public static final String JOB_TYPE = "JobType";
public static final String JOB_ID = "JobId";
@Override
public ExecutionResults execute(CommandContext ctx) throws Exception {
DeploymentService deploymentService = getDeploymentService(ctx);
KModuleDeploymentUnit deploymentUnit = (KModuleDeploymentUnit) ctx.getData(DEPLOYMENT_UNIT);
JobType jobType = (JobType) ctx.getData(JOB_TYPE);
String deploymentId = deploymentUnit.getIdentifier();
JobResultManager jobResultMgr = getJobManager(ctx);
String jobId = (String) ctx.getData(JOB_ID);
JaxbDeploymentJobResult jobResult = jobResultMgr.getJob(jobId);
boolean success = false;
switch (jobType) {
case DEPLOY:
try {
jobResult.getDeploymentUnit().setStatus(JaxbDeploymentStatus.DEPLOYING);
deploymentService.deploy(deploymentUnit);
jobResult.getDeploymentUnit().setStatus(JaxbDeploymentStatus.DEPLOYED);
jobResult.setSuccess(true);
logger.debug("Deployment unit [{}] deployed", deploymentId);
success = true;
} catch (Exception e) {
jobResult.getDeploymentUnit().setStatus(JaxbDeploymentStatus.DEPLOY_FAILED);
jobResult.setSuccess(false);
logger.error("Unable to deploy [{}]", deploymentId, e);
}
break;
case UNDEPLOY:
try {
jobResult.getDeploymentUnit().setStatus(JaxbDeploymentStatus.UNDEPLOYING);
deploymentService.undeploy(deploymentUnit);
jobResult.getDeploymentUnit().setStatus(JaxbDeploymentStatus.UNDEPLOYED);
logger.debug("Deployment unit [{}] undeployed", deploymentId);
jobResult.setSuccess(false);
success = true;
} catch (Exception e) {