Search in sources :

Example 11 with ProcessApplicationInfo

use of org.camunda.bpm.application.ProcessApplicationInfo in project camunda-bpm-platform by camunda.

the class ApplicationContextPathUtil method getApplicationPathForDeployment.

public static String getApplicationPathForDeployment(ProcessEngine engine, String deploymentId) {
    // get the name of the process application that made the deployment
    String processApplicationName = null;
    IdentityService identityService = engine.getIdentityService();
    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    try {
        identityService.clearAuthentication();
        processApplicationName = engine.getManagementService().getProcessApplicationForDeployment(deploymentId);
    } finally {
        identityService.setAuthentication(currentAuthentication);
    }
    if (processApplicationName == null) {
        // no a process application deployment
        return null;
    } else {
        ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
        ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(processApplicationName);
        return processApplicationInfo.getProperties().get(ProcessApplicationInfo.PROP_SERVLET_CONTEXT_PATH);
    }
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) Authentication(org.camunda.bpm.engine.impl.identity.Authentication) ProcessApplicationService(org.camunda.bpm.ProcessApplicationService) ProcessApplicationInfo(org.camunda.bpm.application.ProcessApplicationInfo)

Example 12 with ProcessApplicationInfo

use of org.camunda.bpm.application.ProcessApplicationInfo in project camunda-bpm-platform by camunda.

the class InjectionUtil method resolveInjections.

public static Object[] resolveInjections(DeploymentOperation operationContext, 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(getDefaultProcessEngine(operationContext));
                injectionResolved = true;
            } else // support injection of the ProcessApplicationInfo
            if (ProcessApplicationInfo.class.isAssignableFrom(parameterClass)) {
                parameters.add(getProcessApplicationInfo(operationContext));
                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(getProcessEngines(operationContext));
                injectionResolved = true;
            }
        }
        if (!injectionResolved) {
            throw LOG.unsuppoertedParameterType(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)

Example 13 with ProcessApplicationInfo

use of org.camunda.bpm.application.ProcessApplicationInfo in project camunda-bpm-platform by camunda.

the class ProcessApplicationServiceTest method testProcessApplicationsDeployed.

@Test
@OperateOnDeployment("test1")
public void testProcessApplicationsDeployed() {
    ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
    Set<String> processApplicationNames = processApplicationService.getProcessApplicationNames();
    // check if the new applications are deployed with allowed names
    processApplicationNames.retainAll(Arrays.asList(new String[] { "test1", "test2", "/test1", "/test2" }));
    Assert.assertEquals(2, processApplicationNames.size());
    for (String appName : processApplicationNames) {
        ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(appName);
        Assert.assertNotNull(processApplicationInfo);
        Assert.assertNotNull(processApplicationInfo.getName());
        Assert.assertEquals(1, processApplicationInfo.getDeploymentInfo().size());
    }
}
Also used : ProcessApplicationService(org.camunda.bpm.ProcessApplicationService) ProcessApplicationInfo(org.camunda.bpm.application.ProcessApplicationInfo) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 14 with ProcessApplicationInfo

use of org.camunda.bpm.application.ProcessApplicationInfo in project camunda-bpm-platform by camunda.

the class TestWarDeploymentResumePreviousOnDeploymentName method testDeployProcessArchive.

@Test
@OperateOnDeployment(value = PA2)
public void testDeployProcessArchive() {
    assertThat(processEngine, is(notNullValue()));
    RepositoryService repositoryService = processEngine.getRepositoryService();
    // since we have two processes deployed for PA2 we gotta check that both are present
    long count = repositoryService.createProcessDefinitionQuery().processDefinitionKey("testDeployProcessArchive").count();
    assertThat(count, is(1L));
    count = repositoryService.createProcessDefinitionQuery().processDefinitionKey("testProcess").count();
    assertThat(count, is(1L));
    // validate registrations:
    ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
    Set<String> processApplicationNames = processApplicationService.getProcessApplicationNames();
    // we have two PAs, one from the first deployment and one from the second
    // and only one (the second) is allowed to have two deployments
    boolean resumedRegistrationFound = false;
    for (String paName : processApplicationNames) {
        ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(paName);
        List<ProcessApplicationDeploymentInfo> deploymentInfo = processApplicationInfo.getDeploymentInfo();
        if (deploymentInfo.size() == 2) {
            if (resumedRegistrationFound) {
                fail("Cannot have two registrations");
            }
            resumedRegistrationFound = true;
        }
    }
    assertThat("Previous version of the deployment was not resumed", resumedRegistrationFound, is(true));
}
Also used : ProcessApplicationDeploymentInfo(org.camunda.bpm.application.ProcessApplicationDeploymentInfo) ProcessApplicationService(org.camunda.bpm.ProcessApplicationService) ProcessApplicationInfo(org.camunda.bpm.application.ProcessApplicationInfo) RepositoryService(org.camunda.bpm.engine.RepositoryService) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 15 with ProcessApplicationInfo

use of org.camunda.bpm.application.ProcessApplicationInfo in project camunda-bpm-platform by camunda.

the class TestWarDeploymentResumePreviousOnProcessDefinitionKey method testDeployProcessArchive.

@Test
@OperateOnDeployment(value = PA2)
public void testDeployProcessArchive() {
    assertThat(processEngine, is(notNullValue()));
    RepositoryService repositoryService = processEngine.getRepositoryService();
    long count = repositoryService.createProcessDefinitionQuery().processDefinitionKey("testDeployProcessArchive").count();
    assertThat(count, is(2L));
    // validate registrations:
    ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService();
    Set<String> processApplicationNames = processApplicationService.getProcessApplicationNames();
    // we have two PAs, one from the first deployment and one from the second and only one (the second) is allowed to have two deployments
    boolean resumedRegistrationFound = false;
    for (String paName : processApplicationNames) {
        ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(paName);
        List<ProcessApplicationDeploymentInfo> deploymentInfo = processApplicationInfo.getDeploymentInfo();
        if (deploymentInfo.size() == 2) {
            if (resumedRegistrationFound) {
                fail("Cannot have two registrations");
            }
            resumedRegistrationFound = true;
        }
    }
    assertThat("Previous version of the deployment was not resumed", resumedRegistrationFound, is(true));
}
Also used : ProcessApplicationDeploymentInfo(org.camunda.bpm.application.ProcessApplicationDeploymentInfo) ProcessApplicationService(org.camunda.bpm.ProcessApplicationService) ProcessApplicationInfo(org.camunda.bpm.application.ProcessApplicationInfo) RepositoryService(org.camunda.bpm.engine.RepositoryService) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Aggregations

ProcessApplicationInfo (org.camunda.bpm.application.ProcessApplicationInfo)15 ProcessApplicationService (org.camunda.bpm.ProcessApplicationService)10 Test (org.junit.Test)8 ProcessApplicationDeploymentInfo (org.camunda.bpm.application.ProcessApplicationDeploymentInfo)7 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)7 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)7 RepositoryService (org.camunda.bpm.engine.RepositoryService)6 ArrayList (java.util.ArrayList)4 RuntimeContainerDelegate (org.camunda.bpm.container.RuntimeContainerDelegate)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 Matchers.anyString (org.mockito.Matchers.anyString)3 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 Response (com.jayway.restassured.response.Response)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 Map (java.util.Map)1 PlatformServiceContainer (org.camunda.bpm.container.impl.spi.PlatformServiceContainer)1