use of org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity in project camunda-bpm-platform by camunda.
the class DeployCmd method addResources.
protected void addResources(List<ResourceEntity> resources, DeploymentBuilderImpl deploymentBuilder) {
DeploymentEntity deployment = deploymentBuilder.getDeployment();
Map<String, ResourceEntity> existingResources = deployment.getResources();
for (ResourceEntity resource : resources) {
String resourceName = resource.getName();
if (existingResources != null && existingResources.containsKey(resourceName)) {
String message = String.format("Cannot add resource with id '%s' and name '%s' from " + "deployment with id '%s' to new deployment because the new deployment contains " + "already a resource with same name.", resource.getId(), resourceName, resource.getDeploymentId());
throw new NotValidException(message);
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(resource.getBytes());
deploymentBuilder.addInputStream(resourceName, inputStream);
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity in project camunda-bpm-platform by camunda.
the class DeployCmd method getResourcesByName.
protected List<ResourceEntity> getResourcesByName(Map<String, Set<String>> resourcesByName, CommandContext commandContext) {
List<ResourceEntity> result = new ArrayList<ResourceEntity>();
ResourceManager resourceManager = commandContext.getResourceManager();
for (String deploymentId : resourcesByName.keySet()) {
Set<String> resourceNames = resourcesByName.get(deploymentId);
String[] resourceNameArray = resourceNames.toArray(new String[resourceNames.size()]);
List<ResourceEntity> resources = resourceManager.findResourceByDeploymentIdAndResourceNames(deploymentId, resourceNameArray);
ensureResourcesWithNamesExist(deploymentId, resourceNames, resources);
result.addAll(resources);
}
return result;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity in project camunda-bpm-platform by camunda.
the class DeployCmd method resolveResourcesToDeploy.
protected Map<String, ResourceEntity> resolveResourcesToDeploy(CommandContext commandContext, DeploymentEntity deployment) {
Map<String, ResourceEntity> resourcesToDeploy = new HashMap<String, ResourceEntity>();
Map<String, ResourceEntity> containedResources = deployment.getResources();
if (deploymentBuilder.isDuplicateFilterEnabled()) {
String source = deployment.getSource();
if (source == null || source.isEmpty()) {
source = ProcessApplicationDeployment.PROCESS_APPLICATION_DEPLOYMENT_SOURCE;
}
Map<String, ResourceEntity> existingResources = commandContext.getResourceManager().findLatestResourcesByDeploymentName(deployment.getName(), containedResources.keySet(), source, deployment.getTenantId());
for (ResourceEntity deployedResource : containedResources.values()) {
String resourceName = deployedResource.getName();
ResourceEntity existingResource = existingResources.get(resourceName);
if (existingResource == null || existingResource.isGenerated() || resourcesDiffer(deployedResource, existingResource)) {
if (deploymentBuilder.isDeployChangedOnly()) {
resourcesToDeploy.put(resourceName, deployedResource);
} else {
// all resources should be deployed
resourcesToDeploy = containedResources;
break;
}
}
}
} else {
resourcesToDeploy = containedResources;
}
return resourcesToDeploy;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity 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;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity in project camunda-bpm-platform by camunda.
the class DeployCmd method getResourcesById.
protected List<ResourceEntity> getResourcesById(Map<String, Set<String>> resourcesById, CommandContext commandContext) {
List<ResourceEntity> result = new ArrayList<ResourceEntity>();
ResourceManager resourceManager = commandContext.getResourceManager();
for (String deploymentId : resourcesById.keySet()) {
Set<String> resourceIds = resourcesById.get(deploymentId);
String[] resourceIdArray = resourceIds.toArray(new String[resourceIds.size()]);
List<ResourceEntity> resources = resourceManager.findResourceByDeploymentIdAndResourceIds(deploymentId, resourceIdArray);
ensureResourcesWithIdsExist(deploymentId, resourceIds, resources);
result.addAll(resources);
}
return result;
}
Aggregations