@Override public void onClick(final Optional<AjaxRequestTarget> targetOptional) { final IModel<Boolean> failed = Model.of(Boolean.FALSE); table.visitChildren(MetaContextItem.class, new IVisitor<MetaContextItem<OArtifact, ?>,Void >() { @Override public void component(MetaContextItem<OArtifact, ?> rowItem, IVisit<Void> visit) { OArtifact module = rowItem.getModelObject(); if (isUserArtifactValid(targetOptional, module)) { OArtifact moduleForUpdate = new OArtifact(module.getPreviousArtifactRefence()); moduleForUpdate.setLoad(module.isLoad()) .setTrusted(module.isTrusted()); OrienteerClassLoaderUtil.updateOArtifactInMetadata(moduleForUpdate, module); } else failed.setObject(Boolean.TRUE); visit.dontGoDeeper(); } }); if (!failed.getObject()) { showFeedback(targetOptional, false); super.onClick(targetOptional); } }
protected void sendErrorFeedback(Optional<AjaxRequestTarget> targetOptional, IModel<String> message) { showFeedback(targetOptional, true); feedback.add(AttributeModifier.append(STYLE, ERROR_STYLE)); feedback.setDefaultModel(message); }
/** * Validate user OArtifact and send error message if OModuleConfiguration is not valid. * @param module - user OoArtifact * @return true - if user OoArtifact is valid * false - if user OoArtifact is not valid */ protected boolean isUserArtifactValid(Optional<AjaxRequestTarget> targetOptional, OArtifact module) { OArtifactReference artifact = module.getArtifactReference(); if (Strings.isNullOrEmpty(artifact.getGroupId())) { sendErrorFeedback(targetOptional, new ResourceModel(GROUP_NULL)); return false; } if (Strings.isNullOrEmpty(artifact.getArtifactId())) { sendErrorFeedback(targetOptional, new ResourceModel(ARTIFACT_NULL)); return false; } if (Strings.isNullOrEmpty(artifact.getVersion())) { sendErrorFeedback(targetOptional, new ResourceModel(VERSION_NULL)); return false; } if (Strings.isNullOrEmpty(artifact.getDescription())) { artifact.setDescription(""); } if (Strings.isNullOrEmpty(artifact.getRepository())) { artifact.setRepository(""); } return true; }
protected void sendSuccessFeedback(Optional<AjaxRequestTarget> targetOptional) { showFeedback(targetOptional,true); feedback.add(AttributeModifier.append(STYLE, SUCCESS_STYLE)); feedback.setDefaultModel(new ResourceModel(SUCCESS_MSG)); }