use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class IdentityRestServiceImpl method getGroupInfo.
@Override
public GroupInfoDto getGroupInfo(String userId) {
if (userId == null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "No user id was supplied");
}
IdentityService identityService = getProcessEngine().getIdentityService();
GroupQuery query = identityService.createGroupQuery();
List<Group> userGroups = query.groupMember(userId).orderByGroupName().asc().list();
Set<UserDto> allGroupUsers = new HashSet<UserDto>();
List<GroupDto> allGroups = new ArrayList<GroupDto>();
for (Group group : userGroups) {
List<User> groupUsers = identityService.createUserQuery().memberOfGroup(group.getId()).list();
for (User user : groupUsers) {
if (!user.getId().equals(userId)) {
allGroupUsers.add(new UserDto(user.getId(), user.getFirstName(), user.getLastName()));
}
}
allGroups.add(new GroupDto(group.getId(), group.getName()));
}
return new GroupInfoDto(allGroups, allGroupUsers);
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class IdentityRestServiceImpl method verifyUser.
@Override
public AuthenticationResult verifyUser(BasicUserCredentialsDto credentialsDto) {
if (credentialsDto.getUsername() == null || credentialsDto.getPassword() == null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Username and password are required");
}
IdentityService identityService = getProcessEngine().getIdentityService();
boolean valid = identityService.checkPassword(credentialsDto.getUsername(), credentialsDto.getPassword());
if (valid) {
return AuthenticationResult.successful(credentialsDto.getUsername());
} else {
return AuthenticationResult.unsuccessful(credentialsDto.getUsername());
}
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class JobRestServiceImpl method setRetries.
@Override
public BatchDto setRetries(SetJobRetriesDto setJobRetriesDto) {
try {
EnsureUtil.ensureNotNull("setJobRetriesDto", setJobRetriesDto);
EnsureUtil.ensureNotNull("retries", setJobRetriesDto.getRetries());
} catch (NullValueException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
JobQuery jobQuery = null;
if (setJobRetriesDto.getJobQuery() != null) {
jobQuery = setJobRetriesDto.getJobQuery().toQuery(getProcessEngine());
}
try {
Batch batch = getProcessEngine().getManagementService().setJobRetriesAsync(setJobRetriesDto.getJobIds(), jobQuery, setJobRetriesDto.getRetries().intValue());
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 HistoricProcessInstanceRestServiceImpl method deleteAsync.
@Override
public BatchDto deleteAsync(DeleteHistoricProcessInstancesDto dto) {
HistoryService historyService = processEngine.getHistoryService();
HistoricProcessInstanceQuery historicProcessInstanceQuery = null;
if (dto.getHistoricProcessInstanceQuery() != null) {
historicProcessInstanceQuery = dto.getHistoricProcessInstanceQuery().toQuery(processEngine);
}
try {
Batch batch = historyService.deleteHistoricProcessInstancesAsync(dto.getHistoricProcessInstanceIds(), historicProcessInstanceQuery, dto.getDeleteReason());
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 HistoricTaskInstanceRestServiceImpl method getHistoricTaskInstanceReport.
@Override
public Response getHistoricTaskInstanceReport(UriInfo uriInfo) {
HistoricTaskInstanceReportQueryDto queryDto = new HistoricTaskInstanceReportQueryDto(objectMapper, uriInfo.getQueryParameters());
Response response;
if (AbstractReportDto.REPORT_TYPE_DURATION.equals(queryDto.getReportType())) {
List<? extends ReportResult> reportResults = queryDto.executeReport(processEngine);
response = Response.ok(generateDurationDto(reportResults)).build();
} else if (AbstractReportDto.REPORT_TYPE_COUNT.equals(queryDto.getReportType())) {
List<HistoricTaskInstanceReportResult> reportResults = queryDto.executeCompletedReport(processEngine);
response = Response.ok(generateCountDto(reportResults)).build();
} else {
throw new InvalidRequestException(Response.Status.BAD_REQUEST, "Parameter reportType is not set.");
}
return response;
}
Aggregations