@Override
  public void enumerateKnownFiles(ICollection collection, List<String> dsDefinitions)
      throws IOException {
    if (collection.exists()) {
      List<IResource> resources = collection.getResources();
      for (Iterator<IResource> iterator = resources.iterator(); iterator.hasNext(); ) {
        IResource resource = iterator.next();
        if (resource != null && resource.getName() != null) {
          if (resource.getName().endsWith(EXTENSION_TABLE)
              || resource.getName().endsWith(EXTENSION_VIEW)) {
            //						# 177
            //						String fullPath = collection.getPath().substring(
            //								this.location.length())
            //								+ IRepository.SEPARATOR + resource.getName();
            String fullPath = resource.getPath();
            dsDefinitions.add(fullPath);
          }
        }
      }

      List<ICollection> collections = collection.getCollections();
      for (Iterator<ICollection> iterator = collections.iterator(); iterator.hasNext(); ) {
        ICollection subCollection = iterator.next();
        enumerateKnownFiles(subCollection, dsDefinitions);
      }
    }
  }
 private List<String> listSettingsByRoot(String root, String path) throws IOException {
   String normalizedPath = normalizePath(path);
   String collectionPath = root + normalizedPath;
   if ((repository != null) && repository.hasCollection(collectionPath)) {
     ICollection collection = repository.getCollection(collectionPath);
     return collection.getResourcesNames();
   }
   return new ArrayList<String>();
 }
示例#3
0
  public static void copyCollectionToDirectory(
      ICollection source, File tempDirectory, String... roots) throws IOException {
    if (!source.exists()) {
      return;
    }
    for (IEntity entity : source.getChildren()) {
      if (entity instanceof ICollection) {
        copyCollectionToDirectory((ICollection) entity, tempDirectory, roots);
      }
      if (entity instanceof IResource) {
        String path = entity.getParent().getPath();
        StringBuilder resourceDirectory = new StringBuilder();
        resourceDirectory.append(path);
        resourceDirectory.append(SLASH);

        String directoryPath = resourceDirectory.toString();
        for (int i = 0; i < roots.length; i++) {
          if (directoryPath.startsWith(roots[i])) {
            directoryPath = directoryPath.substring(roots[i].length());
            break;
          }
        }
        new File(tempDirectory, directoryPath).mkdirs();

        String resourcePath = entity.getPath();
        for (int i = 0; i < roots.length; i++) {
          if (resourcePath.startsWith(roots[i])) {
            resourcePath = resourcePath.substring(roots[i].length());
            break;
          }
        }
        InputStream in = new ByteArrayInputStream(((IResource) entity).getContent());
        File outputFile = new File(tempDirectory, resourcePath);

        FileOutputStream out = new FileOutputStream(outputFile);
        IOUtils.copy(in, out);

        in.close();
        out.flush();
        out.close();
      }
    }
  }