use of org.camunda.bpm.engine.management.UpdateJobDefinitionSuspensionStateBuilder in project camunda-bpm-platform by camunda.
the class JobDefinitionSuspensionStateDto method updateSuspensionState.
@Override
public void updateSuspensionState(ProcessEngine engine) {
int params = (jobDefinitionId != null ? 1 : 0) + (processDefinitionId != null ? 1 : 0) + (processDefinitionKey != null ? 1 : 0);
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);
} else if (params == 0) {
String message = "Either jobDefinitionId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}
UpdateJobDefinitionSuspensionStateBuilder updateSuspensionStateBuilder = createUpdateSuspensionStateBuilder(engine);
if (executionDate != null && !executionDate.equals("")) {
Date delayedExecutionDate = DateTimeUtil.parseDate(executionDate);
updateSuspensionStateBuilder.executionDate(delayedExecutionDate);
}
updateSuspensionStateBuilder.includeJobs(includeJobs);
if (getSuspended()) {
updateSuspensionStateBuilder.suspend();
} else {
updateSuspensionStateBuilder.activate();
}
}
Aggregations