Exemplo n.º 1
0
        private DeploymentBuilder extractDeploymentInformation(MultipartFormData payload)
        {
            DeploymentBuilder deploymentBuilder = ProcessEngine.RepositoryService.createDeployment();

            ISet <string> partNames = payload.PartNames;

            foreach (string name in partNames)
            {
                MultipartFormData.FormPart part = payload.getNamedPart(name);

                if (!RESERVED_KEYWORDS.Contains(name))
                {
                    string fileName = part.FileName;
                    if (!string.ReferenceEquals(fileName, null))
                    {
                        deploymentBuilder.addInputStream(part.FileName, new MemoryStream(part.BinaryContent));
                    }
                    else
                    {
                        throw new InvalidRequestException(Status.BAD_REQUEST, "No file name found in the deployment resource described by form parameter '" + fileName + "'.");
                    }
                }
            }

            MultipartFormData.FormPart deploymentName = payload.getNamedPart(DEPLOYMENT_NAME);
            if (deploymentName != null)
            {
                deploymentBuilder.name(deploymentName.TextContent);
            }

            MultipartFormData.FormPart deploymentSource = payload.getNamedPart(DEPLOYMENT_SOURCE);
            if (deploymentSource != null)
            {
                deploymentBuilder.source(deploymentSource.TextContent);
            }

            MultipartFormData.FormPart deploymentTenantId = payload.getNamedPart(TENANT_ID);
            if (deploymentTenantId != null)
            {
                deploymentBuilder.tenantId(deploymentTenantId.TextContent);
            }

            extractDuplicateFilteringForDeployment(payload, deploymentBuilder);
            return(deploymentBuilder);
        }
Exemplo n.º 2
0
        protected internal virtual void autoDeployResources(ProcessEngine processEngine)
        {
            if (deploymentResources != null && deploymentResources.Length > 0)
            {
                RepositoryService repositoryService = processEngine.RepositoryService;

                DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering(deployChangedOnly).name(deploymentName).tenantId(deploymentTenantId);

                foreach (Resource resource in deploymentResources)
                {
                    string resourceName = null;

                    if (resource is ContextResource)
                    {
                        resourceName = ((ContextResource)resource).PathWithinContext;
                    }
                    else if (resource is ByteArrayResource)
                    {
                        resourceName = resource.Description;
                    }
                    else
                    {
                        resourceName = getFileResourceName(resource);
                    }

                    try
                    {
                        if (resourceName.EndsWith(".bar", StringComparison.Ordinal) || resourceName.EndsWith(".zip", StringComparison.Ordinal) || resourceName.EndsWith(".jar", StringComparison.Ordinal))
                        {
                            deploymentBuilder.addZipInputStream(new ZipInputStream(resource.InputStream));
                        }
                        else
                        {
                            deploymentBuilder.addInputStream(resourceName, resource.InputStream);
                        }
                    }
                    catch (IOException e)
                    {
                        throw new ProcessEngineException("couldn't auto deploy resource '" + resource + "': " + e.Message, e);
                    }
                }

                deploymentBuilder.deploy();
            }
        }