diff --git a/pom.xml b/pom.xml index 01cf2e7..d1f5600 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ com.inteligr8.alfresco aps-public-rest-api - 1.2.1 + 1.2.3 aps1 diff --git a/src/main/java/com/inteligr8/maven/aps/modeling/goal/DeployAppGoal.java b/src/main/java/com/inteligr8/maven/aps/modeling/goal/DeployAppGoal.java index 2f8540e..9f47975 100644 --- a/src/main/java/com/inteligr8/maven/aps/modeling/goal/DeployAppGoal.java +++ b/src/main/java/com/inteligr8/maven/aps/modeling/goal/DeployAppGoal.java @@ -4,19 +4,17 @@ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; - -import javax.ws.rs.core.MediaType; +import java.text.ParseException; 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 org.glassfish.jersey.media.multipart.FormDataMultiPart; -import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart; import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl; import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation; +import com.inteligr8.alfresco.activiti.model.FileMultipartJersey; @Mojo( name = "deploy-app", threadSafe = true ) @Component( role = org.apache.maven.plugin.Mojo.class ) @@ -29,7 +27,6 @@ public class DeployAppGoal extends ApsAppAccessibleGoal { protected boolean publish = false; protected final int bufferSize = 128 * 1024; - private final MediaType zipMediaType = MediaType.valueOf("application/zip"); @Override public void executeEnabled() throws MojoExecutionException, MojoFailureException { @@ -68,8 +65,7 @@ public class DeployAppGoal extends ApsAppAccessibleGoal { FileInputStream fistream = new FileInputStream(appZip); BufferedInputStream bistream = new BufferedInputStream(fistream, this.bufferSize); try { - FormDataMultiPart multipart = new FormDataMultiPart(); - multipart.bodyPart(new StreamDataBodyPart("file", bistream, appZip.getName(), this.zipMediaType)); + FileMultipartJersey multipart = FileMultipartJersey.from(appZip.getName(), bistream); if (appId == null) { if (this.publish) { @@ -92,6 +88,8 @@ public class DeployAppGoal extends ApsAppAccessibleGoal { api.getAppDefinitionsJerseyApi().importApp(appId, multipart, true); } } + } catch (ParseException pe) { + throw new MojoExecutionException("The app ZIP could not be wrapped in a multipart", pe); } finally { bistream.close(); }