public JaxbDeploymentJobResult submitDeployJob(String deploymentId, String strategy, String mergeMode, JaxbDeploymentDescriptor deployDescriptor ) {
JaxbDeploymentJobResult jobResult;
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if( deployedUnit != null ) {
// If the deployment unit already exists, request can not be completed..
KModuleDeploymentUnit kDepUnit = (KModuleDeploymentUnit) deployedUnit.getDeploymentUnit();
JaxbDeploymentUnit jaxbDepUnit = convertKModuleDepUnitToJaxbDepUnit(kDepUnit);
jobResult = new JaxbDeploymentJobResult(
null,
"The deployment already exists and must be first undeployed!",
jaxbDepUnit,
JobType.DEPLOY.toString());
jobResult.setSuccess(false);
} else {
KModuleDeploymentUnit deploymentUnit = createDeploymentUnit(deploymentId, deployDescriptor);
if( strategy != null ) {
strategy = strategy.toUpperCase();
RuntimeStrategy runtimeStrategy;
try {
runtimeStrategy = RuntimeStrategy.valueOf(strategy);
} catch( IllegalArgumentException iae ) {
throw KieRemoteRestOperationException.badRequest("Runtime strategy '" + strategy + "' does not exist.");
}
deploymentUnit.setStrategy(runtimeStrategy);
}
if (mergeMode != null) {
mergeMode = mergeMode.toUpperCase();
MergeMode mode;
try {
mode = MergeMode.valueOf(mergeMode);
} catch( IllegalArgumentException iae ) {
throw KieRemoteRestOperationException.badRequest("Merge mode '" + mergeMode + "' does not exist.");
}
deploymentUnit.setMergeMode(mode);
}
jobResult = scheduleDeploymentJobRequest(deploymentId, JobType.DEPLOY, deploymentUnit);
}
return jobResult;