use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.
the class HumanTaskPackageRepository method handleExceptionWithRollback.
/**
* Handles exception and rollbacks an already started transaction. Don't use this method if
* you haven't already started a registry transaction
*
* @param msg - Message to log
* @param e - original exception
* @throws RegistryException on registry rollback error case, we'll init the cause to the
* original exception we got when accessing registry
*/
protected void handleExceptionWithRollback(String msg, Exception e) throws Exception {
Exception cachedException = null;
log.error(msg, e);
try {
configRegistry.rollbackTransaction();
} catch (RegistryException re) {
cachedException = re;
log.error("Transaction rollback failed", re);
}
if (cachedException != null) {
cachedException.initCause(e);
throw cachedException;
} else {
throw e;
}
}
use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.
the class UnifiedEndpointHandler method loadPolicy.
private Policy loadPolicy(String path, MessageContext msgContext) throws AxisFault {
Policy policyDoc = null;
if (path.startsWith(UnifiedEndpointConstants.VIRTUAL_FILE)) {
path = path.replaceFirst(UnifiedEndpointConstants.VIRTUAL_FILE, "");
try {
InputStream policyStream = UnifiedEndpointUtils.getFileInputStream(path);
try {
policyDoc = PolicyEngine.getPolicy(policyStream);
} finally {
policyStream.close();
}
} catch (IOException e) {
String errMsg = "Exception while parsing policy: " + path;
log.error(errMsg, e);
throw new AxisFault(errMsg, e);
}
} else if (path.startsWith(UnifiedEndpointConstants.VIRTUAL_GOV_REG)) {
Registry reg = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE);
path = path.substring(UnifiedEndpointConstants.VIRTUAL_GOV_REG.length());
try {
if (reg.resourceExists(path)) {
Resource policyResource = reg.get(path);
policyDoc = PolicyEngine.getPolicy(policyResource.getContentStream());
}
} catch (RegistryException e) {
String errMsg = "Exception while loading policy from Governance registry: " + path;
log.error(errMsg, e);
throw new AxisFault(errMsg, e);
}
} else if (path.startsWith(UnifiedEndpointConstants.VIRTUAL_CONF_REG)) {
Registry reg = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_CONFIGURATION);
path = path.substring(UnifiedEndpointConstants.VIRTUAL_CONF_REG.length());
try {
if (reg.resourceExists(path)) {
Resource policyResource = reg.get(path);
policyDoc = PolicyEngine.getPolicy(policyResource.getContentStream());
}
} catch (RegistryException e) {
String errMsg = "Exception while loading policy from Configuration registry: " + path;
log.error(errMsg, e);
throw new AxisFault(errMsg, e);
}
} else {
String errMsg = "Invalid policy path: " + path;
log.error(errMsg);
throw new AxisFault(errMsg);
}
return policyDoc;
}
use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.
the class BPELPackageRepository method readPropertiesOfUpdatedDeploymentInfo.
/**
* Reads the updated properties from registry and sets the process configuration fields
*
* @param processConfiguration - Process's configuration details after updated
* @param bpelPackageName - the relevant bpel package
* @throws RegistryException on registry rollback error case, we'll init the cause to the
* original exception we got when accessing registry
* @throws ProcessManagementException
*/
public void readPropertiesOfUpdatedDeploymentInfo(ProcessConfigurationImpl processConfiguration, String bpelPackageName) throws RegistryException, ProcessManagementException {
String versionlessPackageName = BPELPackageRepositoryUtils.getVersionlessPackageName(bpelPackageName);
String packageLocation = BPELPackageRepositoryUtils.getResourcePathForDeployInfoUpdatedBPELPackage(processConfiguration.getPackage(), versionlessPackageName);
Resource bpelPackage = configRegistry.get(packageLocation);
String stateInString = bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_STATE + processConfiguration.getProcessId());
String inMemoryInString = bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_INMEMORY + processConfiguration.getProcessId());
String processEventsInString = bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_EVENTS + processConfiguration.getProcessId());
String generateTypeString = bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_EVENT_GENERATE + processConfiguration.getProcessId());
String successCleanupsInString = bpelPackage.getProperty(BPELConstants.BPEL_INSTANCE_CLEANUP_SUCCESS + processConfiguration.getProcessId());
String failureCleanupsInString = bpelPackage.getProperty(BPELConstants.BPEL_INSTANCE_CLEANUP_FAILURE + processConfiguration.getProcessId());
// editor has been updated, read the updated fields
if (stateInString != null) {
ProcessState state = BPELPackageRepositoryUtils.getProcessState(stateInString);
processConfiguration.setState(state);
processConfiguration.setIsTransient(Boolean.parseBoolean(inMemoryInString));
ProcessEventsListType processEventsList = new ProcessEventsListType();
EnableEventListType enabledEventList = BPELPackageRepositoryUtils.getEnabledEventsListFromString(processEventsInString);
processEventsList.setEnableEventsList(enabledEventList);
Generate_type1 generateType = BPELPackageRepositoryUtils.getProcessGenerateTypeFromString(generateTypeString);
processEventsList.setGenerate(generateType);
ScopeEventListType scopeEventList = new ScopeEventListType();
int j = 0;
while (bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_SCOPE_EVENT + (j + 1) + processConfiguration.getProcessId()) != null) {
ScopeEventType scopeEvent = BPELPackageRepositoryUtils.getScopeEventFromString(bpelPackage.getProperty(BPELConstants.BPEL_PROCESS_SCOPE_EVENT + (j + 1) + processConfiguration.getProcessId()));
scopeEventList.addScopeEvent(scopeEvent);
j++;
}
processEventsList.setScopeEventsList(scopeEventList);
processConfiguration.setProcessEventsList(processEventsList);
CleanUpListType cleanUpList = new CleanUpListType();
CleanUpType successCleanUp = BPELPackageRepositoryUtils.getSuccessCleanUpType(successCleanupsInString);
cleanUpList.addCleanUp(successCleanUp);
CleanUpType failureCleanUp = BPELPackageRepositoryUtils.getFailureCleanUpType(failureCleanupsInString);
cleanUpList.addCleanUp(failureCleanUp);
processConfiguration.setProcessCleanupConfImpl(cleanUpList);
}
}
use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.
the class BPELPackageRepository method createBPELPackageParentCollectionWithProperties.
/**
* Create parent collection to persisting BPEL package information. For example, if you deploy
* a BPEL archive called 'HelloWorld.zip', we store information of that package in collection
* named 'HelloWorld'. This will be the root for 'HelloWorld' BPEL package information and
* there will several versions of this BPEL package in this registry collection which relates
* to the versions deployed in BPEL engine.
*
* @param deploymentContext containing information on current deployment
* @throws RegistryException when there is a error accessing registry
* @throws IOException if file access error occurred during MD5 checksum generation
* @throws NoSuchAlgorithmException when there is a error during MD5 generation
*/
private void createBPELPackageParentCollectionWithProperties(BPELDeploymentContext deploymentContext) throws RegistryException, IOException, NoSuchAlgorithmException {
Collection bpelPackage = configRegistry.newCollection();
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_CHECKSUM, Utils.getMD5Checksum(deploymentContext.getBpelArchive()));
if (log.isDebugEnabled()) {
log.debug(deploymentContext.getBpelPackageName() + " updating checksum: " + Utils.getMD5Checksum(deploymentContext.getBpelArchive()) + " in registry");
}
if (deploymentContext.isFailed()) {
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS, BPELConstants.STATUS_FAILED);
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_ERROR_LOG, deploymentContext.getDeploymentFailureCause());
// bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_DEPLOYMENT_STACK_TRACE,
// ExceptionUtils.getStackTrace(deploymentContext.getStackTrace()));
} else {
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_STATUS, BPELConstants.STATUS_DEPLOYED);
}
bpelPackage.setProperty(BPELConstants.BPEL_PACKAGE_PROP_LATEST_VERSION, Long.toString(deploymentContext.getVersion()));
configRegistry.put(BPELPackageRepositoryUtils.getResourcePathForBPELPackage(deploymentContext), bpelPackage);
}
use of org.wso2.carbon.registry.core.Registry in project carbon-business-process by wso2.
the class BPELPackageRepository method getBPELPackages.
public List<BPELPackageInfo> getBPELPackages() throws Exception {
List<BPELPackageInfo> bpelPackages = new ArrayList<BPELPackageInfo>();
try {
if (configRegistry.resourceExists(BPELConstants.REG_PATH_OF_BPEL_PACKAGES)) {
Resource parentCollection = configRegistry.get(BPELConstants.REG_PATH_OF_BPEL_PACKAGES);
// The above registry resource we retrieve only contains set of child collections.
// So we can directly cast the returned object to a string array.
String[] children = (String[]) parentCollection.getContent();
for (int i = children.length - 1; i >= 0; i--) {
bpelPackages.add(getBPELPackageInfo(children[i]));
}
return sortByPackageName(bpelPackages);
}
} catch (RegistryException re) {
handleExceptionWithRollback("Unable to get BPEL Packages from Repository.", re);
}
return null;
}
Aggregations