Search in sources :

Example 91 with InvalidRequestException

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

the class ProcessInstanceRestServiceImpl method deleteAsyncHistoricQueryBased.

@Override
public BatchDto deleteAsyncHistoricQueryBased(DeleteProcessInstancesDto deleteProcessInstancesDto) {
    List<String> processInstanceIds = new ArrayList<String>();
    HistoricProcessInstanceQueryDto queryDto = deleteProcessInstancesDto.getHistoricProcessInstanceQuery();
    if (queryDto != null) {
        HistoricProcessInstanceQuery query = queryDto.toQuery(getProcessEngine());
        List<HistoricProcessInstance> historicProcessInstances = query.list();
        for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
            processInstanceIds.add(historicProcessInstance.getId());
        }
    }
    if (deleteProcessInstancesDto.getProcessInstanceIds() != null) {
        processInstanceIds.addAll(deleteProcessInstancesDto.getProcessInstanceIds());
    }
    try {
        RuntimeService runtimeService = getProcessEngine().getRuntimeService();
        Batch batch = runtimeService.deleteProcessInstancesAsync(processInstanceIds, null, deleteProcessInstancesDto.getDeleteReason(), deleteProcessInstancesDto.isSkipCustomListeners(), deleteProcessInstancesDto.isSkipSubprocesses());
        return BatchDto.fromBatch(batch);
    } catch (BadUserRequestException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) RuntimeService(org.camunda.bpm.engine.RuntimeService) Batch(org.camunda.bpm.engine.batch.Batch) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 92 with InvalidRequestException

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

the class UserRestServiceImpl method createUser.

public void createUser(UserDto userDto) {
    final IdentityService identityService = getIdentityService();
    if (identityService.isReadOnly()) {
        throw new InvalidRequestException(Status.FORBIDDEN, "Identity service implementation is read-only.");
    }
    UserProfileDto profile = userDto.getProfile();
    if (profile == null || profile.getId() == null) {
        throw new InvalidRequestException(Status.BAD_REQUEST, "request object must provide profile information with valid id.");
    }
    User newUser = identityService.newUser(profile.getId());
    profile.update(newUser);
    if (userDto.getCredentials() != null) {
        newUser.setPassword(userDto.getCredentials().getPassword());
    }
    identityService.saveUser(newUser);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) User(org.camunda.bpm.engine.identity.User) UserProfileDto(org.camunda.bpm.engine.rest.dto.identity.UserProfileDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 93 with InvalidRequestException

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

the class ConditionRestServiceImpl method evaluateCondition.

@Override
public List<ProcessInstanceDto> evaluateCondition(EvaluationConditionDto conditionDto) {
    if (conditionDto.getTenantId() != null && conditionDto.isWithoutTenantId()) {
        throw new InvalidRequestException(Status.BAD_REQUEST, "Parameter 'tenantId' cannot be used together with parameter 'withoutTenantId'.");
    }
    ConditionEvaluationBuilder builder = createConditionEvaluationBuilder(conditionDto);
    List<ProcessInstance> processInstances = builder.evaluateStartConditions();
    List<ProcessInstanceDto> result = new ArrayList<ProcessInstanceDto>();
    for (ProcessInstance processInstance : processInstances) {
        result.add(ProcessInstanceDto.fromProcessInstance(processInstance));
    }
    return result;
}
Also used : ProcessInstanceDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceDto) ConditionEvaluationBuilder(org.camunda.bpm.engine.runtime.ConditionEvaluationBuilder) ArrayList(java.util.ArrayList) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance)

Example 94 with InvalidRequestException

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

the class ExternalTaskRestServiceImpl method setRetriesAsync.

@Override
public BatchDto setRetriesAsync(SetRetriesForExternalTasksDto retriesDto) {
    UpdateExternalTaskRetriesBuilder builder = updateRetries(retriesDto);
    int retries = retriesDto.getRetries();
    try {
        Batch batch = builder.setAsync(retries);
        return BatchDto.fromBatch(batch);
    } 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) Batch(org.camunda.bpm.engine.batch.Batch) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 95 with InvalidRequestException

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

the class FilterRestServiceImpl method createFilter.

public FilterDto createFilter(FilterDto filterDto) {
    FilterService filterService = getProcessEngine().getFilterService();
    String resourceType = filterDto.getResourceType();
    Filter filter;
    if (EntityTypes.TASK.equals(resourceType)) {
        filter = filterService.newTaskFilter();
    } else {
        throw new InvalidRequestException(Response.Status.BAD_REQUEST, "Unable to create filter with invalid resource type '" + resourceType + "'");
    }
    try {
        filterDto.updateFilter(filter, getProcessEngine());
    } catch (NotValidException e) {
        throw new InvalidRequestException(Response.Status.BAD_REQUEST, e, "Unable to create filter with invalid content");
    }
    filterService.saveFilter(filter);
    return FilterDto.fromFilter(filter);
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) Filter(org.camunda.bpm.engine.filter.Filter) FilterService(org.camunda.bpm.engine.FilterService) 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