Search in sources :

Example 81 with InvalidRequestException

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

the class UserResourceImpl method updateCredentials.

public void updateCredentials(UserCredentialsDto account) {
    ensureNotReadOnly();
    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    if (currentAuthentication != null && currentAuthentication.getUserId() != null) {
        if (!identityService.checkPassword(currentAuthentication.getUserId(), account.getAuthenticatedUserPassword())) {
            throw new InvalidRequestException(Status.BAD_REQUEST, "The given authenticated user password is not valid.");
        }
    }
    User dbUser = findUserObject();
    if (dbUser == null) {
        throw new InvalidRequestException(Status.NOT_FOUND, "User with id " + resourceId + " does not exist");
    }
    dbUser.setPassword(account.getPassword());
    identityService.saveUser(dbUser);
}
Also used : User(org.camunda.bpm.engine.identity.User) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 82 with InvalidRequestException

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

the class JobDefinitionResourceImpl method updateSuspensionState.

public void updateSuspensionState(JobDefinitionSuspensionStateDto dto) {
    try {
        dto.setJobDefinitionId(jobDefinitionId);
        dto.updateSuspensionState(engine);
    } catch (IllegalArgumentException e) {
        String message = String.format("The suspension state of Job Definition with id %s could not be updated due to: %s", jobDefinitionId, e.getMessage());
        throw new InvalidRequestException(Status.BAD_REQUEST, e, message);
    }
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 83 with InvalidRequestException

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

the class JobDefinitionResourceImpl method setJobRetries.

public void setJobRetries(RetriesDto dto) {
    try {
        ManagementService managementService = engine.getManagementService();
        managementService.setJobRetriesByJobDefinitionId(jobDefinitionId, dto.getRetries());
    } catch (AuthorizationException e) {
        throw e;
    } catch (ProcessEngineException e) {
        throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 84 with InvalidRequestException

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

the class JobResourceImpl method getJob.

@Override
public JobDto getJob() {
    ManagementService managementService = engine.getManagementService();
    Job job = managementService.createJobQuery().jobId(jobId).singleResult();
    if (job == null) {
        throw new InvalidRequestException(Status.NOT_FOUND, "Job with id " + jobId + " does not exist");
    }
    return JobDto.fromJob(job);
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) Job(org.camunda.bpm.engine.runtime.Job)

Example 85 with InvalidRequestException

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

the class JobResourceImpl method setJobDuedate.

@Override
public void setJobDuedate(JobDuedateDto dto) {
    try {
        ManagementService managementService = engine.getManagementService();
        managementService.setJobDuedate(jobId, dto.getDuedate());
    } catch (AuthorizationException e) {
        throw e;
    } catch (ProcessEngineException e) {
        throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

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