use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class ProcessDefinitionSuspensionStateDto method updateSuspensionState.
public void updateSuspensionState(ProcessEngine engine) {
if (processDefinitionId != null && processDefinitionKey != null) {
String message = "Only one of processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}
RepositoryService repositoryService = engine.getRepositoryService();
Date delayedExecutionDate = null;
if (executionDate != null && !executionDate.equals("")) {
delayedExecutionDate = DateTimeUtil.parseDate(executionDate);
}
if (processDefinitionId != null) {
// activate/suspend process definition by id
if (getSuspended()) {
repositoryService.suspendProcessDefinitionById(processDefinitionId, includeProcessInstances, delayedExecutionDate);
} else {
repositoryService.activateProcessDefinitionById(processDefinitionId, includeProcessInstances, delayedExecutionDate);
}
} else if (processDefinitionKey != null) {
// activate/suspend process definition by key
if (getSuspended()) {
repositoryService.suspendProcessDefinitionByKey(processDefinitionKey, includeProcessInstances, delayedExecutionDate);
} else {
repositoryService.activateProcessDefinitionByKey(processDefinitionKey, includeProcessInstances, delayedExecutionDate);
}
} else {
String message = "Either processDefinitionId or processDefinitionKey should be set to update the suspension state.";
throw new InvalidRequestException(Status.BAD_REQUEST, message);
}
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class CaseExecutionQueryDto method applyFilters.
@Override
protected void applyFilters(CaseExecutionQuery query) {
if (caseExecutionId != null) {
query.caseExecutionId(caseExecutionId);
}
if (caseInstanceId != null) {
query.caseInstanceId(caseInstanceId);
}
if (businessKey != null) {
query.caseInstanceBusinessKey(businessKey);
}
if (caseDefinitionKey != null) {
query.caseDefinitionKey(caseDefinitionKey);
}
if (caseDefinitionId != null) {
query.caseDefinitionId(caseDefinitionId);
}
if (activityId != null) {
query.activityId(activityId);
}
if (tenantIds != null && !tenantIds.isEmpty()) {
query.tenantIdIn(tenantIds.toArray(new String[tenantIds.size()]));
}
if (required != null && required == true) {
query.required();
}
if (active != null && active == true) {
query.active();
}
if (enabled != null && enabled == true) {
query.enabled();
}
if (disabled != null && disabled == true) {
query.disabled();
}
if (variables != null) {
for (VariableQueryParameterDto variableQueryParam : variables) {
String variableName = variableQueryParam.getName();
String op = variableQueryParam.getOperator();
Object variableValue = variableQueryParam.resolveValue(objectMapper);
if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
query.variableValueEquals(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
query.variableValueGreaterThan(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
query.variableValueGreaterThanOrEqual(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
query.variableValueLessThan(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
query.variableValueLessThanOrEqual(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
query.variableValueNotEquals(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
query.variableValueLike(variableName, String.valueOf(variableValue));
} else {
throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid variable comparator specified: " + op);
}
}
}
if (caseInstanceVariables != null) {
for (VariableQueryParameterDto variableQueryParam : caseInstanceVariables) {
String variableName = variableQueryParam.getName();
String op = variableQueryParam.getOperator();
Object variableValue = variableQueryParam.resolveValue(objectMapper);
if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
query.caseInstanceVariableValueEquals(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
query.caseInstanceVariableValueGreaterThan(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
query.caseInstanceVariableValueGreaterThanOrEqual(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
query.caseInstanceVariableValueLessThan(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
query.caseInstanceVariableValueLessThanOrEqual(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
query.caseInstanceVariableValueNotEquals(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
query.caseInstanceVariableValueLike(variableName, String.valueOf(variableValue));
} else {
throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid variable comparator specified: " + op);
}
}
}
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException 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();
}
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class ExecutionQueryDto method applyFilters.
@Override
protected void applyFilters(ExecutionQuery query) {
if (processDefinitionKey != null) {
query.processDefinitionKey(processDefinitionKey);
}
if (businessKey != null) {
query.processInstanceBusinessKey(businessKey);
}
if (processDefinitionId != null) {
query.processDefinitionId(processDefinitionId);
}
if (processInstanceId != null) {
query.processInstanceId(processInstanceId);
}
if (activityId != null) {
query.activityId(activityId);
}
if (signalEventSubscriptionName != null) {
query.signalEventSubscriptionName(signalEventSubscriptionName);
}
if (messageEventSubscriptionName != null) {
query.messageEventSubscriptionName(messageEventSubscriptionName);
}
if (active != null && active == true) {
query.active();
}
if (suspended != null && suspended == true) {
query.suspended();
}
if (incidentId != null) {
query.incidentId(incidentId);
}
if (incidentType != null) {
query.incidentType(incidentType);
}
if (incidentMessage != null) {
query.incidentMessage(incidentMessage);
}
if (incidentMessageLike != null) {
query.incidentMessageLike(incidentMessageLike);
}
if (tenantIdIn != null && !tenantIdIn.isEmpty()) {
query.tenantIdIn(tenantIdIn.toArray(new String[tenantIdIn.size()]));
}
if (variables != null) {
for (VariableQueryParameterDto variableQueryParam : variables) {
String variableName = variableQueryParam.getName();
String op = variableQueryParam.getOperator();
Object variableValue = variableQueryParam.resolveValue(objectMapper);
if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
query.variableValueEquals(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
query.variableValueGreaterThan(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
query.variableValueGreaterThanOrEqual(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
query.variableValueLessThan(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
query.variableValueLessThanOrEqual(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
query.variableValueNotEquals(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
query.variableValueLike(variableName, String.valueOf(variableValue));
} else {
throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid variable comparator specified: " + op);
}
}
}
if (processVariables != null) {
for (VariableQueryParameterDto variableQueryParam : processVariables) {
String variableName = variableQueryParam.getName();
String op = variableQueryParam.getOperator();
Object variableValue = variableQueryParam.resolveValue(objectMapper);
if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
query.processVariableValueEquals(variableName, variableValue);
} else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
query.processVariableValueNotEquals(variableName, variableValue);
} else {
throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid process variable comparator specified: " + op);
}
}
}
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceImpl method deleteAsync.
@Override
public BatchDto deleteAsync(DeleteProcessInstancesDto dto) {
RuntimeService runtimeService = getProcessEngine().getRuntimeService();
ProcessInstanceQuery processInstanceQuery = null;
if (dto.getProcessInstanceQuery() != null) {
processInstanceQuery = dto.getProcessInstanceQuery().toQuery(getProcessEngine());
}
Batch batch = null;
try {
batch = runtimeService.deleteProcessInstancesAsync(dto.getProcessInstanceIds(), processInstanceQuery, dto.getDeleteReason(), dto.isSkipCustomListeners(), dto.isSkipSubprocesses());
return BatchDto.fromBatch(batch);
} catch (BadUserRequestException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
}
Aggregations