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());
}
}
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);
}
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;
}
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());
}
}
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);
}
Aggregations