Search in sources :

Example 6 with InvalidRequestException

use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.

the class DeploymentRestServiceImpl method createDeployment.

public DeploymentWithDefinitionsDto createDeployment(UriInfo uriInfo, MultipartFormData payload) {
    DeploymentBuilder deploymentBuilder = extractDeploymentInformation(payload);
    if (!deploymentBuilder.getResourceNames().isEmpty()) {
        DeploymentWithDefinitions deployment = deploymentBuilder.deployWithResult();
        DeploymentWithDefinitionsDto deploymentDto = DeploymentWithDefinitionsDto.fromDeployment(deployment);
        URI uri = uriInfo.getBaseUriBuilder().path(relativeRootResourcePath).path(DeploymentRestService.PATH).path(deployment.getId()).build();
        // GET
        deploymentDto.addReflexiveLink(uri, HttpMethod.GET, "self");
        return deploymentDto;
    } else {
        throw new InvalidRequestException(Status.BAD_REQUEST, "No deployment resources contained in the form upload.");
    }
}
Also used : DeploymentWithDefinitionsDto(org.camunda.bpm.engine.rest.dto.repository.DeploymentWithDefinitionsDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) URI(java.net.URI)

Example 7 with InvalidRequestException

use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceImpl method setRetries.

@Override
public void setRetries(SetRetriesForExternalTasksDto retriesDto) {
    UpdateExternalTaskRetriesBuilder builder = updateRetries(retriesDto);
    int retries = retriesDto.getRetries();
    try {
        builder.set(retries);
    } catch (NotFoundException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e.getMessage());
    } catch (BadUserRequestException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
}
Also used : UpdateExternalTaskRetriesBuilder(org.camunda.bpm.engine.externaltask.UpdateExternalTaskRetriesBuilder) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 8 with InvalidRequestException

use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.

the class TaskQueryDto method applyFilters.

