Search in sources :

Example 21 with InvalidRequestException

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);
}
Also used : MessageCorrelationResultDto(org.camunda.bpm.engine.rest.dto.message.MessageCorrelationResultDto) ArrayList(java.util.ArrayList) RestException(org.camunda.bpm.engine.rest.exception.RestException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) MessageCorrelationBuilder(org.camunda.bpm.engine.runtime.MessageCorrelationBuilder) MessageCorrelationResult(org.camunda.bpm.engine.runtime.MessageCorrelationResult) MismatchingMessageCorrelationException(org.camunda.bpm.engine.MismatchingMessageCorrelationException)

Example 22 with InvalidRequestException

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());
    }
}
Also used : RuntimeService(org.camunda.bpm.engine.RuntimeService) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) MigrationInstructionsBuilder(org.camunda.bpm.engine.migration.MigrationInstructionsBuilder) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 23 with InvalidRequestException

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;
}
Also used : 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 24 with InvalidRequestException

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);
}
Also used : User(org.camunda.bpm.engine.identity.User) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 25 with InvalidRequestException

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);
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

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