use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.
the class HumanTaskStore method deploy.
/**
* Handles the deployment steps for the master node and salve node in the cluster
* @param humanTaskFile
* @throws Exception
*/
public void deploy(File humanTaskFile) throws Exception {
// Currently using the registry read/write mount property to determine whether this node is a master node
// or a salve node.
// Handle this properly with hazelcast leader for cluster scenario TODO
boolean isMasterServer = !isServerReadOnly();
// Versions of this ht package is already deployed
boolean isExistingPackage = false;
// Exactly matching ht package already exists
boolean isPackageReload = false;
DeploymentUnitDAO currentlyActiveTaskPackage = null;
String md5sum = HumanTaskStoreUtils.getMD5Checksum(humanTaskFile);
String packageName = FilenameUtils.removeExtension(humanTaskFile.getName());
List<DeploymentUnitDAO> existingDeploymentUnitsForPackage = getExistingDeploymentUnitsForPackage(packageName.trim());
if (existingDeploymentUnitsForPackage != null && existingDeploymentUnitsForPackage.size() > 0) {
isExistingPackage = true;
for (DeploymentUnitDAO dao : existingDeploymentUnitsForPackage) {
if ((dao.getStatus() == (TaskPackageStatus.ACTIVE))) {
// extract the currently active task package
currentlyActiveTaskPackage = dao;
if (dao.getChecksum().equals(md5sum)) {
// Check whether the md5sum matches the active task package.
isPackageReload = true;
}
}
}
}
// We will only allow writes to db only for the master node to avoid duplicate version creation
if (isExistingPackage && isPackageReload) {
// Reload the existing versions of the human task package . No need of creating a new version of the package
// This could be due to server restart, deployment of the same package or master node has already deployed the
// new version of the package
// First check if the currently active task package is already loaded
String activePackageName = loadedPackages.get(currentlyActiveTaskPackage.getPackageName());
if (activePackageName != null && activePackageName.equals(currentlyActiveTaskPackage.getName())) {
if (log.isDebugEnabled()) {
log.debug("This task package and its previous versions are already loaded " + activePackageName);
}
// This task package and its previous versions are already loaded , hence return
return;
}
// Load the existing versions of the package
reloadExistingTaskVersions(existingDeploymentUnitsForPackage, humanTaskFile, md5sum, isMasterServer);
return;
}
// New version of the package is being deployed on top of the existing version
if (isExistingPackage && !isPackageReload) {
if (isMasterServer) {
// Retire the existing version of the package and deploy the new version
// This could be two scenarios. Server restart with new version and deploying on existing version.
String activePackageName = loadedPackages.get(currentlyActiveTaskPackage.getPackageName());
if (activePackageName == null) {
// This is a server restart, we need to load existing versions
reloadExistingTaskVersions(existingDeploymentUnitsForPackage, humanTaskFile, md5sum, isMasterServer);
}
long newVersion = getNextVersion();
HumanTaskDeploymentUnit newDeploymentUnit = createNewDeploymentUnit(humanTaskFile, tenantId, newVersion, md5sum);
validateTaskConfig(newDeploymentUnit);
retireTaskPackageConfigurations(currentlyActiveTaskPackage.getName());
currentlyActiveTaskPackage.setStatus(TaskPackageStatus.RETIRED);
updateDeploymentUnitDao(currentlyActiveTaskPackage);
// Retiring of currently active package is complete.
// Create and deploy new version
deployNewTaskVersion(newDeploymentUnit, newVersion);
// Add new version of human task package to registry
// Update the zip and package properties in the registry
repository.handleNewHumanTaskPackageAddition(newDeploymentUnit, humanTaskFile);
// Successfully deployed the packages.
return;
} else {
// Cannot allow creation of a new version from slave nodes, deploy the new version on the master node
// first to avoid duplicate version creation
// Write log, issue warning and return
log.warn("Cannot deploy new version of the task in slave node. Hence deploy the task archive in master" + "node fist");
return;
}
}
if (!isMasterServer) {
// Issue warning, write warn message and return as we cannot allow deployment of new versions on slave nodes
// before deployment of the ht package in the master node
log.warn("Cannot deploy a new version on the package on the salve node first, " + "Deploy the package on the master node first");
return;
}
// Create new version of deployment unit
// Process the human task configurations
// Store deployment unit information to the db
// Deploy axis2 services
// Adding HumanTask package the registry.
long newVersion = getNextVersion();
HumanTaskDeploymentUnit newDeploymentUnit = createNewDeploymentUnit(humanTaskFile, tenantId, newVersion, md5sum);
validateTaskConfig(newDeploymentUnit);
deployNewTaskVersion(newDeploymentUnit, newVersion);
repository.handleNewHumanTaskPackageAddition(newDeploymentUnit, humanTaskFile);
return;
}
use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.
the class ProcessConfigurationImpl method getEndpointProperties.
public Map<String, String> getEndpointProperties(EndpointReference endpointReference) {
/**
* This method is only there to use by ODEProcess#getTimeout method. Because we can't change
* internals of ODE we have to make our configuration mechanism transparent to ODE.
* Therefore I only added mex.timeout property to map and returned it here. If there are
* more properties like this which use by BPEL engine we have to make our configuration
* mechanism transparent and add that property to this map.
*/
EndpointConfiguration epConf = null;
final Map map = eprContext.getConfigLookup(endpointReference);
final QName service = (QName) map.get("service");
final String port = (String) map.get("port");
if (log.isDebugEnabled()) {
log.debug("Looking Endpoint configuration properties for service: " + service + " and port: " + port);
}
if (bpelPackageConfiguration != null) {
epConf = (EndpointConfiguration) bpelPackageConfiguration.getEndpoints().get(service.getLocalPart(), service.getNamespaceURI(), port);
}
HashMap<String, String> props = new HashMap<String, String>();
if (epConf != null) {
props.put(BPELConstants.ODE_MEX_TIMEOUT, epConf.getMexTimeout());
}
return props;
}
use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method handleUndeployOnSlaveNode.
/**
* Undeployment scenario in a worker node( Slave ) in the clustered setup
* When the BPELDeployer get called for undeploying the bpel package, following has already taken place.
* The package information stored in the registry as well as the zip archive is deleted
* Process, Instance information have been removed from the ODE database
* However, on the slave node, the bpel process and the web services associated with the bpel process
* is still in memory. We need to unload the bpel process and the associated web services
*
* @param bpelPackageName bpel package name
* @return
*/
private int handleUndeployOnSlaveNode(String bpelPackageName) {
List<String> packageList = findMatchingProcessByPackageName(bpelPackageName);
if (packageList.size() < 1) {
log.debug("Handling un-deploy operation on salve (worker) node : package list is empty");
return -1;
}
for (String packageName : packageList) {
// location for extracted BPEL package
String bpelPackageLocation = parentProcessStore.getLocalDeploymentUnitRepo().getAbsolutePath() + File.separator + tenantId + File.separator + packageName;
File bpelPackage = new File(bpelPackageLocation);
// removing extracted bpel package at repository/bpel/tenantID/
deleteBpelPackageFromRepo(bpelPackage);
for (QName pid : getProcessesInPackage(packageName)) {
ProcessConfigurationImpl processConf = (ProcessConfigurationImpl) getProcessConfiguration(pid);
// This property is read when we removing the axis service for this process.
// So that we can decide whether we should persist service QOS configs
processConf.setUndeploying(true);
}
}
Collection<QName> undeployedProcesses = new ArrayList<QName>();
for (String nameWithVersion : packageList) {
undeploySpecificVersionOfBPELPackage(nameWithVersion, undeployedProcesses);
}
BPELServerImpl instance = BPELServerImpl.getInstance();
BpelServerImpl odeBpelServer = instance.getODEBPELServer();
for (QName pid : undeployedProcesses) {
odeBpelServer.unregister(pid);
ProcessConf pConf = parentProcessStore.getProcessConfiguration(pid);
if (pConf != null) {
if (log.isDebugEnabled()) {
log.debug("Cancelling all cron scheduled jobs for process " + pid);
}
odeBpelServer.getContexts().cronScheduler.cancelProcessCronJobs(pid, true);
}
log.info("Process " + pid + " un-deployed.");
}
parentProcessStore.updateProcessAndDUMapsForSalve(tenantId, bpelPackageName, undeployedProcesses);
return 0;
}
use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.
the class AbstractPaginateList method paginateList.
public DataResponse paginateList(Map<String, String> requestParams, PaginateRequest paginateRequest, Query query, String defaultSort, Map<String, QueryProperty> properties) {
if (paginateRequest == null) {
paginateRequest = new PaginateRequest();
}
// In case pagination request is incomplete, fill with values found in URL if possible
if (paginateRequest.getStart() == null) {
paginateRequest.setStart(RequestUtil.getInteger(requestParams, "start", 0));
}
if (paginateRequest.getSize() == null) {
paginateRequest.setSize(RequestUtil.getInteger(requestParams, "size", 10));
}
if (paginateRequest.getOrder() == null) {
paginateRequest.setOrder(requestParams.get("order"));
}
if (paginateRequest.getSort() == null) {
paginateRequest.setSort(requestParams.get("sort"));
}
// Use defaults for paging, if not set in the PaginationRequest, nor in the URL
Integer start = paginateRequest.getStart();
if (start == null || start < 0) {
start = 0;
}
Integer size = paginateRequest.getSize();
if (size == null || size < 0) {
size = 10;
}
String sort = paginateRequest.getSort();
if (sort == null) {
// id
sort = defaultSort;
}
String order = paginateRequest.getOrder();
if (order == null) {
order = "asc";
}
// Sort order
if (sort != null && !properties.isEmpty()) {
QueryProperty qp = properties.get(sort);
if (qp == null) {
throw new ActivitiIllegalArgumentException("Value for param 'sort' is not valid, '" + sort + "' is not a valid property");
}
((AbstractQuery) query).orderBy(qp);
if (order.equals("asc")) {
query.asc();
} else if (order.equals("desc")) {
query.desc();
} else {
throw new ActivitiIllegalArgumentException("Value for param 'order' is not valid : '" + order + "', must be 'asc' or 'desc'");
}
}
// Get result and set pagination parameters
List list = processList(query.listPage(start, size));
DataResponse response = new DataResponse();
response.setStart(start);
response.setSize(list.size());
response.setSort(sort);
response.setOrder(order);
response.setTotal(query.count());
response.setData(list);
return response;
}
use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.
the class SubstitutionDataHolder method isTransitivityEnabled.
/**
* Get the transitivity enabled value for substitution from configuration.
* @return true if transitivity enabled
*/
public boolean isTransitivityEnabled() {
if (transitivityEnabled != null) {
return transitivityEnabled;
} else {
transitivityEnabled = BPMNConstants.SUBSTITUTION_TRANSITIVITY_DEFAULT;
BPMNActivitiConfiguration bpmnActivitiConfiguration = BPMNActivitiConfiguration.getInstance();
if (bpmnActivitiConfiguration != null) {
String transitivityEnabledProperty = bpmnActivitiConfiguration.getBPMNPropertyValue(BPMNConstants.SUBSTITUTION_CONFIG, BPMNConstants.SUBSTITUTION_TRANSITIVITY_PROPERTY);
if (transitivityEnabledProperty != null) {
if (transitivityEnabledProperty.trim().equalsIgnoreCase("true") || transitivityEnabledProperty.trim().equalsIgnoreCase("false")) {
transitivityEnabled = Boolean.parseBoolean(transitivityEnabledProperty);
if (log.isDebugEnabled()) {
log.debug("User substitution transitivity enabled : " + transitivityEnabled);
}
} else {
log.warn("Invalid value for the property: " + BPMNConstants.SUBSTITUTION_TRANSITIVITY_PROPERTY + ". Transitivity is being disabled by default.");
}
}
}
return transitivityEnabled;
}
}
Aggregations