@Override
protected void applyFilters(TaskQuery query) {
    if (orQueries != null) {
        for (TaskQueryDto orQueryDto : orQueries) {
            TaskQueryImpl orQuery = new TaskQueryImpl();
            orQuery.setOrQueryActive();
            orQueryDto.applyFilters(orQuery);
            ((TaskQueryImpl) query).addOrQuery(orQuery);
        }
    }
    if (processInstanceBusinessKey != null) {
        query.processInstanceBusinessKey(processInstanceBusinessKey);
    }
    if (processInstanceBusinessKeyExpression != null) {
        query.processInstanceBusinessKeyExpression(processInstanceBusinessKeyExpression);
    }
    if (processInstanceBusinessKeyIn != null && processInstanceBusinessKeyIn.length > 0) {
        query.processInstanceBusinessKeyIn(processInstanceBusinessKeyIn);
    }
    if (processInstanceBusinessKeyLike != null) {
        query.processInstanceBusinessKeyLike(processInstanceBusinessKeyLike);
    }
    if (processInstanceBusinessKeyLikeExpression != null) {
        query.processInstanceBusinessKeyLikeExpression(processInstanceBusinessKeyLikeExpression);
    }
    if (processDefinitionKey != null) {
        query.processDefinitionKey(processDefinitionKey);
    }
    if (processDefinitionKeyIn != null && processDefinitionKeyIn.length > 0) {
        query.processDefinitionKeyIn(processDefinitionKeyIn);
    }
    if (processDefinitionId != null) {
        query.processDefinitionId(processDefinitionId);
    }
    if (executionId != null) {
        query.executionId(executionId);
    }
    if (activityInstanceIdIn != null && activityInstanceIdIn.length > 0) {
        query.activityInstanceIdIn(activityInstanceIdIn);
    }
    if (tenantIdIn != null && tenantIdIn.length > 0) {
        query.tenantIdIn(tenantIdIn);
    }
    if (TRUE.equals(withoutTenantId)) {
        query.withoutTenantId();
    }
    if (processDefinitionName != null) {
        query.processDefinitionName(processDefinitionName);
    }
    if (processDefinitionNameLike != null) {
        query.processDefinitionNameLike(processDefinitionNameLike);
    }
    if (processInstanceId != null) {
        query.processInstanceId(processInstanceId);
    }
    if (assignee != null) {
        query.taskAssignee(assignee);
    }
    if (assigneeExpression != null) {
        query.taskAssigneeExpression(assigneeExpression);
    }
    if (assigneeLike != null) {
        query.taskAssigneeLike(assigneeLike);
    }
    if (assigneeLikeExpression != null) {
        query.taskAssigneeLikeExpression(assigneeLikeExpression);
    }
    if (candidateGroup != null) {
        query.taskCandidateGroup(candidateGroup);
    }
    if (candidateGroupExpression != null) {
        query.taskCandidateGroupExpression(candidateGroupExpression);
    }
    if (withCandidateGroups != null && withCandidateGroups) {
        query.withCandidateGroups();
    }
    if (withoutCandidateGroups != null && withoutCandidateGroups) {
        query.withoutCandidateGroups();
    }
    if (withCandidateUsers != null && withCandidateUsers) {
        query.withCandidateUsers();
    }
    if (withoutCandidateUsers != null && withoutCandidateUsers) {
        query.withoutCandidateUsers();
    }
    if (candidateUser != null) {
        query.taskCandidateUser(candidateUser);
    }
    if (candidateUserExpression != null) {
        query.taskCandidateUserExpression(candidateUserExpression);
    }
    if (taskDefinitionKeyIn != null && taskDefinitionKeyIn.length > 0) {
        query.taskDefinitionKeyIn(taskDefinitionKeyIn);
    }
    if (taskDefinitionKey != null) {
        query.taskDefinitionKey(taskDefinitionKey);
    }
    if (taskDefinitionKeyLike != null) {
        query.taskDefinitionKeyLike(taskDefinitionKeyLike);
    }
    if (description != null) {
        query.taskDescription(description);
    }
    if (descriptionLike != null) {
        query.taskDescriptionLike(descriptionLike);
    }
    if (involvedUser != null) {
        query.taskInvolvedUser(involvedUser);
    }
    if (involvedUserExpression != null) {
        query.taskInvolvedUserExpression(involvedUserExpression);
    }
    if (maxPriority != null) {
        query.taskMaxPriority(maxPriority);
    }
    if (minPriority != null) {
        query.taskMinPriority(minPriority);
    }
    if (name != null) {
        query.taskName(name);
    }
    if (nameNotEqual != null) {
        query.taskNameNotEqual(nameNotEqual);
    }
    if (nameLike != null) {
        query.taskNameLike(nameLike);
    }
    if (nameNotLike != null) {
        query.taskNameNotLike(nameNotLike);
    }
    if (owner != null) {
        query.taskOwner(owner);
    }
    if (ownerExpression != null) {
        query.taskOwnerExpression(ownerExpression);
    }
    if (priority != null) {
        query.taskPriority(priority);
    }
    if (parentTaskId != null) {
        query.taskParentTaskId(parentTaskId);
    }
    if (assigned != null && assigned) {
        query.taskAssigned();
    }
    if (unassigned != null && unassigned) {
        query.taskUnassigned();
    }
    if (dueAfter != null) {
        query.dueAfter(dueAfter);
    }
    if (dueAfterExpression != null) {
        query.dueAfterExpression(dueAfterExpression);
    }
    if (dueBefore != null) {
        query.dueBefore(dueBefore);
    }
    if (dueBeforeExpression != null) {
        query.dueBeforeExpression(dueBeforeExpression);
    }
    if (dueDate != null) {
        query.dueDate(dueDate);
    }
    if (dueDateExpression != null) {
        query.dueDateExpression(dueDateExpression);
    }
    if (followUpAfter != null) {
        query.followUpAfter(followUpAfter);
    }
    if (followUpAfterExpression != null) {
        query.followUpAfterExpression(followUpAfterExpression);
    }
    if (followUpBefore != null) {
        query.followUpBefore(followUpBefore);
    }
    if (followUpBeforeExpression != null) {
        query.followUpBeforeExpression(followUpBeforeExpression);
    }
    if (followUpBeforeOrNotExistent != null) {
        query.followUpBeforeOrNotExistent(followUpBeforeOrNotExistent);
    }
    if (followUpBeforeOrNotExistentExpression != null) {
        query.followUpBeforeOrNotExistentExpression(followUpBeforeOrNotExistentExpression);
    }
    if (followUpDate != null) {
        query.followUpDate(followUpDate);
    }
    if (followUpDateExpression != null) {
        query.followUpDateExpression(followUpDateExpression);
    }
    if (createdAfter != null) {
        query.taskCreatedAfter(createdAfter);
    }
    if (createdAfterExpression != null) {
        query.taskCreatedAfterExpression(createdAfterExpression);
    }
    if (createdBefore != null) {
        query.taskCreatedBefore(createdBefore);
    }
    if (createdBeforeExpression != null) {
        query.taskCreatedBeforeExpression(createdBeforeExpression);
    }
    if (createdOn != null) {
        query.taskCreatedOn(createdOn);
    }
    if (createdOnExpression != null) {
        query.taskCreatedOnExpression(createdOnExpression);
    }
    if (delegationState != null) {
        DelegationStateConverter converter = new DelegationStateConverter();
        DelegationState state = converter.convertQueryParameterToType(delegationState);
        query.taskDelegationState(state);
    }
    if (candidateGroups != null) {
        query.taskCandidateGroupIn(candidateGroups);
    }
    if (candidateGroupsExpression != null) {
        query.taskCandidateGroupInExpression(candidateGroupsExpression);
    }
    if (includeAssignedTasks != null && includeAssignedTasks) {
        query.includeAssignedTasks();
    }
    if (active != null && active) {
        query.active();
    }
    if (suspended != null && suspended) {
        query.suspended();
    }
    if (caseDefinitionId != null) {
        query.caseDefinitionId(caseDefinitionId);
    }
    if (caseDefinitionKey != null) {
        query.caseDefinitionKey(caseDefinitionKey);
    }
    if (caseDefinitionName != null) {
        query.caseDefinitionName(caseDefinitionName);
    }
    if (caseDefinitionNameLike != null) {
        query.caseDefinitionNameLike(caseDefinitionNameLike);
    }
    if (caseExecutionId != null) {
        query.caseExecutionId(caseExecutionId);
    }
    if (caseInstanceBusinessKey != null) {
        query.caseInstanceBusinessKey(caseInstanceBusinessKey);
    }
    if (caseInstanceBusinessKeyLike != null) {
        query.caseInstanceBusinessKeyLike(caseInstanceBusinessKeyLike);
    }
    if (caseInstanceId != null) {
        query.caseInstanceId(caseInstanceId);
    }
    if (taskVariables != null) {
        for (VariableQueryParameterDto variableQueryParam : taskVariables) {
            String variableName = variableQueryParam.getName();
            String op = variableQueryParam.getOperator();
            Object variableValue = variableQueryParam.resolveValue(objectMapper);
            if (op.equals(VariableQueryParameterDto.EQUALS_OPERATOR_NAME)) {
                query.taskVariableValueEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.NOT_EQUALS_OPERATOR_NAME)) {
                query.taskVariableValueNotEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
                query.taskVariableValueGreaterThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.taskVariableValueGreaterThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
                query.taskVariableValueLessThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.taskVariableValueLessThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
                query.taskVariableValueLike(variableName, String.valueOf(variableValue));
            } else {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid task 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 if (op.equals(VariableQueryParameterDto.GREATER_THAN_OPERATOR_NAME)) {
                query.processVariableValueGreaterThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.GREATER_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.processVariableValueGreaterThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OPERATOR_NAME)) {
                query.processVariableValueLessThan(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LESS_THAN_OR_EQUALS_OPERATOR_NAME)) {
                query.processVariableValueLessThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
                query.processVariableValueLike(variableName, String.valueOf(variableValue));
            } else {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid process 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.NOT_EQUALS_OPERATOR_NAME)) {
                query.caseInstanceVariableValueNotEquals(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.caseInstanceVariableValueGreaterThanOrEquals(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.caseInstanceVariableValueLessThanOrEquals(variableName, variableValue);
            } else if (op.equals(VariableQueryParameterDto.LIKE_OPERATOR_NAME)) {
                query.caseInstanceVariableValueLike(variableName, String.valueOf(variableValue));
            } else {
                throw new InvalidRequestException(Status.BAD_REQUEST, "Invalid case variable comparator specified: " + op);
            }
        }
    }
}
Also used : DelegationState(org.camunda.bpm.engine.task.DelegationState) DelegationStateConverter(org.camunda.bpm.engine.rest.dto.converter.DelegationStateConverter) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) VariableQueryParameterDto(org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)

