Search in sources :

Example 36 with NotFoundException

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

the class CaseInstanceResourceImpl method close.

public void close(CaseExecutionTriggerDto triggerDto) {
    try {
        CaseService caseService = engine.getCaseService();
        CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseInstanceId);
        initializeCommand(commandBuilder, triggerDto, "close");
        commandBuilder.close();
    } catch (NotFoundException e) {
        throw createInvalidRequestException("close", Status.NOT_FOUND, e);
    } catch (NotValidException e) {
        throw createInvalidRequestException("close", Status.BAD_REQUEST, e);
    } catch (NotAllowedException e) {
        throw createInvalidRequestException("close", Status.FORBIDDEN, e);
    } catch (ProcessEngineException e) {
        throw createRestException("close", Status.INTERNAL_SERVER_ERROR, e);
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) CaseService(org.camunda.bpm.engine.CaseService) CaseExecutionCommandBuilder(org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 37 with NotFoundException

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

the class JobResourceImpl method setJobPriority.

@Override
public void setJobPriority(PriorityDto dto) {
    if (dto.getPriority() == null) {
        throw new RestException(Status.BAD_REQUEST, "Priority for job '" + jobId + "' cannot be null.");
    }
    try {
        ManagementService managementService = engine.getManagementService();
        managementService.setJobPriority(jobId, dto.getPriority());
    } catch (AuthorizationException e) {
        throw e;
    } catch (NotFoundException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e.getMessage());
    } catch (ProcessEngineException e) {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 38 with NotFoundException

use of org.camunda.bpm.engine.exception.NotFoundException 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());
    }
}
Also used : UpdateExternalTaskRetriesBuilder(org.camunda.bpm.engine.externaltask.UpdateExternalTaskRetriesBuilder) Batch(org.camunda.bpm.engine.batch.Batch) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 39 with NotFoundException

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

the class DeployCmd method ensureDeploymentsWithIdsExists.

protected void ensureDeploymentsWithIdsExists(Set<String> expected, List<DeploymentEntity> actual) {
    Map<String, DeploymentEntity> deploymentMap = new HashMap<String, DeploymentEntity>();
    for (DeploymentEntity deployment : actual) {
        deploymentMap.put(deployment.getId(), deployment);
    }
    List<String> missingDeployments = getMissingElements(expected, deploymentMap);
    if (!missingDeployments.isEmpty()) {
        StringBuilder builder = new StringBuilder();
        builder.append("The following deployments are not found by id: ");
        boolean first = true;
        for (String missingDeployment : missingDeployments) {
            if (!first) {
                builder.append(", ");
            } else {
                first = false;
            }
            builder.append(missingDeployment);
        }
        throw new NotFoundException(builder.toString());
    }
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) HashMap(java.util.HashMap) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException)

Example 40 with NotFoundException

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

the class SetExternalTasksRetriesTest method shouldFailForNonExistingExternalTaskIdSync.

@Test
public void shouldFailForNonExistingExternalTaskIdSync() {
    List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().list();
    ArrayList<String> externalTaskIds = new ArrayList<String>();
    for (ExternalTask task : externalTasks) {
        externalTaskIds.add(task.getId());
    }
    externalTaskIds.add("nonExistingExternalTaskId");
    try {
        externalTaskService.setRetries(externalTaskIds, 10);
        fail("exception expected");
    } catch (NotFoundException e) {
        Assert.assertThat(e.getMessage(), containsString("Cannot find external task with id nonExistingExternalTaskId"));
    }
}
Also used : ArrayList(java.util.ArrayList) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Test(org.junit.Test)

Aggregations

NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)44 Test (org.junit.Test)20 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)17 NotValidException (org.camunda.bpm.engine.exception.NotValidException)17 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)17 RestException (org.camunda.bpm.engine.rest.exception.RestException)17 Matchers.anyString (org.mockito.Matchers.anyString)15 HashMap (java.util.HashMap)11 CaseService (org.camunda.bpm.engine.CaseService)9 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)9 CaseExecutionCommandBuilder (org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder)8 InputStream (java.io.InputStream)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 RepositoryService (org.camunda.bpm.engine.RepositoryService)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 FileNotFoundException (java.io.FileNotFoundException)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2