protected void handleArchive(
     File file, String paResourceRootPath, Map<String, byte[]> resourceMap) {
   try {
     ZipFile zipFile = new ZipFile(file);
     Enumeration<? extends ZipEntry> entries = zipFile.entries();
     while (entries.hasMoreElements()) {
       ZipEntry zipEntry = (ZipEntry) entries.nextElement();
       String processFileName = zipEntry.getName();
       if (ProcessApplicationScanningUtil.isDeployable(processFileName)
           && isBelowPath(processFileName, paResourceRootPath)) {
         addResource(
             zipFile.getInputStream(zipEntry), resourceMap, file.getName() + "!", processFileName);
         // find diagram(s) for process
         Enumeration<? extends ZipEntry> entries2 = zipFile.entries();
         while (entries2.hasMoreElements()) {
           ZipEntry zipEntry2 = (ZipEntry) entries2.nextElement();
           String diagramFileName = zipEntry2.getName();
           if (ProcessApplicationScanningUtil.isDiagramForProcess(
               diagramFileName, processFileName)) {
             addResource(
                 zipFile.getInputStream(zipEntry),
                 resourceMap,
                 file.getName() + "!",
                 diagramFileName);
           }
         }
       }
     }
     zipFile.close();
   } catch (IOException e) {
     throw new ProcessEngineException("IOException while scanning archive '" + file + "'.", e);
   }
 }
  protected void handleDirectory(
      File directory,
      String rootPath,
      String localPath,
      String paResourceRootPath,
      boolean isPaLocal,
      Map<String, byte[]> resourceMap) {
    File[] paths = directory.listFiles();

    String currentPathSegment = localPath;
    if (localPath != null && localPath.length() > 0) {
      if (localPath.indexOf('/') > 0) {
        currentPathSegment = localPath.substring(0, localPath.indexOf('/'));
        localPath = localPath.substring(localPath.indexOf('/') + 1, localPath.length());
      } else {
        localPath = null;
      }
    }

    for (File path : paths) {

      if (isPaLocal // if it is not PA-local, we have already used the classloader to specify the
                    // root path explicitly.
          && currentPathSegment != null
          && currentPathSegment.length() > 0) {

        if (path.isDirectory()) {
          // only descend into directory, if below resource root:
          if (path.getName().equals(currentPathSegment)) {
            handleDirectory(path, rootPath, localPath, paResourceRootPath, isPaLocal, resourceMap);
          }
        }

      } else { // at resource root or below -> continue scanning
        String processFileName = path.getPath();
        if (!path.isDirectory() && ProcessApplicationScanningUtil.isDeployable(processFileName)) {
          addResource(path, resourceMap, paResourceRootPath, processFileName.replace(rootPath, ""));
          // find diagram(s) for process
          for (File file : paths) {
            String diagramFileName = file.getPath();
            if (!path.isDirectory()
                && ProcessApplicationScanningUtil.isDiagramForProcess(
                    diagramFileName, processFileName)) {
              addResource(
                  file, resourceMap, paResourceRootPath, diagramFileName.replace(rootPath, ""));
            }
          }
        } else if (path.isDirectory()) {
          handleDirectory(path, rootPath, localPath, paResourceRootPath, isPaLocal, resourceMap);
        }
      }
    }
  }