Example 9 with InvalidRequestException

use of org.camunda.bpm.engine.rest.exception.InvalidRequestException 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)

Example 10 with InvalidRequestException

use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.

the class ProcessInstanceSuspensionStateDto method updateSuspensionStateAsync.

public Batch updateSuspensionStateAsync(ProcessEngine engine) {
    int params = parameterCount(processInstanceIds, processInstanceQuery, historicProcessInstanceQuery);
    if (params == 0) {
        String message = "Either processInstanceIds, processInstanceQuery or historicProcessInstanceQuery should be set to update the suspension state.";
        throw new InvalidRequestException(Status.BAD_REQUEST, message);
    }
    UpdateProcessInstancesSuspensionStateBuilder updateSuspensionStateBuilder = createUpdateSuspensionStateGroupBuilder(engine);
    if (getSuspended()) {
        return updateSuspensionStateBuilder.suspendAsync();
    } else {
        return updateSuspensionStateBuilder.activateAsync();
    }
}
Also used : UpdateProcessInstancesSuspensionStateBuilder(org.camunda.bpm.engine.runtime.UpdateProcessInstancesSuspensionStateBuilder) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Aggregations

InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)116 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)30 RestException (org.camunda.bpm.engine.rest.exception.RestException)25 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)20 NotValidException (org.camunda.bpm.engine.exception.NotValidException)12 ArrayList (java.util.ArrayList)11 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)11 ManagementService (org.camunda.bpm.engine.ManagementService)11 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)11 VariableQueryParameterDto (org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)10 HistoryService (org.camunda.bpm.engine.HistoryService)9 RuntimeService (org.camunda.bpm.engine.RuntimeService)9 InputStream (java.io.InputStream)8 RepositoryService (org.camunda.bpm.engine.RepositoryService)8 Batch (org.camunda.bpm.engine.batch.Batch)8 URI (java.net.URI)6 VariableMap (org.camunda.bpm.engine.variable.VariableMap)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 FormService (org.camunda.bpm.engine.FormService)5 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)5