From b2fbe41fe1154f9e5f594bf1fa365503a0ab895d Mon Sep 17 00:00:00 2001 From: Brian Long Date: Fri, 13 May 2022 22:37:14 +0100 Subject: [PATCH 1/4] v1.3-SNAPSHOT pom --- pom.xml | 2 +- src/it/deploy-app/pom.xml | 70 ------------- .../aps/modeling/goal/DeployAppGoal.java | 98 ------------------- 3 files changed, 1 insertion(+), 169 deletions(-) delete mode 100644 src/it/deploy-app/pom.xml delete mode 100644 src/main/java/com/inteligr8/maven/aps/modeling/goal/DeployAppGoal.java diff --git a/pom.xml b/pom.xml index 8a24d84..15b7d40 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.inteligr8.alfresco aps-model-maven-plugin - 1.0-SNAPSHOT + 1.3-SNAPSHOT maven-plugin A Maven plugin for Alfresco Process Services model portability diff --git a/src/it/deploy-app/pom.xml b/src/it/deploy-app/pom.xml deleted file mode 100644 index 8f24f58..0000000 --- a/src/it/deploy-app/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - 4.0.0 - - com.inteligr8.alfresco - aps-model-maven-plugin-deploy-app - @pom.version@ - pom - - Deploy App Plugin Tests - - - - - ${project.groupId} - aps-model-maven-plugin - @pom.version@ - - - download-unpack-app - generate-sources - - download-app - unpack-app - - - true - true - - - - translate-app - compile - - translate-app - - - ${project.build.directory}/aps-dev - - - - pack-app - package - - pack-app - - - ${project.build.directory}/aps-dev - ${project.build.directory}/aps-test - - - - deploy-app - package - - deploy-app - - - ${project.build.directory}/aps-test - - - - - - - - diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/DeployAppGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/DeployAppGoal.java deleted file mode 100644 index 9f47975..0000000 --- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/DeployAppGoal.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.inteligr8.maven.aps.modeling.goal; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.text.ParseException; - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.codehaus.plexus.component.annotations.Component; - -import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl; -import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation; -import com.inteligr8.alfresco.activiti.model.FileMultipartJersey; - -@Mojo( name = "deploy-app", threadSafe = true ) -@Component( role = org.apache.maven.plugin.Mojo.class ) -public class DeployAppGoal extends ApsAppAccessibleGoal { - - @Parameter( property = "aps-model.upload.directory", required = true, defaultValue = "${project.build.directory}/aps" ) - protected File zipDirectory; - - @Parameter( property = "publish", required = true, defaultValue = "false" ) - protected boolean publish = false; - - protected final int bufferSize = 128 * 1024; - - @Override - public void executeEnabled() throws MojoExecutionException, MojoFailureException { - File sourceFile = this.validateSourceDirectory(); - - Long appId = this.findAppId(); - - try { - this.uploadApp(appId, sourceFile); - } catch (IOException ie) { - throw new MojoExecutionException("The APS App could not be uploaded", ie); - } - } - - protected File validateSourceDirectory() { - if (!this.zipDirectory.exists()) { - throw new IllegalStateException("The 'zipDirectory' does not exist: " + this.zipDirectory); - } else if (!this.zipDirectory.isDirectory()) { - throw new IllegalStateException("The 'zipDirectory' is not a directory: " + this.zipDirectory); - } - - File sourceFile = new File(this.zipDirectory, this.apsAppName + ".zip"); - - if (!sourceFile.exists()) { - throw new IllegalStateException("The App file does not exists in the 'zipDirectory': " + sourceFile); - } else if (!sourceFile.isFile()) { - throw new IllegalStateException("The App file is not a file: " + sourceFile); - } - - return sourceFile; - } - - private void uploadApp(Long appId, File appZip) throws IOException, MojoExecutionException { - ApsPublicRestApiJerseyImpl api = this.getApsApi(); - - FileInputStream fistream = new FileInputStream(appZip); - BufferedInputStream bistream = new BufferedInputStream(fistream, this.bufferSize); - try { - FileMultipartJersey multipart = FileMultipartJersey.from(appZip.getName(), bistream); - - if (appId == null) { - if (this.publish) { - this.getLog().info("Uploading & publishing new APS App: " + this.apsAppName); - AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(multipart); - if (Boolean.TRUE.equals(appDefUpdate.getError())) - throw new MojoExecutionException(appDefUpdate.getErrorDescription()); - } else { - this.getLog().info("Uploading new APS App: " + this.apsAppName); - api.getAppDefinitionsJerseyApi().importApp(multipart, true); - } - } else { - if (this.publish) { - this.getLog().info("Uploading, versioning, & publishing APS App: " + this.apsAppName + " (" + appId + ")"); - AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(appId, multipart); - if (Boolean.TRUE.equals(appDefUpdate.getError())) - throw new MojoExecutionException(appDefUpdate.getErrorDescription()); - } else { - this.getLog().info("Uploading & versioning APS App: " + this.apsAppName + " (" + appId + ")"); - api.getAppDefinitionsJerseyApi().importApp(appId, multipart, true); - } - } - } catch (ParseException pe) { - throw new MojoExecutionException("The app ZIP could not be wrapped in a multipart", pe); - } finally { - bistream.close(); - } - } - -} From a2befd7dbde89acc16deb6020a098f17a002ab60 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Fri, 13 May 2022 22:39:10 +0100 Subject: [PATCH 2/4] rename deploy to upload; fixed for non-existent apps --- src/it/upload-app/pom.xml | 70 +++++++++++++ .../modeling/goal/ApsAppAccessibleGoal.java | 10 +- .../aps/modeling/goal/DownloadAppGoal.java | 2 +- .../aps/modeling/goal/UploadAppGoal.java | 98 +++++++++++++++++++ 4 files changed, 174 insertions(+), 6 deletions(-) create mode 100644 src/it/upload-app/pom.xml create mode 100644 src/main/java/com/inteligr8/maven/aps/modeling/goal/UploadAppGoal.java diff --git a/src/it/upload-app/pom.xml b/src/it/upload-app/pom.xml new file mode 100644 index 0000000..b64bb4c --- /dev/null +++ b/src/it/upload-app/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + com.inteligr8.alfresco + aps-model-maven-plugin-upload-app + @pom.version@ + pom + + Upload App Plugin Tests + + + + + ${project.groupId} + aps-model-maven-plugin + @pom.version@ + + + download-unpack-app + generate-sources + + download-app + unpack-app + + + true + true + + + + translate-app + compile + + translate-app + + + ${project.build.directory}/aps-dev + + + + pack-app + package + + pack-app + + + ${project.build.directory}/aps-dev + ${project.build.directory}/aps-test + + + + upload-app + package + + upload-app + + + ${project.build.directory}/aps-test + + + + + + + + diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAppAccessibleGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAppAccessibleGoal.java index 489852a..2f0692e 100644 --- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAppAccessibleGoal.java +++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAppAccessibleGoal.java @@ -42,15 +42,15 @@ public abstract class ApsAppAccessibleGoal extends ApsAddressibleGoal { return apps; } - protected Long findAppId() throws MojoExecutionException { - return this.findAppIdByName(this.apsAppName); + protected Long findAppId(boolean failOnNotFound) throws MojoExecutionException { + return this.findAppIdByName(this.apsAppName, failOnNotFound); } - protected Long findAppIdByName(String appName) throws MojoExecutionException { + protected Long findAppIdByName(String appName, boolean failOnNotFound) throws MojoExecutionException { Map apps = this.findAppNameIds(); Long appId = apps.get(this.apsAppName); - if (appId == null) - throw new MojoExecutionException("The APS App '' could not be found; valid apps: " + apps.keySet()); + if (failOnNotFound && appId == null) + throw new MojoExecutionException("The APS App '" + this.apsAppName + "' could not be found; valid apps: " + apps.keySet()); return appId; } diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/DownloadAppGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/DownloadAppGoal.java index 3b7001b..579efc6 100644 --- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/DownloadAppGoal.java +++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/DownloadAppGoal.java @@ -23,7 +23,7 @@ public class DownloadAppGoal extends ApsAppAccessibleGoal { public void executeEnabled() throws MojoExecutionException, MojoFailureException { this.validateTargetDirectory(); - Long appId = this.findAppId(); + Long appId = this.findAppId(true); File appZip = this.downloadApp(appId); File toAppZip = new File(this.zipDirectory, this.apsAppName + ".zip"); diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/UploadAppGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/UploadAppGoal.java new file mode 100644 index 0000000..3d0b1db --- /dev/null +++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/UploadAppGoal.java @@ -0,0 +1,98 @@ +package com.inteligr8.maven.aps.modeling.goal; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.text.ParseException; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.codehaus.plexus.component.annotations.Component; + +import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl; +import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation; +import com.inteligr8.alfresco.activiti.model.FileMultipartJersey; + +@Mojo( name = "upload-app", threadSafe = true ) +@Component( role = org.apache.maven.plugin.Mojo.class ) +public class UploadAppGoal extends ApsAppAccessibleGoal { + + @Parameter( property = "aps-model.upload.directory", required = true, defaultValue = "${project.build.directory}/aps" ) + protected File zipDirectory; + + @Parameter( property = "publish", required = true, defaultValue = "false" ) + protected boolean publish = false; + + protected final int bufferSize = 128 * 1024; + + @Override + public void executeEnabled() throws MojoExecutionException, MojoFailureException { + File sourceFile = this.validateSourceDirectory(); + + Long appId = this.findAppId(false); + + try { + this.uploadApp(appId, sourceFile); + } catch (IOException ie) { + throw new MojoExecutionException("The APS App could not be uploaded", ie); + } + } + + protected File validateSourceDirectory() { + if (!this.zipDirectory.exists()) { + throw new IllegalStateException("The 'zipDirectory' does not exist: " + this.zipDirectory); + } else if (!this.zipDirectory.isDirectory()) { + throw new IllegalStateException("The 'zipDirectory' is not a directory: " + this.zipDirectory); + } + + File sourceFile = new File(this.zipDirectory, this.apsAppName + ".zip"); + + if (!sourceFile.exists()) { + throw new IllegalStateException("The App file does not exists in the 'zipDirectory': " + sourceFile); + } else if (!sourceFile.isFile()) { + throw new IllegalStateException("The App file is not a file: " + sourceFile); + } + + return sourceFile; + } + + private void uploadApp(Long appId, File appZip) throws IOException, MojoExecutionException { + ApsPublicRestApiJerseyImpl api = this.getApsApi(); + + FileInputStream fistream = new FileInputStream(appZip); + BufferedInputStream bistream = new BufferedInputStream(fistream, this.bufferSize); + try { + FileMultipartJersey multipart = FileMultipartJersey.from(appZip.getName(), bistream); + + if (appId == null) { + if (this.publish) { + this.getLog().info("Uploading & publishing new APS App: " + this.apsAppName); + AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(multipart); + if (Boolean.TRUE.equals(appDefUpdate.getError())) + throw new MojoExecutionException(appDefUpdate.getErrorDescription()); + } else { + this.getLog().info("Uploading new APS App: " + this.apsAppName); + api.getAppDefinitionsJerseyApi().importApp(multipart, true); + } + } else { + if (this.publish) { + this.getLog().info("Uploading, versioning, & publishing APS App: " + this.apsAppName + " (" + appId + ")"); + AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(appId, multipart); + if (Boolean.TRUE.equals(appDefUpdate.getError())) + throw new MojoExecutionException(appDefUpdate.getErrorDescription()); + } else { + this.getLog().info("Uploading & versioning APS App: " + this.apsAppName + " (" + appId + ")"); + api.getAppDefinitionsJerseyApi().importApp(appId, multipart, true); + } + } + } catch (ParseException pe) { + throw new MojoExecutionException("The app ZIP could not be wrapped in a multipart", pe); + } finally { + bistream.close(); + } + } + +} From adb43d46b05eca8a7e50c9c0adbfae22ad082c03 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Fri, 13 May 2022 22:39:37 +0100 Subject: [PATCH 3/4] fixed NPE for share-model --- .../maven/aps/modeling/goal/ApsShareGoal.java | 116 ++++++++++-------- 1 file changed, 62 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsShareGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsShareGoal.java index e06d788..544d337 100644 --- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsShareGoal.java +++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsShareGoal.java @@ -28,6 +28,9 @@ import com.inteligr8.maven.aps.modeling.util.Index; @Component( role = org.apache.maven.plugin.Mojo.class ) public class ApsShareGoal extends ApsAddressibleGoal { + @Parameter( property = "aps-model.share.modelName" ) + protected String modelName; + @Parameter( property = "aps-model.share.readers" ) protected String readers; @@ -66,7 +69,6 @@ public class ApsShareGoal extends ApsAddressibleGoal { @Override public void executeEnabled() throws MojoExecutionException, MojoFailureException { - this.getLog().info("editors: " + this.editors); this.normalizeParameters(); this.buildIdentityIndex(); @@ -77,14 +79,19 @@ public class ApsShareGoal extends ApsAddressibleGoal { this.shareModels(ModelsApi.ModelType.Process, this.processReaderSet, this.processEditorSet); if (!this.formReaderSet.isEmpty() || !this.formEditorSet.isEmpty()) - this.shareModels(ModelsApi.ModelType.Form, this.formReaderSet, this.formEditorSet); + this.shareModels(ModelsApi.ModelType.Form, this.formReaderSet, this.formEditorSet); } private void shareModels(ModelsApi.ModelType modelType, Set readers, Set editors) { ResultListDataRepresentation models = this.getApsApi().getModelsApi().get(null, null, modelType.getId(), null); + if (models.getData() == null) + return; + for (Datum datum : models.getData()) { Number modelId = (Number)datum.getAdditionalProperties().get("id"); String modelName = (String)datum.getAdditionalProperties().get("name"); + if (this.modelName != null && !this.modelName.equals(modelName)) + continue; Set groupsAddressed = new HashSet<>(); Set readersUnaddressed = new HashSet<>(readers); @@ -92,65 +99,24 @@ public class ApsShareGoal extends ApsAddressibleGoal { ShareInfoRequest changeRequest = new ShareInfoRequest(); ResultList shares = this.getApsApi().getShareApi().getShareInfo(modelId.toString()); - for (SharePermission share : shares.getData()) { - if (share.getGroup() != null) { - groupsAddressed.add(share.getGroup().getName()); - - if (PermissionLevel.Write.equals(share.getPermission())) { - if (editors.contains(share.getGroup().getName())) { - this.getLog().debug("The named group '" + share.getGroup().getName() + "' is already an editor of model '" + modelName + "'"); - // no change - continue; - } else if (readers.contains(share.getGroup().getName())) { - this.getLog().debug("The named group '" + share.getGroup().getName() + "' reverting from editor to reader of model '" + modelName + "'"); - changeRequest.getUpdated().add(new PermissionLight().withId(share.getId()).withPermission(PermissionLevel.Read)); - continue; - } - } else { - if (editors.contains(share.getGroup().getName())) { - this.getLog().debug("The named group '" + share.getGroup().getName() + "' elevating from reader to editor of model '" + modelName + "'"); - changeRequest.getUpdated().add(new PermissionLight().withId(share.getId()).withPermission(PermissionLevel.Write)); - continue; - } else if (readers.contains(share.getGroup().getName())) { - this.getLog().debug("The named group '" + share.getGroup().getName() + "' is already an reader of model '" + modelName + "'"); - // no change - continue; - } + if (shares.getData() != null) { + for (SharePermission share : shares.getData()) { + if (share.getGroup() != null) { + groupsAddressed.add(share.getGroup().getName()); + this.analyzeChanges(modelName, readers, editors, share, changeRequest); + } else if (share.getPerson() != null) { + this.getLog().debug("Person-based model sharing not supported at this time; ignoring"); } - - if (this.doRevoke) { - this.getLog().debug("The named group '" + share.getGroup().getName() + "' is an unregulated editor of model '" + modelName + "'; revoking ..."); - changeRequest.getRemoved().add(new PermissionLight().withId(share.getId())); - } else { - this.getLog().debug("The named group '" + share.getGroup().getName() + "' is an unregulated editor of model '" + modelName + "'"); - // not touching extra unnamed permissions - } - } else if (share.getPerson() != null) { - this.getLog().debug("Person-based model sharing not supported at this time; ignoring"); } } readersUnaddressed.removeAll(groupsAddressed); - for (String reader : readersUnaddressed) { - Long groupId = this.identityIndex.getValue(reader); - if (groupId == null) { - this.getLog().warn("The named group '" + reader + "' does not exist in APS; ignoring ..."); - } else { - this.getLog().debug("The named group '" + reader + "' becoming a reader of model '" + modelName + "'"); - changeRequest.getAdded().add(new PermissionLight().withGroupId(groupId).withPermission(PermissionLevel.Read)); - } - } + for (String reader : readersUnaddressed) + this.analyzeChanges(modelName, reader, PermissionLevel.Read, changeRequest); editorsUnaddressed.removeAll(groupsAddressed); - for (String editor : editorsUnaddressed) { - Long groupId = this.identityIndex.getValue(editor); - if (groupId == null) { - this.getLog().warn("The named group '" + editor + "' does not exist in APS; ignoring ..."); - } else { - this.getLog().debug("The named group '" + editor + "' becoming an editor of model '" + modelName + "'"); - changeRequest.getAdded().add(new PermissionLight().withGroupId(groupId).withPermission(PermissionLevel.Write)); - } - } + for (String editor : editorsUnaddressed) + this.analyzeChanges(modelName, editor, PermissionLevel.Write, changeRequest); if (!changeRequest.getAdded().isEmpty() || !changeRequest.getUpdated().isEmpty() || !changeRequest.getRemoved().isEmpty()) { this.getLog().info("Sharing model: " + modelType + " => '" + modelName + "'"); @@ -159,6 +125,48 @@ public class ApsShareGoal extends ApsAddressibleGoal { } } + private void analyzeChanges(String modelName, Set readers, Set editors, SharePermission share, ShareInfoRequest changeRequest) { + if (PermissionLevel.Write.equals(share.getPermission())) { + if (editors.contains(share.getGroup().getName())) { + this.getLog().debug("The named group '" + share.getGroup().getName() + "' is already an editor of model '" + modelName + "'"); + // no change + return; + } else if (readers.contains(share.getGroup().getName())) { + this.getLog().debug("The named group '" + share.getGroup().getName() + "' reverting from editor to reader of model '" + modelName + "'"); + changeRequest.getUpdated().add(new PermissionLight().withId(share.getId()).withPermission(PermissionLevel.Read)); + return; + } + } else { + if (editors.contains(share.getGroup().getName())) { + this.getLog().debug("The named group '" + share.getGroup().getName() + "' elevating from reader to editor of model '" + modelName + "'"); + changeRequest.getUpdated().add(new PermissionLight().withId(share.getId()).withPermission(PermissionLevel.Write)); + return; + } else if (readers.contains(share.getGroup().getName())) { + this.getLog().debug("The named group '" + share.getGroup().getName() + "' is already an reader of model '" + modelName + "'"); + // no change + return; + } + } + + if (this.doRevoke) { + this.getLog().debug("The named group '" + share.getGroup().getName() + "' is an unregulated editor of model '" + modelName + "'; revoking ..."); + changeRequest.getRemoved().add(new PermissionLight().withId(share.getId())); + } else { + this.getLog().debug("The named group '" + share.getGroup().getName() + "' is an unregulated editor of model '" + modelName + "'"); + // not touching extra unnamed permissions + } + } + + private void analyzeChanges(String modelName, String groupName, PermissionLevel plevel, ShareInfoRequest changeRequest) { + Long groupId = this.identityIndex.getValue(groupName); + if (groupId == null) { + this.getLog().warn("The named group '" + groupName + "' does not exist in APS; ignoring ..."); + } else { + this.getLog().debug("The named group '" + groupName + "' granted the " + plevel + " role of model '" + modelName + "'"); + changeRequest.getAdded().add(new PermissionLight().withGroupId(groupId).withPermission(plevel)); + } + } + protected void normalizeParameters() { Set readerSet = this.normalizeParameter(this.readers); Set editorSet = this.normalizeParameter(this.editors); From 17594dc52098bb7355e436cfed7ac246d00be872 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Fri, 13 May 2022 22:39:46 +0100 Subject: [PATCH 4/4] added publish-app goal --- .../aps/modeling/goal/PublishAppGoal.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java new file mode 100644 index 0000000..fb06bc0 --- /dev/null +++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java @@ -0,0 +1,40 @@ +package com.inteligr8.maven.aps.modeling.goal; + +import java.io.IOException; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.codehaus.plexus.component.annotations.Component; + +import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl; +import com.inteligr8.alfresco.activiti.model.AppDefinitionPublishRepresentation; + +@Mojo( name = "publish-app", threadSafe = true ) +@Component( role = org.apache.maven.plugin.Mojo.class ) +public class PublishAppGoal extends ApsAppAccessibleGoal { + + @Parameter( property = "aps-model.publish.comment", required = true, defaultValue = "Automated by 'aps-model-maven-plugin'" ) + protected String comment; + + @Override + public void executeEnabled() throws MojoExecutionException, MojoFailureException { + Long appId = this.findAppId(false); + + try { + this.publishApp(appId); + } catch (IOException ie) { + throw new MojoExecutionException("The APS App could not be published", ie); + } + } + + private void publishApp(Long appId) throws IOException, MojoExecutionException { + ApsPublicRestApiJerseyImpl api = this.getApsApi(); + + AppDefinitionPublishRepresentation appDefPublish = new AppDefinitionPublishRepresentation(); + appDefPublish.setComment(this.comment); + api.getAppDefinitionsApi().publish(appId, appDefPublish); + } + +}