Search in sources :

Example 1 with UpdateJobSuspensionStateBuilder

use of org.camunda.bpm.engine.management.UpdateJobSuspensionStateBuilder in project camunda-bpm-platform by camunda.

the class JobSuspensionStateDto method updateSuspensionState.

@Override
public void updateSuspensionState(ProcessEngine engine) {
    int params = (jobId != null ? 1 : 0) + (jobDefinitionId != null ? 1 : 0) + (processInstanceId != null ? 1 : 0) + (processDefinitionId != null ? 1 : 0) + (processDefinitionKey != null ? 1 : 0);
    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);
    } else if (params == 0) {
        String message = "Either jobId, jobDefinitionId, processInstanceId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
        throw new InvalidRequestException(Status.BAD_REQUEST, message);
    }
    UpdateJobSuspensionStateBuilder updateSuspensionStateBuilder = createUpdateSuspensionStateBuilder(engine);
    if (getSuspended()) {
        updateSuspensionStateBuilder.suspend();
    } else {
        updateSuspensionStateBuilder.activate();
    }
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) UpdateJobSuspensionStateBuilder(org.camunda.bpm.engine.management.UpdateJobSuspensionStateBuilder)

Aggregations

UpdateJobSuspensionStateBuilder (org.camunda.bpm.engine.management.UpdateJobSuspensionStateBuilder)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1