Loading pom.xml +113 −72 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.inteligr8.alfresco</groupId> Loading @@ -11,8 +10,19 @@ <packaging>maven-plugin</packaging> <name>A Maven plugin for Alfresco Process Services model portability</name> <description>Generate Alfresco Module Packages (AMP) files in a way simialr to WAR files</description> <url>https://bitbucket.org/inteligr8/amp-maven-plugin</url> <licenses> <license> <name>GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007</name> <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url> </license> </licenses> <scm> <connection>scm:git:https://bitbucket.org/inteligr8/aps-model-maven-plugin.git</connection> <developerConnection>scm:git:git@bitbucket.org:inteligr8/aps-model-maven-plugin.git</developerConnection> <url>https://bitbucket.org/inteligr8/aps-model-maven-plugin</url> </scm> <organization> Loading Loading @@ -41,14 +51,12 @@ <dependency> <groupId>com.inteligr8.alfresco</groupId> <artifactId>aps-public-rest-api</artifactId> <version>2.0.1</version> <classifier>aps1</classifier> <version>2.0.3-aps1</version> </dependency> <dependency> <groupId>com.inteligr8.alfresco</groupId> <artifactId>aps-public-rest-client</artifactId> <version>2.0.1</version> <classifier>jersey</classifier> <version>2.0.2-jersey</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> Loading Loading @@ -109,10 +117,36 @@ </dependencies> <build> <pluginManagement> <plugins> <plugin> <artifactId>maven-invoker-plugin</artifactId> <version>3.2.2</version> <configuration> <projectsDirectory>${basedir}/src/it</projectsDirectory> <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> <localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath> <mavenHome>${env.MAVEN_HOME}</mavenHome> <debug>true</debug> <skipInvocation>${skipTests}</skipInvocation> <properties> <project.main.basedir>${basedir}</project.main.basedir> <aps-model.baseUrl>${aps-model.baseUrl}</aps-model.baseUrl> <aps-model.authType>${aps-model.authType}</aps-model.authType> <aps-model.basicAuth.mavenServerId>${aps-model.basicAuth.mavenServerId}</aps-model.basicAuth.mavenServerId> <aps-model.appName>${aps-model.appName}</aps-model.appName> <aps-model.share.editors>${aps-model.share.editors}</aps-model.share.editors> <aps-model.share.readers>${aps-model.share.readers}</aps-model.share.readers> <aps-model.share.app.editors>${aps-model.share.app.editors}</aps-model.share.app.editors> </properties> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <artifactId>maven-plugin-plugin</artifactId> <version>3.6.0</version> <version>3.6.1</version> <configuration> <goalPrefix>aps-model</goalPrefix> </configuration> Loading Loading @@ -143,27 +177,16 @@ </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <id>run-its</id> <build> <plugins> <plugin> <artifactId>maven-invoker-plugin</artifactId> <version>3.2.2</version> <configuration> <projectsDirectory>${basedir}/src/it</projectsDirectory> <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> <localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath> <mavenHome>${env.MAVEN_HOME}</mavenHome> <debug>true</debug> <skipInvocation>${skipTests}</skipInvocation> <properties> <project.main.basedir>${basedir}</project.main.basedir> <aps-model.baseUrl>${aps-model.baseUrl}</aps-model.baseUrl> <aps-model.authType>${aps-model.authType}</aps-model.authType> <aps-model.basicAuth.mavenServerId>${aps-model.basicAuth.mavenServerId}</aps-model.basicAuth.mavenServerId> <aps-model.appName>${aps-model.appName}</aps-model.appName> <aps-model.share.editors>${aps-model.share.editors}</aps-model.share.editors> <aps-model.share.readers>${aps-model.share.readers}</aps-model.share.readers> <aps-model.share.app.editors>${aps-model.share.app.editors}</aps-model.share.app.editors> </properties> </configuration> <executions> <execution> <id>run-its</id> Loading @@ -174,24 +197,9 @@ </execution> </executions> </plugin> <plugin> <artifactId>maven-javadoc-plugin</artifactId> <executions> <execution> <id>javadoc</id> <phase>package</phase> <goals><goal>jar</goal></goals> <configuration> <show>public</show> <skip>true</skip> </configuration> </execution> </executions> </plugin> </plugins> </build> <profiles> </profile> <profile> <id>run-it-1</id> <activation> Loading @@ -203,10 +211,9 @@ <plugins> <plugin> <artifactId>maven-invoker-plugin</artifactId> <version>3.2.2</version> <executions> <execution> <id>run-its</id> <id>run-it-1</id> <goals> <goal>install</goal> <goal>run</goal> Loading @@ -222,22 +229,56 @@ </plugins> </build> </profile> <profile> <id>ossrh-release</id> <build> <plugins> <plugin> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>source</id> <phase>package</phase> <goals><goal>jar-no-fork</goal></goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-javadoc-plugin</artifactId> <executions> <execution> <id>javadoc</id> <phase>package</phase> <goals><goal>jar</goal></goals> <configuration> <show>public</show> </configuration> </execution> </executions> </plugin> <plugin> <artifactId>maven-gpg-plugin</artifactId> <executions> <execution> <id>sign</id> <phase>verify</phase> <goals><goal>sign</goal></goals> </execution> </executions> </plugin> <plugin> <groupId>org.sonatype.plugins</groupId> <artifactId>nexus-staging-maven-plugin</artifactId> <version>1.6.13</version> <extensions>true</extensions> <configuration> <serverId>ossrh</serverId> <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl> <autoReleaseAfterClose>true</autoReleaseAfterClose> </configuration> </plugin> </plugins> </build> </profile> </profiles> <repositories> <repository> <id>inteligr8-releases</id> <name>Inteligr8 Releases</name> <url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url> </repository> </repositories> <distributionManagement> <repository> <id>inteligr8-releases</id> <name>Inteligr8 Releases</name> <url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url> </repository> </distributionManagement> </project> src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawlable.java +35 −0 Original line number Diff line number Diff line /* * 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 <https://www.gnu.org/licenses/>. */ 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(); } src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawler.java +38 −6 Original line number Diff line number Diff line /* * 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 <https://www.gnu.org/licenses/>. */ package com.inteligr8.maven.aps.modeling.crawler; import java.io.File; Loading @@ -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); Loading @@ -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 ..."); Loading Loading @@ -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); Loading src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsFileTransformer.java +29 −0 Original line number Diff line number Diff line /* * 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 <https://www.gnu.org/licenses/>. */ 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; } src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAddressibleGoal.java +33 −0 Original line number Diff line number Diff line /* * 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 <https://www.gnu.org/licenses/>. */ package com.inteligr8.maven.aps.modeling.goal; import org.apache.maven.execution.MavenSession; Loading @@ -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 ) Loading Loading @@ -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(); Loading Loading @@ -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(); Loading Loading
pom.xml +113 −72 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.inteligr8.alfresco</groupId> Loading @@ -11,8 +10,19 @@ <packaging>maven-plugin</packaging> <name>A Maven plugin for Alfresco Process Services model portability</name> <description>Generate Alfresco Module Packages (AMP) files in a way simialr to WAR files</description> <url>https://bitbucket.org/inteligr8/amp-maven-plugin</url> <licenses> <license> <name>GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007</name> <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url> </license> </licenses> <scm> <connection>scm:git:https://bitbucket.org/inteligr8/aps-model-maven-plugin.git</connection> <developerConnection>scm:git:git@bitbucket.org:inteligr8/aps-model-maven-plugin.git</developerConnection> <url>https://bitbucket.org/inteligr8/aps-model-maven-plugin</url> </scm> <organization> Loading Loading @@ -41,14 +51,12 @@ <dependency> <groupId>com.inteligr8.alfresco</groupId> <artifactId>aps-public-rest-api</artifactId> <version>2.0.1</version> <classifier>aps1</classifier> <version>2.0.3-aps1</version> </dependency> <dependency> <groupId>com.inteligr8.alfresco</groupId> <artifactId>aps-public-rest-client</artifactId> <version>2.0.1</version> <classifier>jersey</classifier> <version>2.0.2-jersey</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> Loading Loading @@ -109,10 +117,36 @@ </dependencies> <build> <pluginManagement> <plugins> <plugin> <artifactId>maven-invoker-plugin</artifactId> <version>3.2.2</version> <configuration> <projectsDirectory>${basedir}/src/it</projectsDirectory> <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> <localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath> <mavenHome>${env.MAVEN_HOME}</mavenHome> <debug>true</debug> <skipInvocation>${skipTests}</skipInvocation> <properties> <project.main.basedir>${basedir}</project.main.basedir> <aps-model.baseUrl>${aps-model.baseUrl}</aps-model.baseUrl> <aps-model.authType>${aps-model.authType}</aps-model.authType> <aps-model.basicAuth.mavenServerId>${aps-model.basicAuth.mavenServerId}</aps-model.basicAuth.mavenServerId> <aps-model.appName>${aps-model.appName}</aps-model.appName> <aps-model.share.editors>${aps-model.share.editors}</aps-model.share.editors> <aps-model.share.readers>${aps-model.share.readers}</aps-model.share.readers> <aps-model.share.app.editors>${aps-model.share.app.editors}</aps-model.share.app.editors> </properties> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <artifactId>maven-plugin-plugin</artifactId> <version>3.6.0</version> <version>3.6.1</version> <configuration> <goalPrefix>aps-model</goalPrefix> </configuration> Loading Loading @@ -143,27 +177,16 @@ </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <id>run-its</id> <build> <plugins> <plugin> <artifactId>maven-invoker-plugin</artifactId> <version>3.2.2</version> <configuration> <projectsDirectory>${basedir}/src/it</projectsDirectory> <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> <localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath> <mavenHome>${env.MAVEN_HOME}</mavenHome> <debug>true</debug> <skipInvocation>${skipTests}</skipInvocation> <properties> <project.main.basedir>${basedir}</project.main.basedir> <aps-model.baseUrl>${aps-model.baseUrl}</aps-model.baseUrl> <aps-model.authType>${aps-model.authType}</aps-model.authType> <aps-model.basicAuth.mavenServerId>${aps-model.basicAuth.mavenServerId}</aps-model.basicAuth.mavenServerId> <aps-model.appName>${aps-model.appName}</aps-model.appName> <aps-model.share.editors>${aps-model.share.editors}</aps-model.share.editors> <aps-model.share.readers>${aps-model.share.readers}</aps-model.share.readers> <aps-model.share.app.editors>${aps-model.share.app.editors}</aps-model.share.app.editors> </properties> </configuration> <executions> <execution> <id>run-its</id> Loading @@ -174,24 +197,9 @@ </execution> </executions> </plugin> <plugin> <artifactId>maven-javadoc-plugin</artifactId> <executions> <execution> <id>javadoc</id> <phase>package</phase> <goals><goal>jar</goal></goals> <configuration> <show>public</show> <skip>true</skip> </configuration> </execution> </executions> </plugin> </plugins> </build> <profiles> </profile> <profile> <id>run-it-1</id> <activation> Loading @@ -203,10 +211,9 @@ <plugins> <plugin> <artifactId>maven-invoker-plugin</artifactId> <version>3.2.2</version> <executions> <execution> <id>run-its</id> <id>run-it-1</id> <goals> <goal>install</goal> <goal>run</goal> Loading @@ -222,22 +229,56 @@ </plugins> </build> </profile> <profile> <id>ossrh-release</id> <build> <plugins> <plugin> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>source</id> <phase>package</phase> <goals><goal>jar-no-fork</goal></goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-javadoc-plugin</artifactId> <executions> <execution> <id>javadoc</id> <phase>package</phase> <goals><goal>jar</goal></goals> <configuration> <show>public</show> </configuration> </execution> </executions> </plugin> <plugin> <artifactId>maven-gpg-plugin</artifactId> <executions> <execution> <id>sign</id> <phase>verify</phase> <goals><goal>sign</goal></goals> </execution> </executions> </plugin> <plugin> <groupId>org.sonatype.plugins</groupId> <artifactId>nexus-staging-maven-plugin</artifactId> <version>1.6.13</version> <extensions>true</extensions> <configuration> <serverId>ossrh</serverId> <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl> <autoReleaseAfterClose>true</autoReleaseAfterClose> </configuration> </plugin> </plugins> </build> </profile> </profiles> <repositories> <repository> <id>inteligr8-releases</id> <name>Inteligr8 Releases</name> <url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url> </repository> </repositories> <distributionManagement> <repository> <id>inteligr8-releases</id> <name>Inteligr8 Releases</name> <url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url> </repository> </distributionManagement> </project>
src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawlable.java +35 −0 Original line number Diff line number Diff line /* * 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 <https://www.gnu.org/licenses/>. */ 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(); }
src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsAppCrawler.java +38 −6 Original line number Diff line number Diff line /* * 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 <https://www.gnu.org/licenses/>. */ package com.inteligr8.maven.aps.modeling.crawler; import java.io.File; Loading @@ -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); Loading @@ -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 ..."); Loading Loading @@ -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); Loading
src/main/java/com/inteligr8/maven/aps/modeling/crawler/ApsFileTransformer.java +29 −0 Original line number Diff line number Diff line /* * 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 <https://www.gnu.org/licenses/>. */ 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; }
src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAddressibleGoal.java +33 −0 Original line number Diff line number Diff line /* * 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 <https://www.gnu.org/licenses/>. */ package com.inteligr8.maven.aps.modeling.goal; import org.apache.maven.execution.MavenSession; Loading @@ -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 ) Loading Loading @@ -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(); Loading Loading @@ -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(); Loading