if (params > 1) {
String message = "Only one of processInstanceId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}
RuntimeService runtimeService = engine.getRuntimeService();
if (processInstanceId != null) {
// activate/suspend process instance by id
if (getSuspended()) {
runtimeService.suspendProcessInstanceById(processInstanceId);
} else {
runtimeService.activateProcessInstanceById(processInstanceId);
}
} else
if (processDefinitionId != null) {
// activate/suspend process instances by process definition id
if (getSuspended()) {
runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId);
} else {
runtimeService.activateProcessInstanceByProcessDefinitionId(processDefinitionId);
}
} else
if (processDefinitionKey != null) {
// activate/suspend process instances by process definition key
if (getSuspended()) {
runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinitionKey);
} else {
runtimeService.activateProcessInstanceByProcessDefinitionKey(processDefinitionKey);
}
} else {
String message = "Either processInstanceId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}