Commit a65a6df1 authored by Brian Long's avatar Brian Long
Browse files

added dryRun for app upload/publish

parent 98c01db5
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -40,6 +40,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 {
		Long appId = this.findAppId(false);
@@ -56,7 +59,12 @@ public class PublishAppGoal extends ApsAppAddressibleGoal {
		
		AppDefinitionPublishRepresentation appDefPublish = new AppDefinitionPublishRepresentation();
		appDefPublish.setComment(this.comment);
		if (this.dryRun) {
			this.getLog().info("[DRYRUN]: Publishing app: " + appId);
		} else {
			this.getLog().info("Publishing app: " + appId);
			api.getAppDefinitionsApi().publish(appId, appDefPublish);
		}
	}

}
+31 −12
Original line number Diff line number Diff line
@@ -50,6 +50,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;
	
	@Override
@@ -93,25 +96,41 @@ public class UploadAppGoal extends ApsAppAddressibleGoal {
			
			if (appId == null) {
				if (this.publish) {
					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 {
					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) {
					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 {
					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) {
			throw new MojoExecutionException("The app ZIP could not be wrapped in a multipart", pe);
		} finally {