if (params > 1) {
String message = "Only one of jobId, jobDefinitionId, processInstanceId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}
ManagementService managementService = engine.getManagementService();
if (jobId != null) {
// activate/suspend job by id
if (getSuspended()) {
managementService.suspendJobById(jobId);
} else {
managementService.activateJobById(jobId);
}
} else
if (jobDefinitionId != null) {
// activate/suspend jobs by job definition id
if (getSuspended()) {
managementService.suspendJobByJobDefinitionId(jobDefinitionId);
} else {
managementService.activateJobByJobDefinitionId(jobDefinitionId);
}
} else
if (processInstanceId != null) {
// activate/suspend jobs by process instance id
if (getSuspended()) {
managementService.suspendJobByProcessInstanceId(processInstanceId);
} else {
managementService.activateJobByProcessInstanceId(processInstanceId);
}
} else
if (processDefinitionId != null) {
// activate/suspend jobs by process definition id
if (getSuspended()) {
managementService.suspendJobByProcessDefinitionId(processDefinitionId);
} else {
managementService.activateJobByProcessDefinitionId(processDefinitionId);
}
} else
if (processDefinitionKey != null) {
// activate/suspend jobs by process definition key
if (getSuspended()) {
managementService.suspendJobByProcessDefinitionKey(processDefinitionKey);
} else {
managementService.activateJobByProcessDefinitionKey(processDefinitionKey);
}
} else {
String message = "Either jobId, jobDefinitionId, processInstanceId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}