use of org.apache.ode.store.DeploymentUnitDir in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method undeploySpecificVersionOfBPELPackage.
private void undeploySpecificVersionOfBPELPackage(final String packageName, final Collection<QName> undeployedProcesses) {
DeploymentUnitDir du = deploymentUnits.remove(packageName);
processesInDeploymentUnit.remove(packageName);
if (du != null) {
long version = du.getVersion();
for (QName name : du.getProcessNames()) {
QName pid = Utils.toPid(name, version);
undeployedProcesses.add(pid);
}
}
}
use of org.apache.ode.store.DeploymentUnitDir in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method loadExistingBPELPackage.
private void loadExistingBPELPackage(String bpelPackageName) throws RegistryException, ProcessManagementException, BPELDeploymentException {
DeploymentUnitDAO duDAO = parentProcessStore.getDeploymentUnitDAO(bpelPackageName);
if (duDAO == null) {
String errMsg = "Cannot find DeploymentUnitDAO instance for package " + bpelPackageName + ".";
log.error(errMsg);
throw new BPELDeploymentException(errMsg);
}
File bpelPackage = findBPELPackageInFileSystem(duDAO);
if (bpelPackage == null || !bpelPackage.exists()) {
throw new BPELDeploymentException("Deployed directory " + bpelPackage + " no longer there!");
}
DeploymentUnitDir du = new DeploymentUnitDir(bpelPackage);
du.setVersion(du.getStaticVersion());
du.scan();
List<ProcessConfigurationImpl> loaded = new ArrayList<ProcessConfigurationImpl>();
List<QName> processIds = new ArrayList<QName>();
for (ProcessConfDAO pConfDAO : duDAO.getProcesses()) {
TDeployment.Process processDD = du.getProcessDeployInfo(pConfDAO.getType());
if (processDD == null) {
log.warn("Cannot load " + pConfDAO.getPID() + "; cannot find descriptor.");
continue;
}
// TODO: update the props based on the values in the DB.
ProcessConfigurationImpl pConf = new ProcessConfigurationImpl(tenantId, processDD, du, duDAO.getDeployDate(), parentProcessStore.getEndpointReferenceContext(), tenantConfigContext);
pConf.setAbsolutePathForBpelArchive(bpelPackage.getAbsolutePath());
pConf.setState(pConfDAO.getState());
processIds.add(pConfDAO.getPID());
// if the deployment descriptor is updated at runtime, first load the updated data in
// registry and use them with the specific process
repository.readPropertiesOfUpdatedDeploymentInfo(pConf, bpelPackageName);
readAnalyticsServerProfiles(processDD, du);
processConfigMap.put(pConf.getProcessId(), pConf);
loaded.add(pConf);
}
deploymentUnits.put(du.getName(), du);
processesInDeploymentUnit.put(du.getName(), processIds);
parentProcessStore.onBPELPackageReload(tenantId, du.getName(), loaded);
}
use of org.apache.ode.store.DeploymentUnitDir in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method findBPELPackageInFileSystem.
private File findBPELPackageInFileSystem(DeploymentUnitDAO dudao) {
String duName = dudao.getName();
// Done: Fix the logic to handle registry
log.info("Looking for BPEL package in file system for deployment unit " + duName);
File bpelDUDirectory = new File(bpelDURepo, duName);
if (bpelDUDirectory.exists()) {
return bpelDUDirectory;
} else {
String registryCollectionPath = dudao.getDeploymentUnitDir();
try {
if (tenantConfigRegistry.resourceExists(registryCollectionPath)) {
if (!bpelDUDirectory.exists() && !bpelDUDirectory.mkdirs()) {
String errMsg = "Error creating BPEL deployment unit repository for " + "tenant " + tenantId;
log.error(errMsg);
log.error("Failed to load BPEL deployment unit " + duName + " due to above error.");
throw new BPELDeploymentException(errMsg);
}
boolean deployedOnCarbon310 = false;
// Check whether the registry repo is of type carbon 3.1.0
if (tenantConfigRegistry.resourceExists(registryCollectionPath + RegistryConstants.PATH_SEPARATOR + duName)) {
registryCollectionPath += RegistryConstants.PATH_SEPARATOR + duName;
deployedOnCarbon310 = true;
if (log.isDebugEnabled()) {
log.debug("Found a carbon 3.1.0 compatible deployment unit at " + registryCollectionPath);
}
}
RegistryClientUtils.exportFromRegistry(bpelDUDirectory, registryCollectionPath, tenantConfigRegistry);
if (deployedOnCarbon310) {
if (log.isDebugEnabled()) {
log.debug("Recompiling the carbon 3.1.0 compatible deployment unit at " + bpelDUDirectory);
}
// Re-compiling to get rid of binary compatibility issues.
DeploymentUnitDir du = new DeploymentUnitDir(bpelDUDirectory);
for (File file : du.allFiles()) {
if (file.getAbsolutePath().endsWith(".cbp") && !file.delete()) {
log.warn("Unable to delete " + file);
}
}
du.compile();
}
return bpelDUDirectory;
} else {
String errMsg = "Expected resource: " + registryCollectionPath + " not found in the registry";
log.error(errMsg);
throw new BPELDeploymentException(errMsg);
}
} catch (RegistryException re) {
String errMsg = "Error while exporting deployment unit: " + duName + " to file system from the registry.";
log.error(errMsg, re);
throw new BPELDeploymentException(errMsg, re);
}
}
}
use of org.apache.ode.store.DeploymentUnitDir in project carbon-business-process by wso2.
the class BPELUploadExecutor method validateBPELPackage.
public void validateBPELPackage(String directoryPath) throws Exception {
DeploymentUnitDir du;
try {
du = new DeploymentUnitDir(new File(directoryPath));
} catch (IllegalArgumentException iae) {
log.error("BPEL Package Validation Failure.", iae);
throw new Exception("BPEL Package Validation Failure.", iae);
}
// check package for illegal charactors which registry does not support. (~!@#$;%^*()+={}[]|\<>)
List<File> packageFiles = du.allFiles();
for (File packageFile : packageFiles) {
if (!packageFile.getName().matches("[^\\~\\!\\@\\#\\$\\;\\%\\^\\*\\(\\)\\+ " + "/\\=\\{\\}\\[\\]\\\\|\\<\\>\"\\'\\`]+")) {
log.error("BPEL Package Validation Failure: one or many of the following illegal characters are in " + "the package.\n ~!@#$;%^*()+={}[]| \\<>\"'`");
throw new Exception("BPEL Package Validation Failure: one or many of the following illegal characters" + " " + "are in the package. ~!@#$;%^*()+={}[]| \\<>\"'`");
}
}
try {
du.compile();
} catch (RuntimeException ce) {
log.error("BPEL Process Compilation Failure.", ce);
throw new Exception("BPEL Compilation Failure!", ce);
} catch (Exception e) {
log.error("BPEL Process Compilation Failure.", e);
throw new Exception("BPEL Compilation Failure!", e);
}
du.scan();
DeployDocument dd = du.getDeploymentDescriptor();
for (TDeployment.Process processDD : dd.getDeploy().getProcessList()) {
QName processType = processDD.getType() != null ? processDD.getType() : processDD.getName();
DeploymentUnitDir.CBPInfo cbpInfo = du.getCBPInfo(processType);
if (cbpInfo == null) {
// removeDeploymentArtifacts(deploymentContext, du);
String logMessage = "Aborting deployment. Cannot find Process definition for type " + processType + ".";
log.error(logMessage);
throw new Exception(logMessage);
}
for (TProvide tProvide : processDD.getProvideList()) {
if (tProvide.getService() == null) {
String errMsg = "Service element missing for the provide element in deploy.xml";
log.error(errMsg);
throw new Exception(errMsg);
}
}
for (TInvoke tInvoke : processDD.getInvokeList()) {
if (tInvoke.getService() == null) {
String errMsg = "Service element missing for the invoke element in deploy.xml";
log.error(errMsg);
throw new Exception(errMsg);
}
}
}
}
use of org.apache.ode.store.DeploymentUnitDir in project carbon-business-process by wso2.
the class PeopleActivity method init.
private void init(ExtensionContext extensionContext, Element element) throws FaultException {
if (!element.getLocalName().equals(BPEL4PeopleConstants.PEOPLE_ACTIVITY) || !element.getNamespaceURI().equals(BPEL4PeopleConstants.B4P_NAMESPACE)) {
throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "No " + BPEL4PeopleConstants.PEOPLE_ACTIVITY + " activity found");
}
name = element.getAttribute(BPEL4PeopleConstants.PEOPLE_ACTIVITY_NAME);
inputVarName = element.getAttribute(BPEL4PeopleConstants.PEOPLE_ACTIVITY_INPUT_VARIABLE);
outputVarName = element.getAttribute(BPEL4PeopleConstants.PEOPLE_ACTIVITY_OUTPUT_VARIABLE);
isSkipable = "yes".equalsIgnoreCase(element.getAttribute(BPEL4PeopleConstants.PEOPLE_ACTIVITY_IS_SKIPABLE));
processStandardElement(element);
processAttachmentPropagationElement(element);
String duDir = extensionContext.getDUDir().toString();
String duVersion = duDir.substring(duDir.lastIndexOf('-') + 1);
if (duVersion.endsWith("/")) {
duVersion = duVersion.substring(0, duVersion.lastIndexOf("/"));
} else if (duVersion.endsWith("\\")) {
duVersion = duVersion.substring(0, duVersion.lastIndexOf("\\"));
}
// //Commenting this logic to fix memory issues.
// DeploymentUnitDir du = new DeploymentUnitDir(new File(extensionContext.getDUDir()));
// processId = new QName(extensionContext.getProcessModel().getQName().getNamespaceURI(),
// extensionContext.getProcessModel().getQName().getLocalPart() + "-" +
// du.getStaticVersion());
processId = new QName(extensionContext.getProcessModel().getQName().getNamespaceURI(), extensionContext.getProcessModel().getQName().getLocalPart() + "-" + duVersion);
Integer tenantId = B4PServiceComponent.getBPELServer().getMultiTenantProcessStore().getTenantId(processId);
DeploymentUnitDir du = B4PServiceComponent.getBPELServer().getMultiTenantProcessStore().getTenantsProcessStore(tenantId).getDeploymentUnitDir(processId);
isTwoWay = activityType.equals(InteractionType.TASK);
deriveServiceEPR(du, extensionContext);
}
Aggregations