use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class MessageRestServiceImpl method deliverMessage.
@Override
public Response deliverMessage(CorrelationMessageDto messageDto) {
if (messageDto.getMessageName() == null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "No message name supplied");
}
if (messageDto.getTenantId() != null && messageDto.isWithoutTenantId()) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Parameter 'tenantId' cannot be used together with parameter 'withoutTenantId'.");
}
List<MessageCorrelationResultDto> resultDtos = new ArrayList<MessageCorrelationResultDto>();
try {
MessageCorrelationBuilder correlation = createMessageCorrelationBuilder(messageDto);
if (!messageDto.isAll()) {
MessageCorrelationResult result = correlation.correlateWithResult();
resultDtos.add(MessageCorrelationResultDto.fromMessageCorrelationResult(result));
} else {
List<MessageCorrelationResult> results = correlation.correlateAllWithResult();
for (MessageCorrelationResult result : results) {
resultDtos.add(MessageCorrelationResultDto.fromMessageCorrelationResult(result));
}
}
} catch (RestException e) {
String errorMessage = String.format("Cannot deliver message: %s", e.getMessage());
throw new InvalidRequestException(e.getStatus(), e, errorMessage);
} catch (MismatchingMessageCorrelationException e) {
throw new RestException(Status.BAD_REQUEST, e);
}
return createResponse(resultDtos, messageDto);
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class MigrationRestServiceImpl method generateMigrationPlan.
public MigrationPlanDto generateMigrationPlan(MigrationPlanGenerationDto generationDto) {
RuntimeService runtimeService = processEngine.getRuntimeService();
String sourceProcessDefinitionId = generationDto.getSourceProcessDefinitionId();
String targetProcessDefinitionId = generationDto.getTargetProcessDefinitionId();
try {
MigrationInstructionsBuilder instructionsBuilder = runtimeService.createMigrationPlan(sourceProcessDefinitionId, targetProcessDefinitionId).mapEqualActivities();
if (generationDto.isUpdateEventTriggers()) {
instructionsBuilder = instructionsBuilder.updateEventTriggers();
}
MigrationPlan migrationPlan = instructionsBuilder.build();
return MigrationPlanDto.from(migrationPlan);
} catch (BadUserRequestException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
}
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class UserResourceImpl method getUserProfile.
public UserProfileDto getUserProfile(UriInfo context) {
User dbUser = findUserObject();
if (dbUser == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "User with id " + resourceId + " does not exist");
}
UserProfileDto user = UserProfileDto.fromUser(dbUser);
return user;
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class UserResourceImpl method updateProfile.
public void updateProfile(UserProfileDto profile) {
ensureNotReadOnly();
User dbUser = findUserObject();
if (dbUser == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "User with id " + resourceId + " does not exist");
}
profile.update(dbUser);
identityService.saveUser(dbUser);
}
use of org.camunda.bpm.engine.rest.exception.InvalidRequestException in project camunda-bpm-platform by camunda.
the class JobDefinitionResourceImpl method getJobDefinition.
public JobDefinitionDto getJobDefinition() {
ManagementService managementService = engine.getManagementService();
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().jobDefinitionId(jobDefinitionId).singleResult();
if (jobDefinition == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Job Definition with id " + jobDefinitionId + " does not exist");
}
return JobDefinitionDto.fromJobDefinition(jobDefinition);
}
Aggregations