Merge branch 'develop' into stable
This commit is contained in:
@@ -6,11 +6,11 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.inteligr8.alfresco</groupId>
|
<groupId>com.inteligr8.alfresco</groupId>
|
||||||
<artifactId>aps-model-maven-plugin-deploy-app</artifactId>
|
<artifactId>aps-model-maven-plugin-upload-app</artifactId>
|
||||||
<version>@pom.version@</version>
|
<version>@pom.version@</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Deploy App Plugin Tests</name>
|
<name>Upload App Plugin Tests</name>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
@@ -53,10 +53,10 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>deploy-app</id>
|
<id>upload-app</id>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>deploy-app</goal>
|
<goal>upload-app</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<zipDirectory>${project.build.directory}/aps-test</zipDirectory>
|
<zipDirectory>${project.build.directory}/aps-test</zipDirectory>
|
@@ -42,15 +42,15 @@ public abstract class ApsAppAccessibleGoal extends ApsAddressibleGoal {
|
|||||||
return apps;
|
return apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Long findAppId() throws MojoExecutionException {
|
protected Long findAppId(boolean failOnNotFound) throws MojoExecutionException {
|
||||||
return this.findAppIdByName(this.apsAppName);
|
return this.findAppIdByName(this.apsAppName, failOnNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Long findAppIdByName(String appName) throws MojoExecutionException {
|
protected Long findAppIdByName(String appName, boolean failOnNotFound) throws MojoExecutionException {
|
||||||
Map<String, Long> apps = this.findAppNameIds();
|
Map<String, Long> apps = this.findAppNameIds();
|
||||||
Long appId = apps.get(this.apsAppName);
|
Long appId = apps.get(this.apsAppName);
|
||||||
if (appId == null)
|
if (failOnNotFound && appId == null)
|
||||||
throw new MojoExecutionException("The APS App '' could not be found; valid apps: " + apps.keySet());
|
throw new MojoExecutionException("The APS App '" + this.apsAppName + "' could not be found; valid apps: " + apps.keySet());
|
||||||
return appId;
|
return appId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,6 +28,9 @@ import com.inteligr8.maven.aps.modeling.util.Index;
|
|||||||
@Component( role = org.apache.maven.plugin.Mojo.class )
|
@Component( role = org.apache.maven.plugin.Mojo.class )
|
||||||
public class ApsShareGoal extends ApsAddressibleGoal {
|
public class ApsShareGoal extends ApsAddressibleGoal {
|
||||||
|
|
||||||
|
@Parameter( property = "aps-model.share.modelName" )
|
||||||
|
protected String modelName;
|
||||||
|
|
||||||
@Parameter( property = "aps-model.share.readers" )
|
@Parameter( property = "aps-model.share.readers" )
|
||||||
protected String readers;
|
protected String readers;
|
||||||
|
|
||||||
@@ -66,7 +69,6 @@ public class ApsShareGoal extends ApsAddressibleGoal {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
|
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
|
||||||
this.getLog().info("editors: " + this.editors);
|
|
||||||
this.normalizeParameters();
|
this.normalizeParameters();
|
||||||
this.buildIdentityIndex();
|
this.buildIdentityIndex();
|
||||||
|
|
||||||
@@ -82,9 +84,14 @@ public class ApsShareGoal extends ApsAddressibleGoal {
|
|||||||
|
|
||||||
private void shareModels(ModelsApi.ModelType modelType, Set<String> readers, Set<String> editors) {
|
private void shareModels(ModelsApi.ModelType modelType, Set<String> readers, Set<String> editors) {
|
||||||
ResultListDataRepresentation models = this.getApsApi().getModelsApi().get(null, null, modelType.getId(), null);
|
ResultListDataRepresentation models = this.getApsApi().getModelsApi().get(null, null, modelType.getId(), null);
|
||||||
|
if (models.getData() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
for (Datum datum : models.getData()) {
|
for (Datum datum : models.getData()) {
|
||||||
Number modelId = (Number)datum.getAdditionalProperties().get("id");
|
Number modelId = (Number)datum.getAdditionalProperties().get("id");
|
||||||
String modelName = (String)datum.getAdditionalProperties().get("name");
|
String modelName = (String)datum.getAdditionalProperties().get("name");
|
||||||
|
if (this.modelName != null && !this.modelName.equals(modelName))
|
||||||
|
continue;
|
||||||
|
|
||||||
Set<String> groupsAddressed = new HashSet<>();
|
Set<String> groupsAddressed = new HashSet<>();
|
||||||
Set<String> readersUnaddressed = new HashSet<>(readers);
|
Set<String> readersUnaddressed = new HashSet<>(readers);
|
||||||
@@ -92,65 +99,24 @@ public class ApsShareGoal extends ApsAddressibleGoal {
|
|||||||
ShareInfoRequest changeRequest = new ShareInfoRequest();
|
ShareInfoRequest changeRequest = new ShareInfoRequest();
|
||||||
|
|
||||||
ResultList<SharePermission> shares = this.getApsApi().getShareApi().getShareInfo(modelId.toString());
|
ResultList<SharePermission> shares = this.getApsApi().getShareApi().getShareInfo(modelId.toString());
|
||||||
for (SharePermission share : shares.getData()) {
|
if (shares.getData() != null) {
|
||||||
if (share.getGroup() != null) {
|
for (SharePermission share : shares.getData()) {
|
||||||
groupsAddressed.add(share.getGroup().getName());
|
if (share.getGroup() != null) {
|
||||||
|
groupsAddressed.add(share.getGroup().getName());
|
||||||
if (PermissionLevel.Write.equals(share.getPermission())) {
|
this.analyzeChanges(modelName, readers, editors, share, changeRequest);
|
||||||
if (editors.contains(share.getGroup().getName())) {
|
} else if (share.getPerson() != null) {
|
||||||
this.getLog().debug("The named group '" + share.getGroup().getName() + "' is already an editor of model '" + modelName + "'");
|
this.getLog().debug("Person-based model sharing not supported at this time; ignoring");
|
||||||
// no change
|
|
||||||
continue;
|
|
||||||
} else if (readers.contains(share.getGroup().getName())) {
|
|
||||||
this.getLog().debug("The named group '" + share.getGroup().getName() + "' reverting from editor to reader of model '" + modelName + "'");
|
|
||||||
changeRequest.getUpdated().add(new PermissionLight().withId(share.getId()).withPermission(PermissionLevel.Read));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (editors.contains(share.getGroup().getName())) {
|
|
||||||
this.getLog().debug("The named group '" + share.getGroup().getName() + "' elevating from reader to editor of model '" + modelName + "'");
|
|
||||||
changeRequest.getUpdated().add(new PermissionLight().withId(share.getId()).withPermission(PermissionLevel.Write));
|
|
||||||
continue;
|
|
||||||
} else if (readers.contains(share.getGroup().getName())) {
|
|
||||||
this.getLog().debug("The named group '" + share.getGroup().getName() + "' is already an reader of model '" + modelName + "'");
|
|
||||||
// no change
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.doRevoke) {
|
|
||||||
this.getLog().debug("The named group '" + share.getGroup().getName() + "' is an unregulated editor of model '" + modelName + "'; revoking ...");
|
|
||||||
changeRequest.getRemoved().add(new PermissionLight().withId(share.getId()));
|
|
||||||
} else {
|
|
||||||
this.getLog().debug("The named group '" + share.getGroup().getName() + "' is an unregulated editor of model '" + modelName + "'");
|
|
||||||
// not touching extra unnamed permissions
|
|
||||||
}
|
|
||||||
} else if (share.getPerson() != null) {
|
|
||||||
this.getLog().debug("Person-based model sharing not supported at this time; ignoring");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readersUnaddressed.removeAll(groupsAddressed);
|
readersUnaddressed.removeAll(groupsAddressed);
|
||||||
for (String reader : readersUnaddressed) {
|
for (String reader : readersUnaddressed)
|
||||||
Long groupId = this.identityIndex.getValue(reader);
|
this.analyzeChanges(modelName, reader, PermissionLevel.Read, changeRequest);
|
||||||
if (groupId == null) {
|
|
||||||
this.getLog().warn("The named group '" + reader + "' does not exist in APS; ignoring ...");
|
|
||||||
} else {
|
|
||||||
this.getLog().debug("The named group '" + reader + "' becoming a reader of model '" + modelName + "'");
|
|
||||||
changeRequest.getAdded().add(new PermissionLight().withGroupId(groupId).withPermission(PermissionLevel.Read));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
editorsUnaddressed.removeAll(groupsAddressed);
|
editorsUnaddressed.removeAll(groupsAddressed);
|
||||||
for (String editor : editorsUnaddressed) {
|
for (String editor : editorsUnaddressed)
|
||||||
Long groupId = this.identityIndex.getValue(editor);
|
this.analyzeChanges(modelName, editor, PermissionLevel.Write, changeRequest);
|
||||||
if (groupId == null) {
|
|
||||||
this.getLog().warn("The named group '" + editor + "' does not exist in APS; ignoring ...");
|
|
||||||
} else {
|
|
||||||
this.getLog().debug("The named group '" + editor + "' becoming an editor of model '" + modelName + "'");
|
|
||||||
changeRequest.getAdded().add(new PermissionLight().withGroupId(groupId).withPermission(PermissionLevel.Write));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!changeRequest.getAdded().isEmpty() || !changeRequest.getUpdated().isEmpty() || !changeRequest.getRemoved().isEmpty()) {
|
if (!changeRequest.getAdded().isEmpty() || !changeRequest.getUpdated().isEmpty() || !changeRequest.getRemoved().isEmpty()) {
|
||||||
this.getLog().info("Sharing model: " + modelType + " => '" + modelName + "'");
|
this.getLog().info("Sharing model: " + modelType + " => '" + modelName + "'");
|
||||||
@@ -159,6 +125,48 @@ public class ApsShareGoal extends ApsAddressibleGoal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void analyzeChanges(String modelName, Set<String> readers, Set<String> editors, SharePermission share, ShareInfoRequest changeRequest) {
|
||||||
|
if (PermissionLevel.Write.equals(share.getPermission())) {
|
||||||
|
if (editors.contains(share.getGroup().getName())) {
|
||||||
|
this.getLog().debug("The named group '" + share.getGroup().getName() + "' is already an editor of model '" + modelName + "'");
|
||||||
|
// no change
|
||||||
|
return;
|
||||||
|
} else if (readers.contains(share.getGroup().getName())) {
|
||||||
|
this.getLog().debug("The named group '" + share.getGroup().getName() + "' reverting from editor to reader of model '" + modelName + "'");
|
||||||
|
changeRequest.getUpdated().add(new PermissionLight().withId(share.getId()).withPermission(PermissionLevel.Read));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (editors.contains(share.getGroup().getName())) {
|
||||||
|
this.getLog().debug("The named group '" + share.getGroup().getName() + "' elevating from reader to editor of model '" + modelName + "'");
|
||||||
|
changeRequest.getUpdated().add(new PermissionLight().withId(share.getId()).withPermission(PermissionLevel.Write));
|
||||||
|
return;
|
||||||
|
} else if (readers.contains(share.getGroup().getName())) {
|
||||||
|
this.getLog().debug("The named group '" + share.getGroup().getName() + "' is already an reader of model '" + modelName + "'");
|
||||||
|
// no change
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.doRevoke) {
|
||||||
|
this.getLog().debug("The named group '" + share.getGroup().getName() + "' is an unregulated editor of model '" + modelName + "'; revoking ...");
|
||||||
|
changeRequest.getRemoved().add(new PermissionLight().withId(share.getId()));
|
||||||
|
} else {
|
||||||
|
this.getLog().debug("The named group '" + share.getGroup().getName() + "' is an unregulated editor of model '" + modelName + "'");
|
||||||
|
// not touching extra unnamed permissions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void analyzeChanges(String modelName, String groupName, PermissionLevel plevel, ShareInfoRequest changeRequest) {
|
||||||
|
Long groupId = this.identityIndex.getValue(groupName);
|
||||||
|
if (groupId == null) {
|
||||||
|
this.getLog().warn("The named group '" + groupName + "' does not exist in APS; ignoring ...");
|
||||||
|
} else {
|
||||||
|
this.getLog().debug("The named group '" + groupName + "' granted the " + plevel + " role of model '" + modelName + "'");
|
||||||
|
changeRequest.getAdded().add(new PermissionLight().withGroupId(groupId).withPermission(plevel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void normalizeParameters() {
|
protected void normalizeParameters() {
|
||||||
Set<String> readerSet = this.normalizeParameter(this.readers);
|
Set<String> readerSet = this.normalizeParameter(this.readers);
|
||||||
Set<String> editorSet = this.normalizeParameter(this.editors);
|
Set<String> editorSet = this.normalizeParameter(this.editors);
|
||||||
|
@@ -23,7 +23,7 @@ public class DownloadAppGoal extends ApsAppAccessibleGoal {
|
|||||||
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
|
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
|
||||||
this.validateTargetDirectory();
|
this.validateTargetDirectory();
|
||||||
|
|
||||||
Long appId = this.findAppId();
|
Long appId = this.findAppId(true);
|
||||||
File appZip = this.downloadApp(appId);
|
File appZip = this.downloadApp(appId);
|
||||||
|
|
||||||
File toAppZip = new File(this.zipDirectory, this.apsAppName + ".zip");
|
File toAppZip = new File(this.zipDirectory, this.apsAppName + ".zip");
|
||||||
|
@@ -0,0 +1,40 @@
|
|||||||
|
package com.inteligr8.maven.aps.modeling.goal;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
|
||||||
|
import com.inteligr8.alfresco.activiti.model.AppDefinitionPublishRepresentation;
|
||||||
|
|
||||||
|
@Mojo( name = "publish-app", threadSafe = true )
|
||||||
|
@Component( role = org.apache.maven.plugin.Mojo.class )
|
||||||
|
public class PublishAppGoal extends ApsAppAccessibleGoal {
|
||||||
|
|
||||||
|
@Parameter( property = "aps-model.publish.comment", required = true, defaultValue = "Automated by 'aps-model-maven-plugin'" )
|
||||||
|
protected String comment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
|
||||||
|
Long appId = this.findAppId(false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.publishApp(appId);
|
||||||
|
} catch (IOException ie) {
|
||||||
|
throw new MojoExecutionException("The APS App could not be published", ie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void publishApp(Long appId) throws IOException, MojoExecutionException {
|
||||||
|
ApsPublicRestApiJerseyImpl api = this.getApsApi();
|
||||||
|
|
||||||
|
AppDefinitionPublishRepresentation appDefPublish = new AppDefinitionPublishRepresentation();
|
||||||
|
appDefPublish.setComment(this.comment);
|
||||||
|
api.getAppDefinitionsApi().publish(appId, appDefPublish);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -16,9 +16,9 @@ import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
|
|||||||
import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation;
|
import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation;
|
||||||
import com.inteligr8.alfresco.activiti.model.FileMultipartJersey;
|
import com.inteligr8.alfresco.activiti.model.FileMultipartJersey;
|
||||||
|
|
||||||
@Mojo( name = "deploy-app", threadSafe = true )
|
@Mojo( name = "upload-app", threadSafe = true )
|
||||||
@Component( role = org.apache.maven.plugin.Mojo.class )
|
@Component( role = org.apache.maven.plugin.Mojo.class )
|
||||||
public class DeployAppGoal extends ApsAppAccessibleGoal {
|
public class UploadAppGoal extends ApsAppAccessibleGoal {
|
||||||
|
|
||||||
@Parameter( property = "aps-model.upload.directory", required = true, defaultValue = "${project.build.directory}/aps" )
|
@Parameter( property = "aps-model.upload.directory", required = true, defaultValue = "${project.build.directory}/aps" )
|
||||||
protected File zipDirectory;
|
protected File zipDirectory;
|
||||||
@@ -32,7 +32,7 @@ public class DeployAppGoal extends ApsAppAccessibleGoal {
|
|||||||
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
|
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
|
||||||
File sourceFile = this.validateSourceDirectory();
|
File sourceFile = this.validateSourceDirectory();
|
||||||
|
|
||||||
Long appId = this.findAppId();
|
Long appId = this.findAppId(false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.uploadApp(appId, sourceFile);
|
this.uploadApp(appId, sourceFile);
|
Reference in New Issue
Block a user