Search in sources :

Example 51 with ProcessEngineException

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

the class MscRuntimeContainerDelegate method unregisterProcessEngine.

@SuppressWarnings("unchecked")
public void unregisterProcessEngine(ProcessEngine processEngine) {
    if (processEngine == null) {
        throw new ProcessEngineException("Cannot unregister process engine with Msc Runtime Container: process engine is 'null'");
    }
    ServiceName serviceName = ServiceNames.forManagedProcessEngine(processEngine.getName());
    // remove the service asynchronously
    ServiceController<ProcessEngine> service = (ServiceController<ProcessEngine>) serviceContainer.getService(serviceName);
    if (service != null && service.getService() instanceof MscManagedProcessEngine) {
        service.setMode(Mode.REMOVE);
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceController(org.jboss.msc.service.ServiceController) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 52 with ProcessEngineException

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

the class ProcessApplicationStartService method getInjections.

protected Object[] getInjections(Method lifecycleMethod) {
    final Type[] parameterTypes = lifecycleMethod.getGenericParameterTypes();
    final List<Object> parameters = new ArrayList<Object>();
    for (Type parameterType : parameterTypes) {
        boolean injectionResolved = false;
        if (parameterType instanceof Class) {
            Class<?> parameterClass = (Class<?>) parameterType;
            // support injection of the default process engine
            if (ProcessEngine.class.isAssignableFrom(parameterClass)) {
                parameters.add(defaultProcessEngineInjector.getValue());
                injectionResolved = true;
            } else // support injection of the ProcessApplicationInfo
            if (ProcessApplicationInfo.class.isAssignableFrom(parameterClass)) {
                parameters.add(processApplicationInfo);
                injectionResolved = true;
            }
        } else if (parameterType instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) parameterType;
            Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
            // support injection of List<ProcessEngine>
            if (actualTypeArguments.length == 1 && ProcessEngine.class.isAssignableFrom((Class<?>) actualTypeArguments[0])) {
                parameters.add(new ArrayList<ProcessEngine>(referencedProcessEngines));
                injectionResolved = true;
            }
        }
        if (!injectionResolved) {
            throw new ProcessEngineException("Unsupported parametertype " + parameterType);
        }
    }
    return parameters.toArray();
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ArrayList(java.util.ArrayList) ProcessApplicationInfo(org.camunda.bpm.application.ProcessApplicationInfo) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 53 with ProcessEngineException

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

the class ManagedProcessEngineMetadata method validate.

/**
 * validates the configuration and throws {@link ProcessEngineException}
 * if the configuration is invalid.
 */
public void validate() {
    StringBuilder validationErrorBuilder = new StringBuilder("Process engine configuration is invalid: \n");
    boolean isValid = true;
    if (datasourceJndiName == null || datasourceJndiName.isEmpty()) {
        isValid = false;
        validationErrorBuilder.append(" property 'datasource' cannot be null \n");
    }
    if (engineName == null || engineName.isEmpty()) {
        isValid = false;
        validationErrorBuilder.append(" property 'engineName' cannot be null \n");
    }
    for (int i = 0; i < pluginConfigurations.size(); i++) {
        ProcessEnginePluginXml pluginConfiguration = pluginConfigurations.get(i);
        if (pluginConfiguration.getPluginClass() == null || pluginConfiguration.getPluginClass().isEmpty()) {
            isValid = false;
            validationErrorBuilder.append(" property 'class' in plugin[" + i + "] cannot be null \n");
        }
    }
    if (!isValid) {
        throw new ProcessEngineException(validationErrorBuilder.toString());
    }
}
Also used : ProcessEnginePluginXml(org.camunda.bpm.container.impl.metadata.spi.ProcessEnginePluginXml) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 54 with ProcessEngineException

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

the class TaskVariableRestResourceInteractionTest method testDeleteVariableForNonExistingTaskId.

@Test
public void testDeleteVariableForNonExistingTaskId() {
    String variableKey = "aVariableKey";
    doThrow(new ProcessEngineException("Cannot find task with id " + NON_EXISTING_ID)).when(taskServiceMock).removeVariable(eq(NON_EXISTING_ID), eq(variableKey));
    given().pathParam("id", NON_EXISTING_ID).pathParam("varId", variableKey).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", is(RestException.class.getSimpleName())).body("message", is("Cannot delete task variable " + variableKey + ": Cannot find task with id " + NON_EXISTING_ID)).when().delete(SINGLE_TASK_DELETE_SINGLE_VARIABLE_URL);
}
Also used : RestException(org.camunda.bpm.engine.rest.exception.RestException) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Example 55 with ProcessEngineException

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

the class TaskVariableRestResourceInteractionTest method testPutVariableForNonExistingTaskId.

@Test
public void testPutVariableForNonExistingTaskId() {
    String variableKey = "aVariableKey";
    String variableValue = "aVariableValue";
    Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue);
    doThrow(new ProcessEngineException("Cannot find task with id " + NON_EXISTING_ID)).when(taskServiceMock).setVariable(eq(NON_EXISTING_ID), eq(variableKey), any());
    given().pathParam("id", NON_EXISTING_ID).pathParam("varId", variableKey).contentType(ContentType.JSON).body(variableJson).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", is(RestException.class.getSimpleName())).body("message", is("Cannot put task variable " + variableKey + ": Cannot find task with id " + NON_EXISTING_ID)).when().put(SINGLE_TASK_PUT_SINGLE_VARIABLE_URL);
}
Also used : RestException(org.camunda.bpm.engine.rest.exception.RestException) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Test(org.junit.Test)

Aggregations

ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)611 Test (org.junit.Test)185 Deployment (org.camunda.bpm.engine.test.Deployment)138 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)79 HashMap (java.util.HashMap)62 RestException (org.camunda.bpm.engine.rest.exception.RestException)62 Matchers.anyString (org.mockito.Matchers.anyString)60 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)57 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)47 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)41 Task (org.camunda.bpm.engine.task.Task)40 ArrayList (java.util.ArrayList)39 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)36 Matchers.containsString (org.hamcrest.Matchers.containsString)35 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)24 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)22 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)21 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)21 NotValidException (org.camunda.bpm.engine.exception.NotValidException)19 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)18