throw new IllegalArgumentException("archive must not be null");
}
final String archiveName = archive.getName();
final ProtocolMetaData protocolMetaData = new ProtocolMetaData();
try {
InputStream deployment = archive.as(ZipExporter.class).exportAsInputStream();
// Build up the POST form to send to Glassfish
final FormDataMultiPart form = new FormDataMultiPart();
form.bodyPart(new StreamDataBodyPart("id", deployment, archiveName));
deploymentName = createDeploymentName(archiveName);
addDeployFormFields(deploymentName, form);
// Do Deploy the application on the remote GlassFish
HTTPContext httpContext = glassFishClient.doDeploy(deploymentName, form);
protocolMetaData.addContext(httpContext);
} catch (GlassFishClientException e) {
throw new DeploymentException("Could not deploy " + archiveName, e);
}
return protocolMetaData;
}