use of org.wso2.carbon.governance.custom.lifecycles.checklist.util.Property in project carbon-business-process by wso2.
the class UserSubstitutionUtils method getPaginatedModelFromRequest.
/**
* Prepare the paginated data model for a substitution query
* @param propertiesMap
* @param tenantId
* @return PaginatedSubstitutesDataModel
*/
private static PaginatedSubstitutesDataModel getPaginatedModelFromRequest(Map<String, String> propertiesMap, int tenantId) {
PaginatedSubstitutesDataModel model = new PaginatedSubstitutesDataModel();
if (propertiesMap.get(SubstitutionQueryProperties.SUBSTITUTE) != null) {
model.setSubstitute(propertiesMap.get(SubstitutionQueryProperties.SUBSTITUTE));
}
if (propertiesMap.get(SubstitutionQueryProperties.USER) != null) {
model.setUser(propertiesMap.get(SubstitutionQueryProperties.USER));
}
String enabled = propertiesMap.get(SubstitutionQueryProperties.ENABLED);
if (enabled != null) {
if (enabled.equalsIgnoreCase("true")) {
model.setEnabled(true);
} else if (enabled.equalsIgnoreCase("false")) {
model.setEnabled(false);
} else {
throw new ActivitiIllegalArgumentException("Invalid parameter " + enabled + " for enabled property.");
}
}
model.setTenantId(tenantId);
int start = Integer.parseInt(propertiesMap.get(SubstitutionQueryProperties.START));
int size = Integer.parseInt(propertiesMap.get(SubstitutionQueryProperties.SIZE));
model.setStart(start);
model.setSize(size);
model.setOrder(propertiesMap.get(SubstitutionQueryProperties.ORDER));
model.setSort(propertiesMap.get(SubstitutionQueryProperties.SORT));
return model;
}
use of org.wso2.carbon.governance.custom.lifecycles.checklist.util.Property in project carbon-business-process by wso2.
the class BPMNDeployer method isWorkerNode.
/**
* Whether a bps node is worker ( a node that does not participate in archive deployment and only handles
* input/output . This is determined by looking at the registry read/only property
* @return
*/
private boolean isWorkerNode() {
RegistryService registryService = BPMNServerHolder.getInstance().getRegistryService();
boolean isWorker = true;
try {
isWorker = (registryService.getConfigSystemRegistry().getRegistryContext().isReadOnly());
} catch (RegistryException e) {
log.error("Error accessing the configuration registry");
}
return isWorker;
}
use of org.wso2.carbon.governance.custom.lifecycles.checklist.util.Property in project carbon-business-process by wso2.
the class ActivitiDAO method querySubstituteInfoWithoutEnabled.
/**
* Return the list of substitute info based on query parameters except enabled property.
* @param model data model with only required query parameter values. Leave others as null.
* @return List<PaginatedSubstitutesDataModel> Result set of substitute info
*/
public List<SubstitutesDataModel> querySubstituteInfoWithoutEnabled(final PaginatedSubstitutesDataModel model) {
final RowBounds rw = new RowBounds(model.getStart(), model.getSize());
CustomSqlExecution<SubstitutesMapper, List<SubstitutesDataModel>> customSqlExecution = new AbstractCustomSqlExecution<SubstitutesMapper, List<SubstitutesDataModel>>(SubstitutesMapper.class) {
public List<SubstitutesDataModel> execute(SubstitutesMapper substitutesMapper) {
return substitutesMapper.querySubstitutesWithoutEnabled(rw, model);
}
};
return managementService.executeCustomSql(customSqlExecution);
}
use of org.wso2.carbon.governance.custom.lifecycles.checklist.util.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.governance.custom.lifecycles.checklist.util.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;
}
Aggregations