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);
}