Search in sources :

Example 21 with NotFoundException

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

the class CaseInstanceResourceImpl method terminate.

public void terminate(CaseExecutionTriggerDto triggerDto) {
    try {
        CaseService caseService = engine.getCaseService();
        CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseInstanceId);
        initializeCommand(commandBuilder, triggerDto, "terminate");
        commandBuilder.terminate();
    } catch (NotFoundException e) {
        throw createInvalidRequestException("terminate", Status.NOT_FOUND, e);
    } catch (NotValidException e) {
        throw createInvalidRequestException("terminate", Status.BAD_REQUEST, e);
    } catch (NotAllowedException e) {
        throw createInvalidRequestException("terminate", Status.FORBIDDEN, e);
    } catch (ProcessEngineException e) {
        throw createRestException("terminate", 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 22 with NotFoundException

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

the class CaseInstanceResourceImpl method complete.

public void complete(CaseExecutionTriggerDto triggerDto) {
    try {
        CaseService caseService = engine.getCaseService();
        CaseExecutionCommandBuilder commandBuilder = caseService.withCaseExecution(caseInstanceId);
        initializeCommand(commandBuilder, triggerDto, "complete");
        commandBuilder.complete();
    } catch (NotFoundException e) {
        throw createInvalidRequestException("complete", Status.NOT_FOUND, e);
    } catch (NotValidException e) {
        throw createInvalidRequestException("complete", Status.BAD_REQUEST, e);
    } catch (NotAllowedException e) {
        throw createInvalidRequestException("complete", Status.FORBIDDEN, e);
    } catch (ProcessEngineException e) {
        throw createRestException("complete", 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 23 with NotFoundException

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

the class AbstractGetDeployedFormCmd method execute.

public InputStream execute(final CommandContext commandContext) {
    checkAuthorization(commandContext);
    final FormData formData = getFormData(commandContext);
    String formKey = formData.getFormKey();
    if (formKey == null) {
        throw new BadUserRequestException("The form key is not set.");
    }
    final String resourceName = getResourceName(formKey);
    try {
        return commandContext.runWithoutAuthorization(new Callable<InputStream>() {

            @Override
            public InputStream call() throws Exception {
                return new GetDeploymentResourceCmd(formData.getDeploymentId(), resourceName).execute(commandContext);
            }
        });
    } catch (DeploymentResourceNotFoundException e) {
        throw new NotFoundException("The form with the resource name '" + resourceName + "' cannot be found in deployment.", e);
    }
}
Also used : FormData(org.camunda.bpm.engine.form.FormData) DeploymentResourceNotFoundException(org.camunda.bpm.engine.exception.DeploymentResourceNotFoundException) InputStream(java.io.InputStream) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) DeploymentResourceNotFoundException(org.camunda.bpm.engine.exception.DeploymentResourceNotFoundException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) DeploymentResourceNotFoundException(org.camunda.bpm.engine.exception.DeploymentResourceNotFoundException)

Example 24 with NotFoundException

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

the class SetExternalTasksRetriesTest method shouldFailForNonExistingExternalTaskIdAsync.

@Test
public void shouldFailForNonExistingExternalTaskIdAsync() {
    List<ExternalTask> externalTasks = externalTaskService.createExternalTaskQuery().list();
    ArrayList<String> externalTaskIds = new ArrayList<String>();
    for (ExternalTask task : externalTasks) {
        externalTaskIds.add(task.getId());
    }
    externalTaskIds.add("nonExistingExternalTaskId");
    Batch batch = externalTaskService.setRetriesAsync(externalTaskIds, null, 10);
    try {
        executeSeedAndBatchJobs(batch);
        fail("exception expected");
    } catch (NotFoundException e) {
        Assert.assertThat(e.getMessage(), containsString("Cannot find external task with id nonExistingExternalTaskId"));
    }
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) 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)

Example 25 with NotFoundException

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

the class RedeploymentTest method testRedeployUnexistingDeploymentResource.

public void testRedeployUnexistingDeploymentResource() {
    // given
    BpmnModelInstance model = createProcessWithServiceTask(PROCESS_KEY);
    Deployment deployment = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_NAME, model).deploy();
    try {
        // when
        repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResourceByName(deployment.getId(), "not-existing-resource.bpmn").deploy();
        fail("It should not be possible to re-deploy a not existing deployment resource");
    } catch (NotFoundException e) {
    // then
    // expected
    }
    try {
        // when
        repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResourcesByName(deployment.getId(), Arrays.asList("not-existing-resource.bpmn")).deploy();
        fail("It should not be possible to re-deploy a not existing deployment resource");
    } catch (NotFoundException e) {
    // then
    // expected
    }
    try {
        // when
        repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResourceById(deployment.getId(), "not-existing-resource-id").deploy();
        fail("It should not be possible to re-deploy a not existing deployment resource");
    } catch (NotFoundException e) {
    // then
    // expected
    }
    try {
        // when
        repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResourcesById(deployment.getId(), Arrays.asList("not-existing-resource-id")).deploy();
        fail("It should not be possible to re-deploy a not existing deployment resource");
    } catch (NotFoundException e) {
    // then
    // expected
    }
    deleteDeployments(deployment);
}
Also used : ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) Deployment(org.camunda.bpm.engine.repository.Deployment) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

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