if (params > 1) {
String message = "Only one of jobDefinitionId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}
ManagementService managementService = engine.getManagementService();
Date delayedExecutionDate = null;
if (executionDate != null && !executionDate.equals("")) {
delayedExecutionDate = DateTimeUtil.parseDate(executionDate);
}
if (jobDefinitionId != null) {
// activate/suspend job definition by id
if (getSuspended()) {
managementService.suspendJobDefinitionById(jobDefinitionId, includeJobs, delayedExecutionDate);
} else {
managementService.activateJobDefinitionById(jobDefinitionId, includeJobs, delayedExecutionDate);
}
} else
if (processDefinitionId != null) {
// activate/suspend job definition by process definition id
if (getSuspended()) {
managementService.suspendJobDefinitionByProcessDefinitionId(processDefinitionId, includeJobs, delayedExecutionDate);
} else {
managementService.activateJobDefinitionByProcessDefinitionId(processDefinitionId, includeJobs, delayedExecutionDate);
}
} else
if (processDefinitionKey != null) {
// activate/suspend job definition by process definition key
if (getSuspended()) {
managementService.suspendJobDefinitionByProcessDefinitionKey(processDefinitionKey, includeJobs, delayedExecutionDate);
} else {
managementService.activateJobDefinitionByProcessDefinitionKey(processDefinitionKey, includeJobs, delayedExecutionDate);
}
} else {
String message = "Either jobDefinitionId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}