Search in sources :

Example 76 with NotValidException

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

the class DeployCmd method checkDuplicateResourceName.

protected void checkDuplicateResourceName(List<ResourceEntity> resources) {
    Map<String, ResourceEntity> resourceMap = new HashMap<String, ResourceEntity>();
    for (ResourceEntity resource : resources) {
        String name = resource.getName();
        ResourceEntity duplicate = resourceMap.get(name);
        if (duplicate != null) {
            String deploymentId = resource.getDeploymentId();
            if (!deploymentId.equals(duplicate.getDeploymentId())) {
                String message = String.format("The deployments with id '%s' and '%s' contain a resource with same name '%s'.", deploymentId, duplicate.getDeploymentId(), name);
                throw new NotValidException(message);
            }
        }
        resourceMap.put(name, resource);
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) HashMap(java.util.HashMap) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity)

Example 77 with NotValidException

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

the class SaveTaskCmd method execute.

public Void execute(CommandContext commandContext) {
    ensureNotNull("task", task);
    String operation;
    if (task.getRevision() == 0) {
        try {
            checkCreateTask(task, commandContext);
            task.insert(null);
            commandContext.getHistoricTaskInstanceManager().createHistoricTask(task);
            operation = UserOperationLogEntry.OPERATION_TYPE_CREATE;
            task.executeMetrics(Metrics.ACTIVTY_INSTANCE_START);
        } catch (NullValueException e) {
            throw new NotValidException(e.getMessage(), e);
        }
    } else {
        checkTaskAssign(task, commandContext);
        task.update();
        operation = UserOperationLogEntry.OPERATION_TYPE_UPDATE;
    }
    task.fireAuthorizationProvider();
    task.fireEvents();
    task.createHistoricTaskDetails(operation);
    return null;
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) NullValueException(org.camunda.bpm.engine.exception.NullValueException)

Example 78 with NotValidException

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

the class RedeploymentTest method testRedeployAndAddNewResourceWithSameName.

public void testRedeployAndAddNewResourceWithSameName() {
    // given
    BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY);
    Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-1").addModelInstance(RESOURCE_1_NAME, model1).deploy();
    // when
    BpmnModelInstance model2 = createProcessWithReceiveTask(PROCESS_2_KEY);
    try {
        repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-2").addModelInstance(RESOURCE_1_NAME, model2).addDeploymentResourceByName(deployment1.getId(), RESOURCE_1_NAME).deploy();
        fail("It should not be possible to deploy different resources with same name.");
    } catch (NotValidException e) {
    // expected
    }
    deleteDeployments(deployment1);
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) Deployment(org.camunda.bpm.engine.repository.Deployment) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 79 with NotValidException

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

the class RedeploymentTest method testRedeployFormDifferentDeploymentsSameResourceName.

public void testRedeployFormDifferentDeploymentsSameResourceName() {
    // given
    BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY);
    // first deployment
    Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-1").addModelInstance(RESOURCE_1_NAME, model1).deploy();
    // second deployment
    BpmnModelInstance model2 = createProcessWithReceiveTask(PROCESS_2_KEY);
    Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-2").addModelInstance(RESOURCE_1_NAME, model2).deploy();
    // when
    try {
        repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-3").addDeploymentResources(deployment1.getId()).addDeploymentResources(deployment2.getId()).deploy();
        fail("It should not be possible to deploy different resources with same name.");
    } catch (NotValidException e) {
    // expected
    }
    deleteDeployments(deployment1, deployment2);
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) Deployment(org.camunda.bpm.engine.repository.Deployment) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 80 with NotValidException

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

the class CaseDefinitionQueryTest method testQueryByInvalidVersion.

public void testQueryByInvalidVersion() {
    CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery();
    query.caseDefinitionVersion(3);
    verifyQueryResults(query, 0);
    try {
        query.caseDefinitionVersion(-1);
        fail();
    } catch (NotValidException e) {
    // Expected exception
    }
    try {
        query.caseDefinitionVersion(null);
        fail();
    } catch (NotValidException e) {
    // Expected exception
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery)

Aggregations

NotValidException (org.camunda.bpm.engine.exception.NotValidException)121 Test (org.junit.Test)28 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)24 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)24 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)18 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)17 Deployment (org.camunda.bpm.engine.test.Deployment)12 CaseDefinitionQuery (org.camunda.bpm.engine.repository.CaseDefinitionQuery)10 DecisionDefinitionQuery (org.camunda.bpm.engine.repository.DecisionDefinitionQuery)10 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)10 CaseService (org.camunda.bpm.engine.CaseService)9 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)9 RestException (org.camunda.bpm.engine.rest.exception.RestException)8 CaseExecutionCommandBuilder (org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder)8 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)8 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)6 HashMap (java.util.HashMap)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 InputStream (java.io.InputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3