Esempio n. 1
0
        protected internal virtual void handleDirectory(File directory, string rootPath, string localPath, string paResourceRootPath, bool isPaLocal, string[] additionalResourceSuffixes, IDictionary <string, sbyte[]> resourceMap)
        {
            File[] paths = directory.listFiles();

            string currentPathSegment = localPath;

            if (!string.ReferenceEquals(localPath, null) && localPath.Length > 0)
            {
                if (localPath.IndexOf('/') > 0)
                {
                    currentPathSegment = localPath.Substring(0, localPath.IndexOf('/'));
                    localPath          = StringHelper.SubstringSpecial(localPath, localPath.IndexOf('/') + 1, localPath.Length);
                }
                else
                {
                    localPath = null;
                }
            }

            foreach (File path in paths)
            {
                if (isPaLocal && !string.ReferenceEquals(currentPathSegment, null) && currentPathSegment.Length > 0)
                {
                    if (path.Directory)
                    {
                        // only descend into directory, if below resource root:
                        if (path.Name.Equals(currentPathSegment))
                        {
                            handleDirectory(path, rootPath, localPath, paResourceRootPath, isPaLocal, additionalResourceSuffixes, resourceMap);
                        }
                    }
                }
                else
                {   // at resource root or below -> continue scanning
                    string modelFileName = path.Path;
                    if (!path.Directory && ProcessApplicationScanningUtil.isDeployable(modelFileName, additionalResourceSuffixes))
                    {
                        // (1): "...\directory\sub_directory\process.bpmn" -> "sub_directory\process.bpmn"
                        // (2): "sub_directory\process.bpmn" -> "sub_directory/process.bpmn"
                        addResource(path, resourceMap, paResourceRootPath, modelFileName.Replace(rootPath, "").Replace("\\", "/"));
                        // find diagram(s) for process
                        foreach (File file in paths)
                        {
                            string diagramFileName = file.Path;
                            if (!path.Directory && ProcessApplicationScanningUtil.isDiagram(diagramFileName, modelFileName))
                            {
                                // (1): "...\directory\sub_directory\process.png" -> "sub_directory\process.png"
                                // (2): "sub_directory\process.png" -> "sub_directory/process.png"
                                addResource(file, resourceMap, paResourceRootPath, diagramFileName.Replace(rootPath, "").Replace("\\", "/"));
                            }
                        }
                    }
                    else if (path.Directory)
                    {
                        handleDirectory(path, rootPath, localPath, paResourceRootPath, isPaLocal, additionalResourceSuffixes, resourceMap);
                    }
                }
            }
        }
Esempio n. 2
0
        protected internal virtual void handleArchive(File file, string paResourceRootPath, string[] additionalResourceSuffixes, IDictionary <string, sbyte[]> resourceMap)
        {
            try
            {
                ZipFile zipFile = new ZipFile(file);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Iterator< ? extends java.util.zip.ZipEntry> entries = zipFile.entries();
                IEnumerator <ZipEntry> entries = zipFile.entries();
                while (entries.MoveNext())
                {
                    ZipEntry zipEntry      = entries.Current;
                    string   modelFileName = zipEntry.Name;
                    if (ProcessApplicationScanningUtil.isDeployable(modelFileName, additionalResourceSuffixes) && isBelowPath(modelFileName, paResourceRootPath))
                    {
                        string resourceName = modelFileName;
                        if (!string.ReferenceEquals(paResourceRootPath, null) && paResourceRootPath.Length > 0)
                        {
                            // "directory/sub_directory/process.bpmn" -> "sub_directory/process.bpmn"
                            resourceName = modelFileName.replaceFirst(paResourceRootPath, "");
                        }
                        addResource(zipFile.getInputStream(zipEntry), resourceMap, file.Name + "!", resourceName);
                        // find diagram(s) for process
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Iterator< ? extends java.util.zip.ZipEntry> entries2 = zipFile.entries();
                        IEnumerator <ZipEntry> entries2 = zipFile.entries();
                        while (entries2.MoveNext())
                        {
                            ZipEntry zipEntry2       = entries2.Current;
                            string   diagramFileName = zipEntry2.Name;
                            if (ProcessApplicationScanningUtil.isDiagram(diagramFileName, modelFileName))
                            {
                                if (!string.ReferenceEquals(paResourceRootPath, null) && paResourceRootPath.Length > 0)
                                {
                                    // "directory/sub_directory/process.png" -> "sub_directory/process.png"
                                    diagramFileName = diagramFileName.replaceFirst(paResourceRootPath, "");
                                }
                                addResource(zipFile.getInputStream(zipEntry), resourceMap, file.Name + "!", diagramFileName);
                            }
                        }
                    }
                }
                zipFile.close();
            }
            catch (IOException e)
            {
                throw LOG.exceptionWhileScanning(file.AbsolutePath, e);
            }
        }
Esempio n. 3
0
 public bool accepts(VirtualFile file)
 {
     return(file.File && ProcessApplicationScanningUtil.isDeployable(file.Name, additionalResourceSuffixes));
 }