use of org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity in project sling by apache.
the class SlingPostDeployMethod method undeploy.
@Override
public void undeploy(String targetURL, File file, String bundleSymbolicName, DeployContext context) throws MojoExecutionException {
final PostMethod post = new PostMethod(getURLWithFilename(targetURL, file.getName()));
try {
// Add SlingPostServlet operation flag for deleting the content
Part[] parts = new Part[1];
parts[0] = new StringPart(":operation", "delete");
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
// Request JSON response from Sling instead of standard HTML
post.setRequestHeader("Accept", JSON_MIME_TYPE);
int status = context.getHttpClient().executeMethod(post);
if (status == HttpStatus.SC_OK) {
context.getLog().info("Bundle uninstalled");
} else {
context.getLog().error("Uninstall failed, cause: " + HttpStatus.getStatusText(status));
}
} catch (Exception ex) {
throw new MojoExecutionException("Uninstall from " + targetURL + " failed, cause: " + ex.getMessage(), ex);
} finally {
post.releaseConnection();
}
}
Aggregations