Loading pom.xml +1 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ <dependency> <groupId>com.inteligr8.alfresco</groupId> <artifactId>aps-public-rest-api</artifactId> <version>2.0.15</version> <version>2.0.16</version> </dependency> <dependency> <groupId>com.inteligr8.alfresco</groupId> Loading src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAppAddressibleGoal.java +19 −18 Original line number Diff line number Diff line Loading @@ -22,8 +22,10 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; import com.inteligr8.activiti.model.Datum; import com.inteligr8.activiti.model.ResultList; import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl; import com.inteligr8.alfresco.activiti.api.ModelsApi.ModelType; import com.inteligr8.alfresco.activiti.model.ModelRepresentation; import com.inteligr8.alfresco.activiti.model.ResultListDataRepresentation; import com.inteligr8.alfresco.activiti.model.Tenant; Loading Loading @@ -58,24 +60,23 @@ public abstract class ApsAppAddressibleGoal extends ApsAddressibleGoal { /** * This method makes the appropriate service calls to find all the APS * Apps, returning them as a map of names to IDs. * Apps, returning them as a map of names to models. * * This method does not cache the result. * * @return A map of APS App names to their respective IDs; may be empty; never null. * @return A map of APS App names to their model; may be empty; never null. */ protected Map<String, Long> findAppNameIds() { protected Map<String, ModelRepresentation> buildAppNameMap() { ApsPublicRestApiJerseyImpl api = this.getApsApi(); Map<String, Long> apps = new HashMap<>(16); Map<String, ModelRepresentation> apps = new HashMap<>(16); this.getLog().debug("Searching for all APS Apps"); ResultListDataRepresentation<Datum> results = api.getModelsApi().get("everyone", null, ModelType.App.getId(), null); ResultList<ModelRepresentation> results = api.getModelsApi().get("everyone", null, ModelType.App.getId(), null); this.getLog().debug("Found " + results.getTotal() + " APS Apps"); for (Datum datum : results.getData()) { String name = (String)datum.getAdditionalProperties().get("name"); Number id = (Number)datum.getAdditionalProperties().get("id"); apps.put(name, id.longValue()); for (ModelRepresentation model : results.getData()) { String name = model.getName(); apps.put(name, model); } return apps; Loading @@ -88,11 +89,11 @@ public abstract class ApsAppAddressibleGoal extends ApsAddressibleGoal { * 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. * @return An APS App model; 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); protected ModelRepresentation findAppModel(boolean failOnNotFound) throws MojoExecutionException { return this.findAppModelByName(this.apsAppName, failOnNotFound); } /** Loading @@ -103,15 +104,15 @@ public abstract class ApsAppAddressibleGoal extends ApsAddressibleGoal { * * @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. * @return An APS App model; null if not found. * @throws MojoExecutionException The APS App could not be found. */ protected Long findAppIdByName(String appName, boolean failOnNotFound) throws MojoExecutionException { Map<String, Long> apps = this.findAppNameIds(); Long appId = apps.get(this.apsAppName); if (failOnNotFound && appId == null) protected ModelRepresentation findAppModelByName(String appName, boolean failOnNotFound) throws MojoExecutionException { Map<String, ModelRepresentation> apps = this.buildAppNameMap(); ModelRepresentation appModel = apps.get(this.apsAppName); if (failOnNotFound && appModel == null) throw new MojoExecutionException("The APS App '" + this.apsAppName + "' could not be found; valid apps: " + apps.keySet()); return appId; return appModel; } } src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsShareGoal.java +6 −7 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.inteligr8.activiti.model.Datum; import com.inteligr8.activiti.model.ResultList; import com.inteligr8.alfresco.activiti.api.ModelsApi; import com.inteligr8.alfresco.activiti.model.GroupLight; import com.inteligr8.alfresco.activiti.model.ModelRepresentation; import com.inteligr8.alfresco.activiti.model.PermissionLevel; import com.inteligr8.alfresco.activiti.model.PermissionLight; import com.inteligr8.alfresco.activiti.model.ResultListDataRepresentation; Loading Loading @@ -108,14 +109,12 @@ public class ApsShareGoal extends ApsAddressibleGoal { } private void shareModels(ModelsApi.ModelType modelType, Set<String> readers, Set<String> editors) { ResultListDataRepresentation<Datum> models = this.getApsApi().getModelsApi().get(null, null, modelType.getId(), null); ResultList<ModelRepresentation> models = this.getApsApi().getModelsApi().get(null, null, modelType.getId(), null); if (models.getData() == null) return; for (Datum datum : models.getData()) { Number modelId = (Number)datum.getAdditionalProperties().get("id"); String modelName = (String)datum.getAdditionalProperties().get("name"); if (this.modelName != null && !this.modelName.equals(modelName)) for (ModelRepresentation model : models.getData()) { if (this.modelName != null && !this.modelName.equals(model.getName())) continue; Set<String> groupsAddressed = new HashSet<>(); Loading @@ -123,7 +122,7 @@ public class ApsShareGoal extends ApsAddressibleGoal { Set<String> editorsUnaddressed = new HashSet<>(editors); ShareInfoRequest changeRequest = new ShareInfoRequest(); ResultList<SharePermission> shares = this.getApsApi().getShareApi().getShareInfo(modelId.toString()); ResultList<SharePermission> shares = this.getApsApi().getShareApi().getShareInfo(model.getId().toString()); if (shares.getData() != null) { for (SharePermission share : shares.getData()) { if (share.getGroup() != null) { Loading @@ -145,7 +144,7 @@ public class ApsShareGoal extends ApsAddressibleGoal { if (!changeRequest.getAdded().isEmpty() || !changeRequest.getUpdated().isEmpty() || !changeRequest.getRemoved().isEmpty()) { this.getLog().info("Sharing model: " + modelType + " => '" + modelName + "'"); this.getApsApi().getShareApi().setShareInfo(modelId.toString(), changeRequest); this.getApsApi().getShareApi().setShareInfo(model.getId().toString(), changeRequest); } } } Loading src/main/java/com/inteligr8/maven/aps/modeling/goal/DownloadAppGoal.java +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class DownloadAppGoal extends ApsAppAddressibleGoal { public void executeEnabled() throws MojoExecutionException, MojoFailureException { this.validateTargetDirectory(); Long appId = this.findAppId(true); Long appId = this.findAppModel(true).getId(); File appZip = this.downloadApp(appId); File toAppZip = new File(this.zipDirectory, this.apsAppName + ".zip"); Loading src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ public class PublishAppGoal extends ApsAppAddressibleGoal { @Override public void executeEnabled() throws MojoExecutionException, MojoFailureException { Long appId = this.findAppId(false); Long appId = this.findAppModel(false).getId(); try { this.publishApp(appId); Loading Loading
pom.xml +1 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ <dependency> <groupId>com.inteligr8.alfresco</groupId> <artifactId>aps-public-rest-api</artifactId> <version>2.0.15</version> <version>2.0.16</version> </dependency> <dependency> <groupId>com.inteligr8.alfresco</groupId> Loading
src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsAppAddressibleGoal.java +19 −18 Original line number Diff line number Diff line Loading @@ -22,8 +22,10 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; import com.inteligr8.activiti.model.Datum; import com.inteligr8.activiti.model.ResultList; import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl; import com.inteligr8.alfresco.activiti.api.ModelsApi.ModelType; import com.inteligr8.alfresco.activiti.model.ModelRepresentation; import com.inteligr8.alfresco.activiti.model.ResultListDataRepresentation; import com.inteligr8.alfresco.activiti.model.Tenant; Loading Loading @@ -58,24 +60,23 @@ public abstract class ApsAppAddressibleGoal extends ApsAddressibleGoal { /** * This method makes the appropriate service calls to find all the APS * Apps, returning them as a map of names to IDs. * Apps, returning them as a map of names to models. * * This method does not cache the result. * * @return A map of APS App names to their respective IDs; may be empty; never null. * @return A map of APS App names to their model; may be empty; never null. */ protected Map<String, Long> findAppNameIds() { protected Map<String, ModelRepresentation> buildAppNameMap() { ApsPublicRestApiJerseyImpl api = this.getApsApi(); Map<String, Long> apps = new HashMap<>(16); Map<String, ModelRepresentation> apps = new HashMap<>(16); this.getLog().debug("Searching for all APS Apps"); ResultListDataRepresentation<Datum> results = api.getModelsApi().get("everyone", null, ModelType.App.getId(), null); ResultList<ModelRepresentation> results = api.getModelsApi().get("everyone", null, ModelType.App.getId(), null); this.getLog().debug("Found " + results.getTotal() + " APS Apps"); for (Datum datum : results.getData()) { String name = (String)datum.getAdditionalProperties().get("name"); Number id = (Number)datum.getAdditionalProperties().get("id"); apps.put(name, id.longValue()); for (ModelRepresentation model : results.getData()) { String name = model.getName(); apps.put(name, model); } return apps; Loading @@ -88,11 +89,11 @@ public abstract class ApsAppAddressibleGoal extends ApsAddressibleGoal { * 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. * @return An APS App model; 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); protected ModelRepresentation findAppModel(boolean failOnNotFound) throws MojoExecutionException { return this.findAppModelByName(this.apsAppName, failOnNotFound); } /** Loading @@ -103,15 +104,15 @@ public abstract class ApsAppAddressibleGoal extends ApsAddressibleGoal { * * @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. * @return An APS App model; null if not found. * @throws MojoExecutionException The APS App could not be found. */ protected Long findAppIdByName(String appName, boolean failOnNotFound) throws MojoExecutionException { Map<String, Long> apps = this.findAppNameIds(); Long appId = apps.get(this.apsAppName); if (failOnNotFound && appId == null) protected ModelRepresentation findAppModelByName(String appName, boolean failOnNotFound) throws MojoExecutionException { Map<String, ModelRepresentation> apps = this.buildAppNameMap(); ModelRepresentation appModel = apps.get(this.apsAppName); if (failOnNotFound && appModel == null) throw new MojoExecutionException("The APS App '" + this.apsAppName + "' could not be found; valid apps: " + apps.keySet()); return appId; return appModel; } }
src/main/java/com/inteligr8/maven/aps/modeling/goal/ApsShareGoal.java +6 −7 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.inteligr8.activiti.model.Datum; import com.inteligr8.activiti.model.ResultList; import com.inteligr8.alfresco.activiti.api.ModelsApi; import com.inteligr8.alfresco.activiti.model.GroupLight; import com.inteligr8.alfresco.activiti.model.ModelRepresentation; import com.inteligr8.alfresco.activiti.model.PermissionLevel; import com.inteligr8.alfresco.activiti.model.PermissionLight; import com.inteligr8.alfresco.activiti.model.ResultListDataRepresentation; Loading Loading @@ -108,14 +109,12 @@ public class ApsShareGoal extends ApsAddressibleGoal { } private void shareModels(ModelsApi.ModelType modelType, Set<String> readers, Set<String> editors) { ResultListDataRepresentation<Datum> models = this.getApsApi().getModelsApi().get(null, null, modelType.getId(), null); ResultList<ModelRepresentation> models = this.getApsApi().getModelsApi().get(null, null, modelType.getId(), null); if (models.getData() == null) return; for (Datum datum : models.getData()) { Number modelId = (Number)datum.getAdditionalProperties().get("id"); String modelName = (String)datum.getAdditionalProperties().get("name"); if (this.modelName != null && !this.modelName.equals(modelName)) for (ModelRepresentation model : models.getData()) { if (this.modelName != null && !this.modelName.equals(model.getName())) continue; Set<String> groupsAddressed = new HashSet<>(); Loading @@ -123,7 +122,7 @@ public class ApsShareGoal extends ApsAddressibleGoal { Set<String> editorsUnaddressed = new HashSet<>(editors); ShareInfoRequest changeRequest = new ShareInfoRequest(); ResultList<SharePermission> shares = this.getApsApi().getShareApi().getShareInfo(modelId.toString()); ResultList<SharePermission> shares = this.getApsApi().getShareApi().getShareInfo(model.getId().toString()); if (shares.getData() != null) { for (SharePermission share : shares.getData()) { if (share.getGroup() != null) { Loading @@ -145,7 +144,7 @@ public class ApsShareGoal extends ApsAddressibleGoal { if (!changeRequest.getAdded().isEmpty() || !changeRequest.getUpdated().isEmpty() || !changeRequest.getRemoved().isEmpty()) { this.getLog().info("Sharing model: " + modelType + " => '" + modelName + "'"); this.getApsApi().getShareApi().setShareInfo(modelId.toString(), changeRequest); this.getApsApi().getShareApi().setShareInfo(model.getId().toString(), changeRequest); } } } Loading
src/main/java/com/inteligr8/maven/aps/modeling/goal/DownloadAppGoal.java +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class DownloadAppGoal extends ApsAppAddressibleGoal { public void executeEnabled() throws MojoExecutionException, MojoFailureException { this.validateTargetDirectory(); Long appId = this.findAppId(true); Long appId = this.findAppModel(true).getId(); File appZip = this.downloadApp(appId); File toAppZip = new File(this.zipDirectory, this.apsAppName + ".zip"); Loading
src/main/java/com/inteligr8/maven/aps/modeling/goal/PublishAppGoal.java +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ public class PublishAppGoal extends ApsAppAddressibleGoal { @Override public void executeEnabled() throws MojoExecutionException, MojoFailureException { Long appId = this.findAppId(false); Long appId = this.findAppModel(false).getId(); try { this.publishApp(appId); Loading