Search in sources :

Example 6 with DeploymentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity in project camunda-bpm-platform by camunda.

the class ResourceDefinitionCache method resolveDefinition.

public T resolveDefinition(T definition) {
    String definitionId = definition.getId();
    String deploymentId = definition.getDeploymentId();
    T cachedDefinition = cache.get(definitionId);
    if (cachedDefinition == null) {
        synchronized (this) {
            cachedDefinition = cache.get(definitionId);
            if (cachedDefinition == null) {
                DeploymentEntity deployment = Context.getCommandContext().getDeploymentManager().findDeploymentById(deploymentId);
                deployment.setNew(false);
                cacheDeployer.deployOnlyGivenResourcesOfDeployment(deployment, definition.getResourceName(), definition.getDiagramResourceName());
                cachedDefinition = cache.get(definitionId);
            }
        }
        checkInvalidDefinitionWasCached(deploymentId, definitionId, cachedDefinition);
    }
    if (cachedDefinition != null) {
        cachedDefinition.updateModifiableFieldsFromEntity(definition);
    }
    return cachedDefinition;
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity)

Example 7 with DeploymentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity in project camunda-bpm-platform by camunda.

the class DeployCmd method doExecute.

protected DeploymentWithDefinitions doExecute(final CommandContext commandContext) {
    DeploymentManager deploymentManager = commandContext.getDeploymentManager();
    Set<String> deploymentIds = getAllDeploymentIds(deploymentBuilder);
    if (!deploymentIds.isEmpty()) {
        String[] deploymentIdArray = deploymentIds.toArray(new String[deploymentIds.size()]);
        List<DeploymentEntity> deployments = deploymentManager.findDeploymentsByIds(deploymentIdArray);
        ensureDeploymentsWithIdsExists(deploymentIds, deployments);
    }
    checkCreateAndReadDeployments(commandContext, deploymentIds);
    // set deployment name if it should retrieved from an existing deployment
    String nameFromDeployment = deploymentBuilder.getNameFromDeployment();
    setDeploymentName(nameFromDeployment, deploymentBuilder, commandContext);
    // get resources to re-deploy
    List<ResourceEntity> resources = getResources(deploymentBuilder, commandContext);
    // .. and add them the builder
    addResources(resources, deploymentBuilder);
    Collection<String> resourceNames = deploymentBuilder.getResourceNames();
    if (resourceNames == null || resourceNames.isEmpty()) {
        throw new NotValidException("No deployment resources contained to deploy.");
    }
    // perform deployment
    DeploymentWithDefinitions deployment = commandContext.runWithoutAuthorization(new Callable<DeploymentWithDefinitions>() {

        @Override
        public DeploymentWithDefinitions call() throws Exception {
            acquireExclusiveLock(commandContext);
            DeploymentEntity deployment = initDeployment();
            Map<String, ResourceEntity> resourcesToDeploy = resolveResourcesToDeploy(commandContext, deployment);
            Map<String, ResourceEntity> resourcesToIgnore = new HashMap<String, ResourceEntity>(deployment.getResources());
            resourcesToIgnore.keySet().removeAll(resourcesToDeploy.keySet());
            if (!resourcesToDeploy.isEmpty()) {
                LOG.debugCreatingNewDeployment();
                deployment.setResources(resourcesToDeploy);
                deploy(deployment);
            } else {
                LOG.usingExistingDeployment();
                deployment = getExistingDeployment(commandContext, deployment.getName());
            }
            scheduleProcessDefinitionActivation(commandContext, deployment);
            if (deploymentBuilder instanceof ProcessApplicationDeploymentBuilder) {
                // for process application deployments, job executor registration is managed by
                // process application manager
                Set<String> processesToRegisterFor = retrieveProcessKeysFromResources(resourcesToIgnore);
                ProcessApplicationRegistration registration = registerProcessApplication(commandContext, deployment, processesToRegisterFor);
                return new ProcessApplicationDeploymentImpl(deployment, registration);
            } else {
                registerWithJobExecutor(commandContext, deployment);
            }
            return deployment;
        }
    });
    createUserOperationLog(deploymentBuilder, deployment, commandContext);
    return deployment;
}
Also used : ProcessApplicationRegistration(org.camunda.bpm.application.ProcessApplicationRegistration) NotValidException(org.camunda.bpm.engine.exception.NotValidException) Set(java.util.Set) HashSet(java.util.HashSet) DeploymentManager(org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager) NotValidException(org.camunda.bpm.engine.exception.NotValidException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) ProcessApplicationDeploymentImpl(org.camunda.bpm.engine.impl.persistence.entity.ProcessApplicationDeploymentImpl) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with DeploymentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity in project camunda-bpm-platform by camunda.

