Search in sources :

Example 1 with UpdateJobDefinitionSuspensionStateBuilder

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();
    }
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) UpdateJobDefinitionSuspensionStateBuilder(org.camunda.bpm.engine.management.UpdateJobDefinitionSuspensionStateBuilder) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 UpdateJobDefinitionSuspensionStateBuilder (org.camunda.bpm.engine.management.UpdateJobDefinitionSuspensionStateBuilder)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1