Search in sources :

Example 1 with DeploymentManager

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

the class DeployCmd method getResourcesByDeploymentId.

protected List<ResourceEntity> getResourcesByDeploymentId(Set<String> deploymentIds, CommandContext commandContext) {
    List<ResourceEntity> result = new ArrayList<ResourceEntity>();
    if (!deploymentIds.isEmpty()) {
        DeploymentManager deploymentManager = commandContext.getDeploymentManager();
        for (String deploymentId : deploymentIds) {
            DeploymentEntity deployment = deploymentManager.findDeploymentById(deploymentId);
            Map<String, ResourceEntity> resources = deployment.getResources();
            Collection<ResourceEntity> values = resources.values();
            result.addAll(values);
        }
    }
    return result;
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) DeploymentManager(org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity) ArrayList(java.util.ArrayList)

Example 2 with DeploymentManager

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

the class DeployCmd method setDeploymentName.

protected void setDeploymentName(String deploymentId, DeploymentBuilderImpl deploymentBuilder, CommandContext commandContext) {
    if (deploymentId != null && !deploymentId.isEmpty()) {
        DeploymentManager deploymentManager = commandContext.getDeploymentManager();
        DeploymentEntity deployment = deploymentManager.findDeploymentById(deploymentId);
        deploymentBuilder.getDeployment().setName(deployment.getName());
    }
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) DeploymentManager(org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager)

Example 3 with DeploymentManager

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager 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)

Aggregations

DeploymentEntity (org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity)3 DeploymentManager (org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager)3 ResourceEntity (org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ProcessApplicationRegistration (org.camunda.bpm.application.ProcessApplicationRegistration)1 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)1 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1 ProcessApplicationDeploymentImpl (org.camunda.bpm.engine.impl.persistence.entity.ProcessApplicationDeploymentImpl)1