log.info("Starting deployment of processes from directory "
+ bpelPackage.getAbsolutePath());
final Date deployDate = new Date();
// Create the DU and compile/scan it before doing any other work.
final DeploymentUnitDir du = new DeploymentUnitDir(bpelPackage);
// Before coming to this stage, we create the bpel package directory with the static version
// so we don't need to get the version from database. We can directly use static version
// calculated from bpel package directory name.
du.setVersion(du.getStaticVersion());
try {
du.compile();
} catch (CompilationException ce) {
String logMessage = "Deployment failed due to compilation issues.";
log.error(logMessage, ce);
throw new BPELDeploymentException(logMessage, ce);
}
du.scan();
DeployDocument dd = du.getDeploymentDescriptor();
List<ProcessConfigurationImpl> processConfs = new ArrayList<ProcessConfigurationImpl>();
List<QName> processIds = new ArrayList<QName>();
if (deploymentUnits.containsKey(du.getName())) {
String logMessage = "Aborting deployment. Duplicate Deployment unit "
+ du.getName() + ".";
log.error(logMessage);
throw new BPELDeploymentException(logMessage);
}
// Validate BPEL package partially before retiring old versions.
validateBPELPackage(du);
// Before updating a BPEL package we need to retire processes in old version
retirePreviousPackageVersions(du);
for (TDeployment.Process processDD : dd.getDeploy().getProcessList()) {
QName processId = Utils.toPid(processDD.getName(), du.getVersion());
processConfs.add(new ProcessConfigurationImpl(
tenantId,
processDD,
du,
deployDate,
parentProcessStore.getEndpointReferenceContext(),
tenantConfigContext));
processIds.add(processId);
}
deploymentUnits.put(du.getName(), du);
processesInDeploymentUnit.put(du.getName(), processIds);
for (ProcessConfigurationImpl processConf : processConfs) {
processes.put(processConf.getProcessId(), processConf);
deploymentContext.addProcessId(processConf.getProcessId());
}
try {
parentProcessStore.onBPELPackageDeployment(
tenantId,
du.getName(),
BPELPackageRepositoryUtils.getResourcePathForBPELPackageContent(deploymentContext),
processConfs);
} catch (ContextException ce) {
handleDeploymentErrorsAtODELayer(deploymentContext, du.getName());
deploymentContext.setDeploymentFailureCause("BPEL Package deployment failed at " +
"ODE layer. Possible cause: " + ce.getMessage());
deploymentContext.setStackTrace(ce);
try {
handleDeploymentError(deploymentContext);