use of org.wso2.carbon.bpmn.core.deployment.TenantRepository in project carbon-business-process by wso2.
the class BPMNDeploymentService method undeploy.
public void undeploy(String deploymentName) throws BPSFault {
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
ProcessEngine processEngine = BPMNServerHolder.getInstance().getEngine();
DeploymentQuery query = processEngine.getRepositoryService().createDeploymentQuery();
query = query.deploymentTenantId(tenantId.toString());
query = query.deploymentNameLike("%" + deploymentName + "%");
int deploymentCount = (int) query.count();
log.info("Package " + deploymentName + " id going to be undeployed for the deployment count : " + deploymentCount);
BPMNDeletableInstances bpmnDeletableInstances = new BPMNDeletableInstances();
bpmnDeletableInstances.setTenantId(tenantId);
List<Deployment> deployments = query.listPage(0, deploymentCount + 1);
for (Deployment deployment : deployments) {
aggregateRemovableProcessInstances(bpmnDeletableInstances, deployment.getId(), tenantId, processEngine);
}
if ((bpmnDeletableInstances.getActiveInstanceCount() + bpmnDeletableInstances.getCompletedInstanceCount()) > maximumDeleteCount) {
String errorMessage = " Failed to un deploy the package. Please delete the instances before un deploying " + "the package";
throw new BPSFault(errorMessage, new Exception(errorMessage));
}
deleteInstances(bpmnDeletableInstances, processEngine);
TenantRepository tenantRepository = BPMNServerHolder.getInstance().getTenantManager().getTenantRepository(tenantId);
tenantRepository.undeploy(deploymentName, false);
}
use of org.wso2.carbon.bpmn.core.deployment.TenantRepository in project carbon-business-process by wso2.
the class BPMNDeployer method init.
/**
* Initializes the deployment per tenant
*
* @param configurationContext axis2 configurationContext
*/
@Override
public void init(ConfigurationContext configurationContext) {
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
log.info("Initializing BPMN Deployer for tenant " + tenantId + ".");
try {
File tenantRepoFolder = createTenantRepo(configurationContext);
tenantRepository = BPMNServerHolder.getInstance().getTenantManager().createTenantRepository(tenantId);
tenantRepository.setRepoFolder(tenantRepoFolder);
// This is to check whether the user have added resolveDeploymentAtStartup system property to true if need
// for resolving deployment to avoid inconsistencies
boolean fixDeployments = true;
if (System.getProperty(BPMNConstants.RESOLVE_DEPLOYMENT_SYS_PROP) != null && !Boolean.parseBoolean(System.getProperty(BPMNConstants.RESOLVE_DEPLOYMENT_SYS_PROP))) {
fixDeployments = false;
log.info("BPMN deployment inconsistencies will not resolved");
}
if (!isWorkerNode() && fixDeployments) {
log.info("Resolving BPMN deployments to avoid inconsistencies");
tenantRepository.fixDeployments();
}
} catch (BPSFault e) {
String msg = "Tenant Error: " + tenantId;
log.error(msg, e);
}
}
use of org.wso2.carbon.bpmn.core.deployment.TenantRepository in project carbon-business-process by wso2.
the class BPMNDeploymentService method getDeployedProcesses.
public BPMNProcess[] getDeployedProcesses() throws BPSFault {
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
TenantRepository tenantRepository = BPMNServerHolder.getInstance().getTenantManager().getTenantRepository(tenantId);
List<ProcessDefinition> processDefinitions = tenantRepository.getDeployedProcessDefinitions();
BPMNProcess[] bpmnProcesses = new BPMNProcess[processDefinitions.size()];
for (int i = 0; i < processDefinitions.size(); i++) {
ProcessDefinition def = processDefinitions.get(i);
BPMNProcess bpmnProcess = new BPMNProcess();
bpmnProcess.setProcessId(def.getId());
bpmnProcess.setDeploymentId(def.getDeploymentId());
bpmnProcess.setKey(def.getKey());
bpmnProcess.setVersion(def.getVersion());
bpmnProcesses[i] = bpmnProcess;
}
return bpmnProcesses;
}
Aggregations