public DeployCmd(DeploymentBuilderImpl deploymentBuilder) {
this.deploymentBuilder = deploymentBuilder;
}
public Deployment execute(CommandContext commandContext) {
DeploymentEntity deployment = deploymentBuilder.getDeployment();
if(deployment.getUpdateDeploymentId()!=null&&!deployment.getUpdateDeploymentId().equals("")){
DeploymentEntity deploymentOld=Context.getCommandContext().getDeploymentManager().findDeploymentById(deployment.getUpdateDeploymentId());
if(deploymentOld.getResources().keySet().size()!=2){
throw new FixFlowBizException("资源发布号,中不存在流程定义和流程图两个文件!");
}
ResourceEntity resourceEntityNewBpmn = null;
ResourceEntity resourceEntityNewPng = null;
for ( ResourceEntity resourceEntityNew : deployment.getResources().values()) {
if (resourceEntityNew.getName().toLowerCase().endsWith(BpmnDeployer.BPMN_RESOURCE_SUFFIX)) {
resourceEntityNewBpmn = resourceEntityNew;
} else {
if (resourceEntityNew.getName().toLowerCase().endsWith(BpmnDeployer.DIAGRAM_SUFFIXES)) {
resourceEntityNewPng = resourceEntityNew;
}
}
}
for ( ResourceEntity resourceEntityOld : deploymentOld.getResources().values()) {
if (resourceEntityOld.getName().toLowerCase().endsWith(BpmnDeployer.BPMN_RESOURCE_SUFFIX)) {
resourceEntityOld.setBytes(resourceEntityNewBpmn.getBytes());
} else {
if (resourceEntityOld.getName().toLowerCase().endsWith(BpmnDeployer.DIAGRAM_SUFFIXES)) {
resourceEntityOld.setBytes(resourceEntityNewPng.getBytes());
}
}
}
deploymentOld.setUpdateDeploymentId(deployment.getUpdateDeploymentId());
Context.getCommandContext().getDeploymentManager().updateDeployment(deploymentOld);
}else{