added dryRun for app upload/publish

This commit is contained in:
Brian Long 2023-11-15 20:00:58 -05:00
parent 98c01db50d
commit a65a6df1f8
2 changed files with 40 additions and 13 deletions

View File

@ -39,6 +39,9 @@ public class PublishAppGoal extends ApsAppAddressibleGoal {
@Parameter( property = "aps-model.publish.comment", required = true, defaultValue = "Automated by 'aps-model-maven-plugin'" )
protected String comment;
@Parameter( property = "aps-model.dryRun", required = true, defaultValue = "false" )
protected boolean dryRun;
@Override
public void executeEnabled() throws MojoExecutionException, MojoFailureException {
@ -56,7 +59,12 @@ public class PublishAppGoal extends ApsAppAddressibleGoal {
AppDefinitionPublishRepresentation appDefPublish = new AppDefinitionPublishRepresentation();
appDefPublish.setComment(this.comment);
api.getAppDefinitionsApi().publish(appId, appDefPublish);
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Publishing app: " + appId);
} else {
this.getLog().info("Publishing app: " + appId);
api.getAppDefinitionsApi().publish(appId, appDefPublish);
}
}
}

View File

@ -49,6 +49,9 @@ public class UploadAppGoal extends ApsAppAddressibleGoal {
@Parameter( property = "publish", required = true, defaultValue = "false" )
protected boolean publish = false;
@Parameter( property = "aps-model.dryRun", required = true, defaultValue = "false" )
protected boolean dryRun;
protected final int bufferSize = 128 * 1024;
@ -93,23 +96,39 @@ public class UploadAppGoal extends ApsAppAddressibleGoal {
if (appId == null) {
if (this.publish) {
this.getLog().info("Uploading & publishing new APS App: " + this.apsAppName);
AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(multipart);
if (Boolean.TRUE.equals(appDefUpdate.getError()))
throw new MojoExecutionException(appDefUpdate.getErrorDescription());
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Uploading & publishing new APS App: " + this.apsAppName);
} else {
this.getLog().info("Uploading & publishing new APS App: " + this.apsAppName);
AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(multipart);
if (Boolean.TRUE.equals(appDefUpdate.getError()))
throw new MojoExecutionException(appDefUpdate.getErrorDescription());
}
} else {
this.getLog().info("Uploading new APS App: " + this.apsAppName);
api.getAppDefinitionsJerseyApi().importApp(multipart, true);
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Uploading new APS App: " + this.apsAppName);
} else {
this.getLog().info("Uploading new APS App: " + this.apsAppName);
api.getAppDefinitionsJerseyApi().importApp(multipart, true);
}
}
} else {
if (this.publish) {
this.getLog().info("Uploading, versioning, & publishing APS App: " + this.apsAppName + " (" + appId + ")");
AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(appId, multipart);
if (Boolean.TRUE.equals(appDefUpdate.getError()))
throw new MojoExecutionException(appDefUpdate.getErrorDescription());
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Uploading, versioning, & publishing APS App: " + this.apsAppName + " (" + appId + ")");
} else {
this.getLog().info("Uploading, versioning, & publishing APS App: " + this.apsAppName + " (" + appId + ")");
AppDefinitionUpdateResultRepresentation appDefUpdate = api.getAppDefinitionsJerseyApi().publishApp(appId, multipart);
if (Boolean.TRUE.equals(appDefUpdate.getError()))
throw new MojoExecutionException(appDefUpdate.getErrorDescription());
}
} else {
this.getLog().info("Uploading & versioning APS App: " + this.apsAppName + " (" + appId + ")");
api.getAppDefinitionsJerseyApi().importApp(appId, multipart, true);
if (this.dryRun) {
this.getLog().info("[DRYRUN]: Uploading & versioning APS App: " + this.apsAppName + " (" + appId + ")");
} else {
this.getLog().info("Uploading & versioning APS App: " + this.apsAppName + " (" + appId + ")");
api.getAppDefinitionsJerseyApi().importApp(appId, multipart, true);
}
}
}
} catch (ParseException pe) {