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);
}
}
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;
}
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);
}
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);
}
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
}
}
Aggregations