use of org.camunda.bpm.engine.RepositoryService in project camunda-bpm-platform by camunda.
the class ProcessApplicationDeploymentService method performDeployment.
protected void performDeployment() throws StartException {
ManagedReference reference = null;
try {
// get process engine
ProcessEngine processEngine = processEngineInjector.getValue();
// get the process application component
ProcessApplicationInterface processApplication = null;
ComponentView componentView = paComponentViewInjector.getOptionalValue();
if (componentView != null) {
reference = componentView.createInstance();
processApplication = (ProcessApplicationInterface) reference.getInstance();
} else {
processApplication = noViewProcessApplication.getValue();
}
// get the application name
String processApplicationName = processApplication.getName();
// build the deployment
final RepositoryService repositoryService = processEngine.getRepositoryService();
final ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.getReference());
// enable duplicate filtering
deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DEPLOY_CHANGED_ONLY, false));
// enable resuming of previous versions:
if (PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_RESUME_PREVIOUS_VERSIONS, true)) {
enableResumingOfPreviousVersions(deploymentBuilder);
}
// set the name for the deployment
String deploymentName = processArchive.getName();
if (deploymentName == null || deploymentName.isEmpty()) {
deploymentName = processApplicationName;
}
deploymentBuilder.name(deploymentName);
// set the tenant id for the deployment
String tenantId = processArchive.getTenantId();
if (tenantId != null && !tenantId.isEmpty()) {
deploymentBuilder.tenantId(tenantId);
}
// add deployment resources
for (Entry<String, byte[]> resource : deploymentMap.entrySet()) {
deploymentBuilder.addInputStream(resource.getKey(), new ByteArrayInputStream(resource.getValue()));
}
// let the process application component add resources to the deployment.
processApplication.createDeployment(processArchive.getName(), deploymentBuilder);
Collection<String> resourceNames = deploymentBuilder.getResourceNames();
if (!resourceNames.isEmpty()) {
logDeploymentSummary(resourceNames, deploymentName, processApplicationName);
// perform the actual deployment
deployment = Tccl.runUnderClassloader(new Tccl.Operation<ProcessApplicationDeployment>() {
public ProcessApplicationDeployment run() {
return deploymentBuilder.deploy();
}
}, module.getClassLoader());
} else {
LOGGER.info("Not creating a deployment for process archive '" + processArchive.getName() + "': no resources provided.");
}
} catch (Exception e) {
throw new StartException("Could not register process application with shared process engine ", e);
} finally {
if (reference != null) {
reference.release();
}
}
}
use of org.camunda.bpm.engine.RepositoryService in project camunda-bpm-platform by camunda.
the class ProcessDefinitionSuspensionStateDto method updateSuspensionState.
public void updateSuspensionState(ProcessEngine engine) {
if (processDefinitionId != null && processDefinitionKey != null) {
String message = "Only one of processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}
RepositoryService repositoryService = engine.getRepositoryService();
Date delayedExecutionDate = null;
if (executionDate != null && !executionDate.equals("")) {
delayedExecutionDate = DateTimeUtil.parseDate(executionDate);
}
if (processDefinitionId != null) {
// activate/suspend process definition by id
if (getSuspended()) {
repositoryService.suspendProcessDefinitionById(processDefinitionId, includeProcessInstances, delayedExecutionDate);
} else {
repositoryService.activateProcessDefinitionById(processDefinitionId, includeProcessInstances, delayedExecutionDate);
}
} else if (processDefinitionKey != null) {
// activate/suspend process definition by key
if (getSuspended()) {
repositoryService.suspendProcessDefinitionByKey(processDefinitionKey, includeProcessInstances, delayedExecutionDate);
} else {
repositoryService.activateProcessDefinitionByKey(processDefinitionKey, includeProcessInstances, delayedExecutionDate);
}
} else {
String message = "Either processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}
}
use of org.camunda.bpm.engine.RepositoryService in project camunda-bpm-platform by camunda.
the class ProcessDefinitionRestServiceImpl method deleteProcessDefinitionsByKey.
@Override
public void deleteProcessDefinitionsByKey(String processDefinitionKey, boolean cascade, boolean skipCustomListeners) {
RepositoryService repositoryService = processEngine.getRepositoryService();
DeleteProcessDefinitionsBuilder builder = repositoryService.deleteProcessDefinitions().byKey(processDefinitionKey);
deleteProcessDefinitions(builder, cascade, skipCustomListeners);
}
use of org.camunda.bpm.engine.RepositoryService in project camunda-bpm-platform by camunda.
the class ProcessDefinitionRestServiceImpl method deleteProcessDefinitionsByKeyAndTenantId.
@Override
public void deleteProcessDefinitionsByKeyAndTenantId(String processDefinitionKey, boolean cascade, boolean skipCustomListeners, String tenantId) {
RepositoryService repositoryService = processEngine.getRepositoryService();
DeleteProcessDefinitionsBuilder builder = repositoryService.deleteProcessDefinitions().byKey(processDefinitionKey).withTenantId(tenantId);
deleteProcessDefinitions(builder, cascade, skipCustomListeners);
}
use of org.camunda.bpm.engine.RepositoryService in project camunda-bpm-platform by camunda.
the class CaseDefinitionResourceImpl method getCaseDefinition.
@Override
public CaseDefinitionDto getCaseDefinition() {
RepositoryService repositoryService = engine.getRepositoryService();
CaseDefinition definition = null;
try {
definition = repositoryService.getCaseDefinition(caseDefinitionId);
} catch (NotFoundException e) {
throw new InvalidRequestException(Status.NOT_FOUND, e, e.getMessage());
} catch (NotValidException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
} catch (ProcessEngineException e) {
throw new RestException(Status.INTERNAL_SERVER_ERROR, e);
}
return CaseDefinitionDto.fromCaseDefinition(definition);
}
Aggregations