String runtimeName = contentUploader.getRuntimeName();
String hash = contentUploader.getHash();
Redeployer redeployer = new Redeployer(runtimeName, hash, getASConnection());
if (redeployer.deploymentExists()) {
Result result = redeployer.redeployOnServer();
if (result.isRolledBack()) {
return BundleHandoverResponse.failure(EXECUTION, result.getFailureDescription());
}
return BundleHandoverResponse.success();
}
Operation addDeploymentStep = new Operation("add", "deployment", filename);
List<Object> addDeploymentContentProperty = new ArrayList<Object>(1);
Map<String, Object> contentValues = new HashMap<String, Object>();
contentValues.put("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
addDeploymentContentProperty.add(contentValues);
addDeploymentStep.addAdditionalProperty("content", addDeploymentContentProperty);
addDeploymentStep.addAdditionalProperty("name", filename);
addDeploymentStep.addAdditionalProperty("runtime-name", runtimeName);
Operation deployStep = new Operation("deploy", addDeploymentStep.getAddress());
CompositeOperation compositeOperation = new CompositeOperation();
compositeOperation.addStep(addDeploymentStep);
compositeOperation.addStep(deployStep);
Result result = getASConnection().execute(compositeOperation, 300);
if (!result.isSuccess()) {
return BundleHandoverResponse.failure(EXECUTION, result.getFailureDescription());
} else {
return BundleHandoverResponse.success();
}
}