the class DeployCmd method ensureDeploymentsWithIdsExists.

protected void ensureDeploymentsWithIdsExists(Set<String> expected, List<DeploymentEntity> actual) {
    Map<String, DeploymentEntity> deploymentMap = new HashMap<String, DeploymentEntity>();
    for (DeploymentEntity deployment : actual) {
        deploymentMap.put(deployment.getId(), deployment);
    }
    List<String> missingDeployments = getMissingElements(expected, deploymentMap);
    if (!missingDeployments.isEmpty()) {
        StringBuilder builder = new StringBuilder();
        builder.append("The following deployments are not found by id: ");
        boolean first = true;
        for (String missingDeployment : missingDeployments) {
            if (!first) {
                builder.append(", ");
            } else {
                first = false;
            }
            builder.append(missingDeployment);
        }
        throw new NotFoundException(builder.toString());
    }
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) HashMap(java.util.HashMap) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException)

Example 9 with DeploymentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity in project camunda-bpm-platform by camunda.

the class CaseHandlerTest method setUp.

@Before
public void setUp() {
    context = new CmmnHandlerContext();
    DeploymentEntity deployment = new DeploymentEntity();
    deployment.setId("aDeploymentId");
    context.setDeployment(deployment);
    context.setModel(modelInstance);
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) CmmnHandlerContext(org.camunda.bpm.engine.impl.cmmn.handler.CmmnHandlerContext) Before(org.junit.Before)

Example 10 with DeploymentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity in project camunda-bpm-platform by camunda.

the class CmmnTransformerTest method setup.

@Before
public void setup() {
    CmmnTransformer transformerWrapper = new CmmnTransformer(null, new DefaultCmmnElementHandlerRegistry(), null);
    transformer = new CmmnTransform(transformerWrapper);
    deployment = new DeploymentEntity();
    deployment.setId("aDeploymentId");
    transformer.setDeployment(deployment);
    modelInstance = Cmmn.createEmptyModel();
    definitions = modelInstance.newInstance(Definitions.class);
    definitions.setTargetNamespace("http://camunda.org/examples");
    modelInstance.setDefinitions(definitions);
    caseDefinition = createElement(definitions, "aCaseDefinition", Case.class);
    casePlanModel = createElement(caseDefinition, "aCasePlanModel", CasePlanModel.class);
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) Definitions(org.camunda.bpm.model.cmmn.instance.Definitions) DefaultCmmnElementHandlerRegistry(org.camunda.bpm.engine.impl.cmmn.handler.DefaultCmmnElementHandlerRegistry) CmmnTransformer(org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransformer) CmmnTransform(org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransform) Case(org.camunda.bpm.model.cmmn.instance.Case) Before(org.junit.Before)

Aggregations

DeploymentEntity (org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity)11 DeploymentManager (org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager)3 ResourceEntity (org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)2 NotValidException (org.camunda.bpm.engine.exception.NotValidException)2 Before (org.junit.Before)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ProcessApplicationRegistration (org.camunda.bpm.application.ProcessApplicationRegistration)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 CmmnHandlerContext (org.camunda.bpm.engine.impl.cmmn.handler.CmmnHandlerContext)1 DefaultCmmnElementHandlerRegistry (org.camunda.bpm.engine.impl.cmmn.handler.DefaultCmmnElementHandlerRegistry)1 CmmnTransform (org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransform)1 CmmnTransformer (org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransformer)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 ProcessApplicationDeploymentImpl (org.camunda.bpm.engine.impl.persistence.entity.ProcessApplicationDeploymentImpl)1