diff --git a/pom.xml b/pom.xml
index 1408007..dc76a50 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,8 +1,7 @@
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.inteligr8.alfresco
@@ -11,8 +10,19 @@
maven-plugin
A Maven plugin for Alfresco Process Services model portability
+ Generate Alfresco Module Packages (AMP) files in a way simialr to WAR files
+ https://bitbucket.org/inteligr8/amp-maven-plugin
+
+
+
+ GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007
+ https://www.gnu.org/licenses/lgpl-3.0.txt
+
+
+ scm:git:https://bitbucket.org/inteligr8/aps-model-maven-plugin.git
+ scm:git:git@bitbucket.org:inteligr8/aps-model-maven-plugin.git
https://bitbucket.org/inteligr8/aps-model-maven-plugin
@@ -41,14 +51,12 @@
com.inteligr8.alfresco
aps-public-rest-api
- 2.0.1
- aps1
+ 2.0.3-aps1
com.inteligr8.alfresco
aps-public-rest-client
- 2.0.1
- jersey
+ 2.0.2-jersey
org.apache.commons
@@ -109,10 +117,36 @@
+
+
+
+ maven-invoker-plugin
+ 3.2.2
+
+ ${basedir}/src/it
+ ${project.build.directory}/it
+ ${project.build.directory}/it-repo
+ ${env.MAVEN_HOME}
+ true
+ ${skipTests}
+
+ ${basedir}
+ ${aps-model.baseUrl}
+ ${aps-model.authType}
+ ${aps-model.basicAuth.mavenServerId}
+ ${aps-model.appName}
+ ${aps-model.share.editors}
+ ${aps-model.share.readers}
+ ${aps-model.share.app.editors}
+
+
+
+
+
maven-plugin-plugin
- 3.6.0
+ 3.6.1
aps-model
@@ -143,55 +177,29 @@
-
- maven-invoker-plugin
- 3.2.2
-
- ${basedir}/src/it
- ${project.build.directory}/it
- ${project.build.directory}/it-repo
- ${env.MAVEN_HOME}
- true
- ${skipTests}
-
- ${basedir}
- ${aps-model.baseUrl}
- ${aps-model.authType}
- ${aps-model.basicAuth.mavenServerId}
- ${aps-model.appName}
- ${aps-model.share.editors}
- ${aps-model.share.readers}
- ${aps-model.share.app.editors}
-
-
-
-
- run-its
-
- install
- run
-
-
-
-
-
- maven-javadoc-plugin
-
-
- javadoc
- package
- jar
-
- public
- true
-
-
-
-
-
+
+
+ run-its
+
+
+
+ maven-invoker-plugin
+
+
+ run-its
+
+ install
+ run
+
+
+
+
+
+
+
run-it-1
@@ -203,10 +211,9 @@
maven-invoker-plugin
- 3.2.2
- run-its
+ run-it-1
install
run
@@ -222,22 +229,56 @@
+
+ ossrh-release
+
+
+
+ maven-source-plugin
+
+
+ source
+ package
+ jar-no-fork
+
+
+
+
+ maven-javadoc-plugin
+
+
+ javadoc
+ package
+ jar
+
+ public
+
+
+
+
+
+ maven-gpg-plugin
+
+
+ sign
+ verify
+ sign
+
+
+
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.13
+ true
+
+ ossrh
+ https://s01.oss.sonatype.org/
+ true
+
+
+
+
+
-
-
-
- inteligr8-releases
- Inteligr8 Releases
- https://repos.inteligr8.com/nexus/repository/inteligr8-public
-
-
-
-
-
- inteligr8-releases
- Inteligr8 Releases
- https://repos.inteligr8.com/nexus/repository/inteligr8-public
-
-
-
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawlable.java b/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawlable.java
index 390da7f..0c53a3d 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawlable.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawlable.java
@@ -1,13 +1,48 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.crawler;
+/**
+ * An interface for APS App export transformation implementations.
+ *
+ * An APS App export is a ZIP file that always contains an APS App JSON file.
+ * It may also contain many process XML/JSON files, form JSON files, thumbnail
+ * images, and more.
+ *
+ * @author brian@inteligr8.com
+ */
public interface ApsAppCrawlable {
+ /**
+ * @return A file transformer for APS App JSON files.
+ */
ApsFileTransformer getAppJsonTransformer();
+ /**
+ * @return A file transformer for APS Process JSON files.
+ */
ApsFileTransformer getProcessJsonTransformer();
+ /**
+ * @return A file transformer for APS Process BPMN (XML) files.
+ */
ApsFileTransformer getProcessBpmnTransformer();
+ /**
+ * @return A file transformer for APS Form JSON files.
+ */
ApsFileTransformer getFormJsonTransformer();
}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawler.java b/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawler.java
index 9639572..bdc9629 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawler.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawler.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.crawler;
import java.io.File;
@@ -11,6 +25,12 @@ import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * A class that implements a APS App export crawler. The crawler does not
+ * directly perform any transformations. Those are handled through a callback.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsAppCrawler {
private final Logger logger = LoggerFactory.getLogger(ApsAppCrawler.class);
@@ -20,27 +40,39 @@ public class ApsAppCrawler {
private final File appDescriptor;
private final boolean failOnIntegrityViolation;
+ /**
+ * @param apsAppName A name for the APS App.
+ * @param apsAppDirectory A directory to the unpacked APS App export.
+ * @param failOnIntegrityViolation true to fail on file integrity issues; false to log warnings.
+ */
public ApsAppCrawler(String apsAppName, File apsAppDirectory, boolean failOnIntegrityViolation) {
this.appName = apsAppName;
this.appDirectory = apsAppDirectory;
this.failOnIntegrityViolation = failOnIntegrityViolation;
- this.appDescriptor = this.validateDescriptor(appDirectory);
+ this.appDescriptor = this.validateDescriptor();
if (this.logger.isDebugEnabled())
this.logger.debug("APS App descriptor found: " + this.appDescriptor);
}
- protected File validateDescriptor(File appDirectory) {
- File appDescriptor = new File(appDirectory, this.appName + ".json");
+ /**
+ * @return A file handle to the root APS App JSON (configuration) file.
+ */
+ protected File validateDescriptor() {
+ File appDescriptor = new File(this.appDirectory, this.appName + ".json");
if (!appDescriptor.exists())
- throw new IllegalStateException("The APS App descriptor could not be found: " + appDescriptor);
+ throw new IllegalStateException("The APS App descriptor could not be found: " + this.appDescriptor);
if (!appDescriptor.isFile())
- throw new IllegalStateException("The APS App descriptor is not a file: " + appDescriptor);
+ throw new IllegalStateException("The APS App descriptor is not a file: " + this.appDescriptor);
return appDescriptor;
}
+ /**
+ * @param crawlable A crawlable implementation; the callback for potential transformations.
+ * @throws IOException A file access exception occurred.
+ */
public void execute(ApsAppCrawlable crawlable) throws IOException {
this.logger.info("Crawling APS App ...");
@@ -83,7 +115,7 @@ public class ApsAppCrawler {
}
String modelName = matcher.group(1);
- Long modelId = new Long(matcher.group(2));
+ Long modelId = Long.valueOf(matcher.group(2));
this.logger.trace("Transforming model {} ID: {}", modelName, modelId);
this.transform(transformer, modelFile, modelName, modelId);
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsFileTransformer.java b/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsFileTransformer.java
index 8e9ac56..937da1e 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsFileTransformer.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsFileTransformer.java
@@ -1,10 +1,39 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.crawler;
import java.io.File;
import java.io.IOException;
+/**
+ * This interface provides a common method for transforming various files in an
+ * exported APS App.
+ *
+ * @author brian@inteligr8.com
+ */
public interface ApsFileTransformer {
+ /**
+ * This method transforms the specified file which should be referred to
+ * with the specified name and ID.
+ *
+ * @param file A model file.
+ * @param modelName The target model name.
+ * @param modelId The target model ID.
+ * @throws IOException An I/O related exception has occurred during transformation.
+ */
void transformFile(File file, String modelName, Long modelId) throws IOException;
}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAddressibleGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAddressibleGoal.java
index 896fca5..dfac7bc 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAddressibleGoal.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAddressibleGoal.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import org.apache.maven.execution.MavenSession;
@@ -8,6 +22,14 @@ import com.inteligr8.alfresco.activiti.ApsClientJerseyConfiguration;
import com.inteligr8.alfresco.activiti.ApsClientJerseyImpl;
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
+/**
+ * This class adds APS addressbility to extending goals.
+ *
+ * This is a common need for several goals in this library, as most of those
+ * goals will need to call an APS service to perform their work.
+ *
+ * @author brian@inteligr8.com
+ */
public abstract class ApsAddressibleGoal extends DisablableGoal {
@Parameter( defaultValue = "${session}", readonly = true )
@@ -36,6 +58,14 @@ public abstract class ApsAddressibleGoal extends DisablableGoal {
private ApsPublicRestApiJerseyImpl api;
+ /**
+ * Retrieves an APS client configuration.
+ *
+ * The configuration is built based on the properties injected into this
+ * class. It supports either `BASIC` or `OAuth` based authentication.
+ *
+ * @return An APS client configuration.
+ */
public ApsClientJerseyConfiguration getApsClientConfiguration() {
this.getLog().debug("Configuring APS to URL: " + this.activitiAppBaseUrl);
ApsClientJerseyConfiguration config = new ApsClientJerseyConfiguration();
@@ -86,6 +116,9 @@ public abstract class ApsAddressibleGoal extends DisablableGoal {
return config;
}
+ /**
+ * @return An APS API instance.
+ */
public synchronized ApsPublicRestApiJerseyImpl getApsApi() {
if (this.api == null) {
ApsClientJerseyConfiguration config = this.getApsClientConfiguration();
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 2f0692e..b83abc8 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
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import java.util.HashMap;
@@ -13,11 +27,28 @@ import com.inteligr8.alfresco.activiti.model.Datum;
import com.inteligr8.alfresco.activiti.model.ResultListDataRepresentation;
import com.inteligr8.alfresco.activiti.model.Tenant;
+/**
+ * This class adds the APS App name to APS addressibility to extending goals.
+ *
+ * Only use this class if your goal needs both the APS name and an APS service
+ * client. You can use `ApsAppGoal` or `ApsAddressibleGoal` if you only need
+ * one of those capabilities.
+ *
+ * @author brian@inteligr8.com
+ */
public abstract class ApsAppAccessibleGoal extends ApsAddressibleGoal {
@Parameter( property = "aps-model.appName", required = true )
protected String apsAppName;
+ /**
+ * This method makes the appropriate service calls to find the first APS
+ * tenant ID from the configured APS service.
+ *
+ * This method does not cache the result.
+ *
+ * @return An APS tenant ID; null only if there are no tenants.
+ */
protected Long findTenantId() {
List tenants = this.getApsApi().getAdminApi().getTenants();
if (tenants == null || tenants.isEmpty())
@@ -25,6 +56,14 @@ public abstract class ApsAppAccessibleGoal extends ApsAddressibleGoal {
return tenants.iterator().next().getId();
}
+ /**
+ * This method makes the appropriate service calls to find all the APS
+ * Apps, returning them as a map of names to IDs.
+ *
+ * This method does not cache the result.
+ *
+ * @return A map of APS App names to their respective IDs; may be empty; never null.
+ */
protected Map findAppNameIds() {
ApsPublicRestApiJerseyImpl api = this.getApsApi();
@@ -42,10 +81,31 @@ public abstract class ApsAppAccessibleGoal extends ApsAddressibleGoal {
return apps;
}
+ /**
+ * This method makes the appropriate service calls to find the APS App by
+ * the configured APS App name.
+ *
+ * This method does not cache the result.
+ *
+ * @param failOnNotFound true to fail if not found; false to return null.
+ * @return An APS App ID; null if not found.
+ * @throws MojoExecutionException The APS App could not be found.
+ */
protected Long findAppId(boolean failOnNotFound) throws MojoExecutionException {
return this.findAppIdByName(this.apsAppName, failOnNotFound);
}
+ /**
+ * This method makes the appropriate service calls to find an APS App by
+ * the specified APS App name.
+ *
+ * This method does not cache the result.
+ *
+ * @param apsName An APS App name.
+ * @param failOnNotFound true to fail if not found; false to return null.
+ * @return An APS App ID; null if not found.
+ * @throws MojoExecutionException The APS App could not be found.
+ */
protected Long findAppIdByName(String appName, boolean failOnNotFound) throws MojoExecutionException {
Map apps = this.findAppNameIds();
Long appId = apps.get(this.apsAppName);
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAppGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAppGoal.java
index e60b081..534bd48 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAppGoal.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAppGoal.java
@@ -1,7 +1,26 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import org.apache.maven.plugins.annotations.Parameter;
+/**
+ * This class adds the APS App name to extending goals.
+ *
+ * @author brian@inteligr8.com
+ */
public abstract class ApsAppGoal extends DisablableGoal {
@Parameter( property = "aps-model.appName", required = true )
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsInfoGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsInfoGoal.java
index d3764d5..b0dbd22 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsInfoGoal.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsInfoGoal.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import org.apache.maven.plugin.MojoExecutionException;
@@ -7,6 +21,15 @@ import org.codehaus.plexus.component.annotations.Component;
import com.inteligr8.alfresco.activiti.model.AppVersion;
+/**
+ * A class that implements an APS service information goal.
+ *
+ * This goal will simply output the APS edition and version to the Maven output
+ * at the `INFO` level. It is a great way to test your connection
+ * configuration and network accessibility of the service.
+ *
+ * @author brian@inteligr8.com
+ */
@Mojo( name = "aps-info", threadSafe = true )
@Component( role = org.apache.maven.plugin.Mojo.class )
public class ApsInfoGoal extends ApsAddressibleGoal {
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 544d337..a2993dd 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
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import java.util.Arrays;
@@ -24,6 +38,17 @@ import com.inteligr8.alfresco.activiti.model.SharePermission;
import com.inteligr8.alfresco.activiti.model.Tenant;
import com.inteligr8.maven.aps.modeling.util.Index;
+/**
+ * A class that implements a way to 'share' APS models.
+ *
+ * All APS models are automatically owned by the person that creates them. The
+ * model is then not viewable or editable by anyone else, except for APS
+ * administrators. This class provides a way to automatically 'share' the
+ * synchronized models to groups or individual users. The 'share' may have
+ * readonly or editing capabilities, as configured.
+ *
+ * @author brian@inteligr8.com
+ */
@Mojo( name = "share-models", threadSafe = true )
@Component( role = org.apache.maven.plugin.Mojo.class )
public class ApsShareGoal extends ApsAddressibleGoal {
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/DisablableGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/DisablableGoal.java
index ba1c368..c1929f3 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/DisablableGoal.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/DisablableGoal.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import org.apache.maven.plugin.AbstractMojo;
@@ -5,6 +19,10 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
+/**
+ * This class adds enable/disable capability to any goal. It uses the standard
+ * 'skip' terminology.
+ */
public abstract class DisablableGoal extends AbstractMojo {
@Parameter( property = "aps-model.skip", required = true, defaultValue = "false" )
@@ -24,6 +42,15 @@ public abstract class DisablableGoal extends AbstractMojo {
this.executeEnabled();
}
+ /**
+ * Identical to the `AbstractMojo.execute()` method, but it is only called
+ * when this is enabled.
+ *
+ * @see AbstractMojo#execute()
+ *
+ * @throws MojoExecutionException The goal failed to execute.
+ * @throws MojoFailureException The goal failed whiling executing.
+ */
public abstract void executeEnabled() throws MojoExecutionException, MojoFailureException;
}
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 579efc6..d37f73b 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
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import java.io.File;
@@ -12,6 +26,15 @@ import org.codehaus.plexus.component.annotations.Component;
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
+/**
+ * A class that implements an APS service download goal.
+ *
+ * This goal will simply download the APS App with the specified name from the
+ * specified APS service. The downloaded APS App will remain packed (zipped).
+ * If a file exists with a conflicting name, it will be overwritten.
+ *
+ * @author brian@inteligr8.com
+ */
@Mojo( name = "download-app", threadSafe = true )
@Component( role = org.apache.maven.plugin.Mojo.class )
public class DownloadAppGoal extends ApsAppAccessibleGoal {
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/PackAppGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/PackAppGoal.java
index 69bf6c1..59e0f0c 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/PackAppGoal.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/PackAppGoal.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import java.io.BufferedInputStream;
@@ -18,6 +32,15 @@ import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.component.annotations.Component;
+/**
+ * A class that implements an APS App packaging goal.
+ *
+ * This goal will simply pack (zip) a folder containing an APS App file
+ * structure. If a file exists with a conflicting name, it will be
+ * overwritten.
+ *
+ * @author brian@inteligr8.com
+ */
@Mojo( name = "pack-app", threadSafe = true )
@Component( role = org.apache.maven.plugin.Mojo.class )
public class PackAppGoal extends ApsAppGoal {
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
index fb06bc0..5541a17 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import java.io.IOException;
@@ -11,6 +25,14 @@ import org.codehaus.plexus.component.annotations.Component;
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
import com.inteligr8.alfresco.activiti.model.AppDefinitionPublishRepresentation;
+/**
+ * A class that implements an APS Service publish goal.
+ *
+ * This goal will simply attempt to publish an existing APS App using the APS
+ * Service. It is typically used in conjuection with the `upload-app` goal.
+ *
+ * @author brian@inteligr8.com
+ */
@Mojo( name = "publish-app", threadSafe = true )
@Component( role = org.apache.maven.plugin.Mojo.class )
public class PublishAppGoal extends ApsAppAccessibleGoal {
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/TranslateAppGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/TranslateAppGoal.java
index 126a899..e305016 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/TranslateAppGoal.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/TranslateAppGoal.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import java.io.File;
@@ -13,6 +27,20 @@ import org.codehaus.plexus.component.annotations.Component;
import com.inteligr8.maven.aps.modeling.crawler.ApsAppCrawler;
import com.inteligr8.maven.aps.modeling.translator.ApsAppTranslator;
+/**
+ * A class that implements an APS App translation goal.
+ *
+ * This goal will translate all the JSON and XML files in an APS App to match
+ * the environment referenced by the specified APS App. This relies on all APS
+ * model elements (apps, processes, and forms) to have unique names. The names
+ * of those mdoel elements are used to remap IDs between environments.
+ *
+ * APS does not enforce a unique name constraint. But it is good practice to
+ * avoid using the same name anyhow. This plugin will just make you do it. It
+ * will error if a duplicate is detected.
+ *
+ * @author brian@inteligr8.com
+ */
@Mojo( name = "translate-app", threadSafe = true )
@Component( role = org.apache.maven.plugin.Mojo.class )
public class TranslateAppGoal extends ApsAppAccessibleGoal {
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/UnpackAppGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/UnpackAppGoal.java
index 062e68e..27a49be 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/UnpackAppGoal.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/UnpackAppGoal.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import java.io.BufferedInputStream;
@@ -29,6 +43,15 @@ import com.inteligr8.maven.aps.modeling.crawler.ApsAppCrawler;
import com.inteligr8.maven.aps.modeling.normalizer.ApsAppNormalizer;
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
+/**
+ * A class that implements an APS App unpackaging goal.
+ *
+ * This goal will simply unpack (unzip) an APS App export into a folder. If a
+ * folder of the APS App name already exists, it will be cleared before the
+ * export is unpacked into it.
+ *
+ * @author brian@inteligr8.com
+ */
@Mojo( name = "unpack-app", threadSafe = true )
@Component( role = org.apache.maven.plugin.Mojo.class )
public class UnpackAppGoal extends ApsAppGoal {
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
index 3d0b1db..9396a6a 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/UploadAppGoal.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/UploadAppGoal.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.goal;
import java.io.BufferedInputStream;
@@ -16,6 +30,16 @@ import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation;
import com.inteligr8.alfresco.activiti.model.FileMultipartJersey;
+/**
+ * A class that implements an APS service upload goal.
+ *
+ * This goal will simply upload an APS App package with the specified name to
+ * the specified APS service. Any IDs specified in the uploaded package must
+ * match existing IDs for them to properly version. That is the main purpose
+ * of this plugin and can be achieved using the 'translate-app' goal.
+ *
+ * @author brian@inteligr8.com
+ */
@Mojo( name = "upload-app", threadSafe = true )
@Component( role = org.apache.maven.plugin.Mojo.class )
public class UploadAppGoal extends ApsAppAccessibleGoal {
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsAppJsonNormalizer.java b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsAppJsonNormalizer.java
index a7277e7..b5bae83 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsAppJsonNormalizer.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsAppJsonNormalizer.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.normalizer;
import java.io.File;
@@ -10,21 +24,39 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.inteligr8.maven.aps.modeling.util.ApsModelArrayNodeSorter;
+import com.inteligr8.maven.aps.modeling.util.ArrayNodeObjectSorter;
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
+/**
+ * This class implements an APS App JSON configuration file normalizer.
+ *
+ * This will remove the 'lastUpdated' date of each defined process model. It
+ * will also order the process 'models' by their respective 'name' values.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsAppJsonNormalizer implements ApsFileNormalizer {
private final Logger logger = LoggerFactory.getLogger(ApsAppJsonNormalizer.class);
private final boolean enableSorting;
+ /**
+ * This constructor initializes the default normalizer with or without
+ * sorting.
+ *
+ * The sorting feature is available for a better "diff" experience. If
+ * you intend to commit the APS App configurations to Git, you will want to
+ * enable sorting.
+ *
+ * @param enableSorting true to re-order JSON objects; false to keep as-is.
+ */
public ApsAppJsonNormalizer(boolean enableSorting) {
this.enableSorting = enableSorting;
}
@Override
- public void transformFile(File file, String modelName, Long modelId) throws IOException {
+ public void normalizeFile(File file, String modelName) throws IOException {
this.logger.debug("Normalizing App JSON file: {}", file);
boolean changed = false;
@@ -34,20 +66,27 @@ public class ApsAppJsonNormalizer implements ApsFileNormalizer {
// remove system-level and non-functional fields from models
for (JsonNode _jsonModel : jsonModels) {
ObjectNode jsonModel = (ObjectNode)_jsonModel;
-
- int fields = jsonModel.size();
- jsonModel.remove(Arrays.asList("lastUpdated"));
-// jsonModel.remove(Arrays.asList("createdBy", "createdByFullName", "lastUpdatedBy", "lastUpdatedByFullName", "lastUpdated"));
- if (jsonModel.size() < fields)
- changed = true;
+ changed = this.transformModel(jsonModel) || changed;
}
// sort the models for better 'diff' support
- if (this.enableSorting)
- changed = ApsModelArrayNodeSorter.getInstance().sort(jsonModels, "name") || changed;
+ if (this.enableSorting) {
+ boolean sorted = ArrayNodeObjectSorter.getInstance().sort(jsonModels, "name");
+ this.logger.trace("Sorted App models: {}: {}", modelName, sorted);
+ changed = sorted || changed;
+ }
if (changed)
ModelUtil.getInstance().writeJson(descriptor, file, this.enableSorting);
}
+ private boolean transformModel(ObjectNode jsonModel) {
+ this.logger.trace("Removing excess App model meta-data: {}", jsonModel.get("name"));
+
+ int fields = jsonModel.size();
+ jsonModel.remove(Arrays.asList("lastUpdated"));
+// jsonModel.remove(Arrays.asList("createdBy", "createdByFullName", "lastUpdatedBy", "lastUpdatedByFullName", "lastUpdated"));
+ return jsonModel.size() < fields;
+ }
+
}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsAppNormalizer.java b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsAppNormalizer.java
index 6e607db..0f1b4d6 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsAppNormalizer.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsAppNormalizer.java
@@ -1,12 +1,54 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.normalizer;
import com.inteligr8.maven.aps.modeling.crawler.ApsAppCrawlable;
import com.inteligr8.maven.aps.modeling.crawler.ApsFileTransformer;
+/**
+ * This class defines an APS App package normalizer.
+ *
+ * An APS App package is a ZIP file that contains multiple files in a
+ * predictable folder hierachy with predictable file names. It is effectively
+ * an APS App interchange format specification.
+ *
+ * A package must have at least a single configuration file at the root of the
+ * ZIP package in the JSON format. It must be named the APS App name. That
+ * file will then reference all the model elements contained in the ZIP. Any
+ * model elements not referenced will simply be ignored by APS and by this
+ * plugin.
+ *
+ * This class has methods that provide normalizer for all the various model
+ * elements in an APS App package.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsAppNormalizer implements ApsAppCrawlable {
private final boolean enableSorting;
+ /**
+ * This constructor initializes the default normalizer with or without
+ * sorting.
+ *
+ * The sorting feature is available for a better "diff" experience. If
+ * you intend to commit the APS App configurations to Git, you will want to
+ * enable sorting.
+ *
+ * @param enableSorting true to re-order JSON objects; false to keep as-is.
+ */
public ApsAppNormalizer(boolean enableSorting) {
this.enableSorting = enableSorting;
}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsFileNormalizer.java b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsFileNormalizer.java
index 9ff8d1f..e3de66f 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsFileNormalizer.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsFileNormalizer.java
@@ -1,7 +1,48 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.normalizer;
+import java.io.File;
+import java.io.IOException;
+
import com.inteligr8.maven.aps.modeling.crawler.ApsFileTransformer;
+/**
+ * This interface defines an APS file normalizer.
+ *
+ * Normalization is the transformation of something from one state to a target
+ * (normalized) state. In this context, a configuration is being normalized to
+ * be diff-friendly. That principally means the removal of dates. In theory,
+ * two normalized files will always match unless something of real substance
+ * has changed.
+ */
public interface ApsFileNormalizer extends ApsFileTransformer {
+
+ @Override
+ default void transformFile(File file, String modelName, Long modelId) throws IOException {
+ this.normalizeFile(file, modelName);
+ }
+
+ /**
+ * This method normalizes the specified file which should be referred to
+ * with the specified name.
+ *
+ * @param file A model file.
+ * @param modelName The model name.
+ * @throws IOException An I/O related exception has occurred during normalization.
+ */
+ void normalizeFile(File file, String modelName) throws IOException;
}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsFormJsonNormalizer.java b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsFormJsonNormalizer.java
index 5a96d51..03c0058 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsFormJsonNormalizer.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsFormJsonNormalizer.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.normalizer;
import java.io.File;
@@ -6,14 +20,21 @@ import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * This class implements an APS Form JSON configuration file normalizer.
+ *
+ * This does nothing but log at this time.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsFormJsonNormalizer implements ApsFileNormalizer {
private final Logger logger = LoggerFactory.getLogger(ApsFormJsonNormalizer.class);
@Override
- public void transformFile(File file, String modelName, Long modelId) throws IOException {
+ public void normalizeFile(File file, String modelName) throws IOException {
this.logger.debug("Normalizing Form JSON file: {}", file);
- this.logger.trace("Nothing to normalize: {}", file);
+ this.logger.trace("Nothing to normalize: {}", modelName);
}
}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsProcessBpmnNormalizer.java b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsProcessBpmnNormalizer.java
index 9120c45..273519b 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsProcessBpmnNormalizer.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsProcessBpmnNormalizer.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.normalizer;
import java.io.File;
@@ -14,6 +28,14 @@ import org.xml.sax.SAXException;
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
+/**
+ * This class implements an APS Process BPMN/XML configuration file normalizer.
+ *
+ * This will remove the 'exportDateTime' and 'modelLastUpdated' dates and
+ * 'modelVersion' of the process model.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsProcessBpmnNormalizer implements ApsFileNormalizer {
private static final String NAMESPACE_ACTIVITI_MODELER = "http://activiti.com/modeler";
@@ -21,7 +43,7 @@ public class ApsProcessBpmnNormalizer implements ApsFileNormalizer {
private final Logger logger = LoggerFactory.getLogger(ApsProcessBpmnNormalizer.class);
@Override
- public void transformFile(File file, String modelName, Long modelId) throws IOException {
+ public void normalizeFile(File file, String modelName) throws IOException {
this.logger.debug("Normalizing Process BPMN file: {}", file);
boolean changed = false;
@@ -32,6 +54,8 @@ public class ApsProcessBpmnNormalizer implements ApsFileNormalizer {
changed = this.removeAttributeIfSet(definitionsElement, NAMESPACE_ACTIVITI_MODELER, "exportDateTime") || changed;
changed = this.removeAttributeIfSet(definitionsElement, NAMESPACE_ACTIVITI_MODELER, "modelLastUpdated") || changed;
+ changed = this.removeAttributeIfSet(definitionsElement, NAMESPACE_ACTIVITI_MODELER, "modelVersion") || changed;
+ //changed = this.setAttributeIfSet(definitionsElement, NAMESPACE_ACTIVITI_MODELER, "modelVersion", "0") || changed;
if (changed)
ModelUtil.getInstance().writeXml(bpmn, file);
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsProcessJsonNormalizer.java b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsProcessJsonNormalizer.java
index cc0e1ac..a32ef6a 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsProcessJsonNormalizer.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/normalizer/ApsProcessJsonNormalizer.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.normalizer;
import java.io.File;
@@ -9,21 +23,39 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.inteligr8.maven.aps.modeling.util.ApsModelArrayNodeSorter;
+import com.inteligr8.maven.aps.modeling.util.ArrayNodeObjectSorter;
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
+/**
+ * This class implements an APS Process JSON configuration file normalizer.
+ *
+ * This will do nothing unless sorting is enabled. With sorting, it will order
+ * the 'childShapes' by their respective 'resourceId' values.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsProcessJsonNormalizer implements ApsFileNormalizer {
private final Logger logger = LoggerFactory.getLogger(ApsProcessJsonNormalizer.class);
private final boolean enableSorting;
+ /**
+ * This constructor initializes the default normalizer with or without
+ * sorting.
+ *
+ * The sorting feature is available for a better "diff" experience. If
+ * you intend to commit the APS App configurations to Git, you will want to
+ * enable sorting.
+ *
+ * @param enableSorting true to re-order JSON objects; false to keep as-is.
+ */
public ApsProcessJsonNormalizer(boolean enableSorting) {
this.enableSorting = enableSorting;
}
@Override
- public void transformFile(File file, String modelName, Long modelId) throws IOException {
+ public void normalizeFile(File file, String modelName) throws IOException {
this.logger.debug("Normalizing Process JSON file: {}", file);
if (!this.enableSorting)
@@ -33,8 +65,10 @@ public class ApsProcessJsonNormalizer implements ApsFileNormalizer {
ObjectNode jsonDescriptor = ModelUtil.getInstance().readJson(file, ObjectNode.class);
ArrayNode jsonChildShapes = this.getChildShapes(jsonDescriptor);
+ this.logger.trace("Found Process shapes: {}: {}", modelName, jsonChildShapes.size());
- changed = ApsModelArrayNodeSorter.getInstance().sort(jsonChildShapes, "resourceId") || changed;
+ changed = ArrayNodeObjectSorter.getInstance().sort(jsonChildShapes, "resourceId") || changed;
+ this.logger.trace("Sorted Process shapes: {}: {}", modelName, changed);
if (changed)
ModelUtil.getInstance().writeJson(jsonDescriptor, file, this.enableSorting);
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsAppJsonTranslator.java b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsAppJsonTranslator.java
index 8982aab..64ea976 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsAppJsonTranslator.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsAppJsonTranslator.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.translator;
import java.io.File;
@@ -15,6 +29,19 @@ import com.inteligr8.alfresco.activiti.model.GroupLight;
import com.inteligr8.maven.aps.modeling.util.Index;
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
+/**
+ * This class implements an APS App JSON configuration file translator.
+ *
+ * This will translate the IDs of all the APS App, Processes, and Organizations
+ * referenced in the APS App descriptor.
+ *
+ * Caution: in lieu of implementing APS User translation, APS User identity
+ * references are simply removed. Using APS Users in your APS models is bad
+ * practice. Use APS Organizations, even if that user is the only member of
+ * the group.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsAppJsonTranslator extends ApsOrganizationHandler implements ApsFileTranslator {
private final Logger logger = LoggerFactory.getLogger(ApsAppJsonTranslator.class);
@@ -22,35 +49,45 @@ public class ApsAppJsonTranslator extends ApsOrganizationHandler implements ApsF
private final Index apsProcessIndex;
private final Index fileProcessIndex;
+ /**
+ * This constructor initializes the default translator.
+ *
+ * @param api An APS API reference.
+ * @param apsProcessIndex A map of process IDs to process names as defined in the APS Service.
+ * @param apsOrgIndex A map of organizations (groups) to organization meta-data as defined in the APS Service.
+ * @param fileProcessIndex A map of process IDs to process names as used in the local process files.
+ */
public ApsAppJsonTranslator(
ApsPublicRestApi api,
- Map apsOrgIndex,
Index apsProcessIndex,
+ Map apsOrgIndex,
Index fileProcessIndex) {
super(api, apsOrgIndex);
- this.apsOrgIndex = apsOrgIndex;
this.apsProcessIndex = apsProcessIndex;
+ this.apsOrgIndex = apsOrgIndex;
this.fileProcessIndex = fileProcessIndex;
}
@Override
- public void translateFile(File file, String modelName, Long modelId) throws IOException {
+ public void translateFile(File file, String appName, Long appId) throws IOException {
this.logger.debug("Translating JSON file: {}", file);
boolean changed = false;
- JsonNode descriptor = ModelUtil.getInstance().readJson(file);
+
+ JsonNode jsonDescriptor = ModelUtil.getInstance().readJson(file);
- changed = this.translateModels(descriptor) || changed;
- changed = this.translateIdentities(descriptor) || changed;
+ changed = this.translateModels(jsonDescriptor, appName) || changed;
+ changed = this.translateIdentities(jsonDescriptor, appName) || changed;
if (changed)
- ModelUtil.getInstance().writeJson(descriptor, file, false);
+ ModelUtil.getInstance().writeJson(jsonDescriptor, file, false);
}
- private boolean translateModels(JsonNode descriptor) {
+ private boolean translateModels(JsonNode jsonDescriptor, String appName) {
+ this.logger.trace("Translating processes in App: {}", appName);
boolean changed = false;
- for (JsonNode _jsonModel : descriptor.get("definition").get("models")) {
+ for (JsonNode _jsonModel : jsonDescriptor.get("definition").get("models")) {
ObjectNode jsonModel = (ObjectNode)_jsonModel;
String fileProcessName = jsonModel.get("name").asText();
@@ -91,10 +128,11 @@ public class ApsAppJsonTranslator extends ApsOrganizationHandler implements ApsF
return changed;
}
- private boolean translateIdentities(JsonNode descriptor) {
+ private boolean translateIdentities(JsonNode jsonDescriptor, String appName) {
+ this.logger.trace("Translating identities in App: {}", appName);
boolean changed = false;
- Iterator i = descriptor.get("definition").get("publishIdentityInfo").iterator();
+ Iterator i = jsonDescriptor.get("definition").get("publishIdentityInfo").iterator();
while (i.hasNext()) {
JsonNode jsonIdentityInfo = i.next();
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsAppTranslator.java b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsAppTranslator.java
index 6fe46d3..e206885 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsAppTranslator.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsAppTranslator.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.translator;
import java.io.File;
@@ -13,7 +27,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.inteligr8.alfresco.activiti.ApsPublicRestApi;
-import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
import com.inteligr8.alfresco.activiti.api.ModelsApi.ModelType;
import com.inteligr8.alfresco.activiti.model.Datum;
import com.inteligr8.alfresco.activiti.model.GroupLight;
@@ -23,6 +36,24 @@ import com.inteligr8.maven.aps.modeling.crawler.ApsAppCrawlable;
import com.inteligr8.maven.aps.modeling.crawler.ApsFileTransformer;
import com.inteligr8.maven.aps.modeling.util.Index;
+/**
+ * This class defines an APS App package translator.
+ *
+ * An APS App package is a ZIP file that contains multiple files in a
+ * predictable folder hierachy with predictable file names. It is effectively
+ * an APS App interchange format specification.
+ *
+ * A package must have at least a single configuration file at the root of the
+ * ZIP package in the JSON format. It must be named the APS App name. That
+ * file will then reference all the model elements contained in the ZIP. Any
+ * model elements not referenced will simply be ignored by APS and by this
+ * plugin.
+ *
+ * This class has methods that provide translator for all the various model
+ * elements in an APS App package.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsAppTranslator implements ApsAppCrawlable {
private final Logger logger = LoggerFactory.getLogger(ApsAppTranslator.class);
@@ -38,11 +69,27 @@ public class ApsAppTranslator implements ApsAppCrawlable {
private Index fileProcessIndex;
private Index fileSubprocessIndex;
- public ApsAppTranslator(File apsAppDirectory, ApsPublicRestApiJerseyImpl api) {
+ /**
+ * This constructor initializes the default translator.
+ *
+ * The specified directory and a reference to the APS Service are both
+ * required. This way the configuration file can be cross-referenced with
+ * the APS App IDs on the target APS instance.
+ *
+ * @param apsAppDirectory The directory of the unpacked APS package.
+ * @param api An APS API reference.
+ */
+ public ApsAppTranslator(File apsAppDirectory, ApsPublicRestApi api) {
this.api = api;
this.appDirectory = apsAppDirectory;
}
+ /**
+ * This method initializes the data required from the APS Service for the
+ * function of this class.
+ *
+ * @throws IOException A network I/O related issue occurred.
+ */
public synchronized void buildIndexes() throws IOException {
if (this.indexesBuilt)
return;
@@ -96,8 +143,8 @@ public class ApsAppTranslator implements ApsAppCrawlable {
return new ApsAppJsonTranslator(
this.api,
- this.apsOrgIndex,
this.apsProcessIndex,
+ this.apsOrgIndex,
this.fileProcessIndex);
}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsFileTranslator.java b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsFileTranslator.java
index f542e56..9ecc985 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsFileTranslator.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsFileTranslator.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.translator;
import java.io.File;
@@ -5,6 +19,14 @@ import java.io.IOException;
import com.inteligr8.maven.aps.modeling.crawler.ApsFileTransformer;
+/**
+ * This interface defines an APS file translator.
+ *
+ * Translation is the transformation of something from one state to a target
+ * state. In this context, a configuration is being translated to be import
+ * friendly for the target APS Service. That principally means the update
+ * of APS model IDs.
+ */
public interface ApsFileTranslator extends ApsFileTransformer {
@Override
@@ -12,6 +34,15 @@ public interface ApsFileTranslator extends ApsFileTransformer {
this.translateFile(file, modelName, modelId);
}
+ /**
+ * This method translates the specified file which should be referred to
+ * with the specified name and ID.
+ *
+ * @param file A model file.
+ * @param modelName The target model name.
+ * @param modelId The target model ID.
+ * @throws IOException An I/O related exception has occurred during translation.
+ */
void translateFile(File file, String modelName, Long modelId) throws IOException;
}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsFormJsonTranslator.java b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsFormJsonTranslator.java
index eb46762..d0175f7 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsFormJsonTranslator.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsFormJsonTranslator.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.translator;
import java.io.File;
@@ -11,11 +25,23 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import com.inteligr8.maven.aps.modeling.util.Index;
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
+/**
+ * This class implements an APS Form JSON configuration file translator.
+ *
+ * This will translate the form ID embedded into APS Form descriptor.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsFormJsonTranslator implements ApsFileTranslator {
private final Logger logger = LoggerFactory.getLogger(ApsFormJsonTranslator.class);
private final Index apsIndex;
+ /**
+ * This constructor initializes the default translator.
+ *
+ * @param apsFormIndex A map of form IDs to form names as defined in the APS Service.
+ */
public ApsFormJsonTranslator(Index apsFormIndex) {
this.apsIndex = apsFormIndex;
}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsOrganizationHandler.java b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsOrganizationHandler.java
index f28fe09..3116baa 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsOrganizationHandler.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsOrganizationHandler.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.translator;
import java.util.Map;
@@ -9,12 +23,21 @@ import com.inteligr8.alfresco.activiti.ApsPublicRestApi;
import com.inteligr8.alfresco.activiti.model.Group;
import com.inteligr8.alfresco.activiti.model.GroupLight;
+/**
+ * This class provides APS Organization support.
+ *
+ * @author brian@inteligr8.com.
+ */
public class ApsOrganizationHandler {
private final Logger logger = LoggerFactory.getLogger(ApsOrganizationHandler.class);
private final ApsPublicRestApi api;
private final Map apsOrgIndex;
+ /**
+ * @param api An APS API reference.
+ * @param apsOrgIndex A map of organization IDs to organization meta-data defined in the APS service.
+ */
public ApsOrganizationHandler(
ApsPublicRestApi api,
Map apsOrgIndex) {
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsProcessBpmnTranslator.java b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsProcessBpmnTranslator.java
index 5e7083a..e2d2dfd 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsProcessBpmnTranslator.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsProcessBpmnTranslator.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.translator;
import java.io.File;
@@ -27,6 +41,19 @@ import com.inteligr8.alfresco.activiti.model.GroupLight;
import com.inteligr8.maven.aps.modeling.util.Index;
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
+/**
+ * This class implements an APS Process BPMN/XML configuration file translator.
+ *
+ * This will translate the IDs of all the APS Process, Organizations, and
+ * Forms referenced in the APS Process BPMN.
+ *
+ * Caution: in lieu of implementing APS User translation, APS User identity
+ * references are simply removed. Using APS Users in your APS models is bad
+ * practice. Use APS Organizations, even if that user is the only member of
+ * the group.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsProcessBpmnTranslator extends ApsOrganizationHandler implements ApsFileTranslator {
private static final String NAMESPACE_ACTIVITI = "http://activiti.org/bpmn";
@@ -38,6 +65,15 @@ public class ApsProcessBpmnTranslator extends ApsOrganizationHandler implements
private final Index apsFormIndex;
private final Index fileFormIndex;
+ /**
+ * This constructor initializes the default translator.
+ *
+ * @param api An APS API reference.
+ * @param apsProcessIndex A map of process IDs to process names as defined in the APS Service.
+ * @param apsOrgIndex A map of organizations (groups) to organization meta-data as defined in the APS Service.
+ * @param apsFormIndex A map of form IDs to form names as defined in the APS Service.
+ * @param fileFormIndex A map of form IDS to form names as used in the local form files.
+ */
public ApsProcessBpmnTranslator(
ApsPublicRestApi api,
Index apsProcessIndex,
@@ -106,8 +142,6 @@ public class ApsProcessBpmnTranslator extends ApsOrganizationHandler implements
if (apsProcessId != null)
changed = this.setAttributeIfSet(definitionsElement, NAMESPACE_ACTIVITI_MODELER, "modelId", apsProcessId) || changed;
- changed = this.removeAttributeIfSet(definitionsElement, NAMESPACE_ACTIVITI_MODELER, "modelVersion") || changed;
- //changed = this.setAttributeIfSet(definitionsElement, NAMESPACE_ACTIVITI_MODELER, "modelVersion", "0") || changed;
return changed;
}
@@ -340,14 +374,5 @@ public class ApsProcessBpmnTranslator extends ApsOrganizationHandler implements
attr.setValue(value.toString());
return true;
}
-
- private boolean removeAttributeIfSet(Element element, String attrNamespace, String attrName) {
- Attr attr = element.getAttributeNodeNS(attrNamespace, attrName);
- if (attr == null)
- return false;
-
- element.removeAttributeNode(attr);
- return true;
- }
}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsProcessJsonTranslator.java b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsProcessJsonTranslator.java
index ef527de..37090a4 100644
--- a/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsProcessJsonTranslator.java
+++ b/src/main/java/com/inteligr8/maven/aps/modeling/translator/ApsProcessJsonTranslator.java
@@ -1,3 +1,17 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
package com.inteligr8.maven.aps.modeling.translator;
import java.io.File;
@@ -15,6 +29,19 @@ import com.inteligr8.alfresco.activiti.model.GroupLight;
import com.inteligr8.maven.aps.modeling.util.Index;
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
+/**
+ * This class implements an APS Process JSON configuration file translator.
+ *
+ * This will translate the IDs of all the APS Process, Organizations, and
+ * Forms referenced in the APS Process descriptor.
+ *
+ * Caution: in lieu of implementing APS User translation, APS User identity
+ * references are simply removed. Using APS Users in your APS models is bad
+ * practice. Use APS Organizations, even if that user is the only member of
+ * the group.
+ *
+ * @author brian@inteligr8.com
+ */
public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements ApsFileTranslator {
private final Logger logger = LoggerFactory.getLogger(ApsProcessJsonTranslator.class);
@@ -22,6 +49,14 @@ public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements
private final Map apsOrgIndex;
private final Index apsFormIndex;
+ /**
+ * This constructor initializes the default translator.
+ *
+ * @param api An APS API reference.
+ * @param apsProcessIndex A map of process IDs to process names as defined in the APS Service.
+ * @param apsOrgIndex A map of organizations (groups) to organization meta-data as defined in the APS Service.
+ * @param apsFormIndex A map of form IDs to form names as defined in the APS Service.
+ */
public ApsProcessJsonTranslator(
ApsPublicRestApi api,
Index apsProcessIndex,
@@ -42,21 +77,22 @@ public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements
ObjectNode jsonDescriptor = ModelUtil.getInstance().readJson(file, ObjectNode.class);
- changed = this.translateResourceId(jsonDescriptor, apsProcessId) || changed;
- changed = this.translateOrganizations(jsonDescriptor) || changed;
- changed = this.translateForms(jsonDescriptor) || changed;
- changed = this.translateSubprocesses(jsonDescriptor) || changed;
+ changed = this.translateResourceId(jsonDescriptor, processName, apsProcessId) || changed;
+ changed = this.translateOrganizations(jsonDescriptor, processName) || changed;
+ changed = this.translateForms(jsonDescriptor, processName) || changed;
+ changed = this.translateSubprocesses(jsonDescriptor, processName) || changed;
if (changed)
ModelUtil.getInstance().writeJson(jsonDescriptor, file, false);
}
- private boolean translateResourceId(ObjectNode jsonDescriptor, Long apsProcessId) {
+ private boolean translateResourceId(ObjectNode jsonDescriptor, String processName, Long apsProcessId) {
if (apsProcessId == null) {
this.logger.trace("The process is not in APS; treating as new");
return false;
}
+ this.logger.trace("Translating resource ID in process: {}", processName);
ObjectNode resourceIdParentJson = jsonDescriptor;
JsonNode jsonResourceId = jsonDescriptor.get("resourceId");
@@ -83,7 +119,8 @@ public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements
- private boolean translateOrganizations(ObjectNode jsonDescriptor) {
+ private boolean translateOrganizations(ObjectNode jsonDescriptor, String processName) {
+ this.logger.trace("Translating organizations in process: {}", processName);
boolean changed = false;
for (JsonNode jsonChildShape : this.getChildShapes(jsonDescriptor)) {
@@ -134,7 +171,8 @@ public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements
- private boolean translateForms(ObjectNode jsonDescriptor) {
+ private boolean translateForms(ObjectNode jsonDescriptor, String processName) {
+ this.logger.trace("Translating forms in process: {}", processName);
boolean changed = false;
for (JsonNode jsonChildShape : this.getChildShapes(jsonDescriptor)) {
@@ -168,7 +206,8 @@ public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements
- private boolean translateSubprocesses(ObjectNode jsonDescriptor) {
+ private boolean translateSubprocesses(ObjectNode jsonDescriptor, String processName) {
+ this.logger.trace("Translating subprocesses in process: {}", processName);
boolean changed = false;
for (JsonNode jsonChildShape : this.getChildShapes(jsonDescriptor)) {
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/util/ApsModelArrayNodeSorter.java b/src/main/java/com/inteligr8/maven/aps/modeling/util/ApsModelArrayNodeSorter.java
deleted file mode 100644
index 11c49c3..0000000
--- a/src/main/java/com/inteligr8/maven/aps/modeling/util/ApsModelArrayNodeSorter.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.inteligr8.maven.aps.modeling.util;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-public class ApsModelArrayNodeSorter extends ArrayNodeObjectSorter {
-
- private static ApsModelArrayNodeSorter INSTANCE = new ApsModelArrayNodeSorter();
-
- public static ApsModelArrayNodeSorter getInstance() {
- return INSTANCE;
- }
-
-
-
- protected ApsModelArrayNodeSorter() {
- }
-
- public boolean sort(ArrayNode arrayNode, String jsonObjectFieldName) {
- return this.sort(arrayNode, new ObjectNodeComparator(jsonObjectFieldName));
- }
-
-}
diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/util/ApsModelListMapSorter.java b/src/main/java/com/inteligr8/maven/aps/modeling/util/ApsModelListMapSorter.java
deleted file mode 100644
index 212a048..0000000
--- a/src/main/java/com/inteligr8/maven/aps/modeling/util/ApsModelListMapSorter.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.inteligr8.maven.aps.modeling.util;
-
-import java.util.List;
-import java.util.Map;
-
-public class ApsModelListMapSorter extends ListMapSorter {
-
- private static ApsModelListMapSorter INSTANCE = new ApsModelListMapSorter();
-
- public static ApsModelListMapSorter getInstance() {
- return INSTANCE;
- }
-
-
-
- protected ApsModelListMapSorter() {
- }
-
- public boolean sort(List