Example #1
0
  public static void directoryListJSON(
      IVResource dir, String path, User user, JSONWriter jsonWriter) {
    if (dir.exists()) {
      IVResource[] listFiles = dir.listFiles();
      for (int j = 0; j < listFiles.length; j++) {
        IVResource member = listFiles[j];
        if (Resource.isHidden(member)) continue;

        jsonWriter
            .startObject()
            .addField("name", member.getName())
            .addField("isDir", member.isDirectory())
            .endObject();
      }
      List links = user.getLinks().findLinks(path);
      for (Iterator iterator = links.iterator(); iterator.hasNext(); ) {
        Link link = (Link) iterator.next();
        jsonWriter
            .startObject()
            .addField("name", link.name)
            .addField("isDir", true)
            .addField("link", link.location)
            .endObject();
      }
    }
    /*
    if (path.equals(".") || path.length()==0 || jsonWriter.isEmpty())
    {
    	ServerManager.getServerManger().getLibraryManager().listFiles(path,jsonWriter);

    }
    */

  }
Example #2
0
  public IVResource[] getParents() {
    Vector parents = new Vector();

    IVResource parent = this.getParent();
    while (parent != null) {
      parents.add(0, parent);
      parent = parent.getParent();
    }
    if (this.isDirectory()) parents.add(this);
    return (IVResource[]) parents.toArray(new IVResource[parents.size()]);
  }
Example #3
0
  public static void copyDirectory(IVResource source, IVResource destination, boolean recurse) {
    IVResource[] list = source.listFiles();

    for (int i = 0; i < list.length; i++) {
      destination.mkdir();
      IVResource r = destination.create(list[i].getName());
      if (list[i].isDirectory()) {
        r.mkdir();
        if (recurse) {
          VResourceUtils.copyDirectory(list[i], r, recurse);
        }
      } else {
        try {
          if (!r.exists()) {
            r.createNewInstance();
            VResourceUtils.copyFile(list[i], r);
            r.flushWorkingCopy();
          }
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
  }
Example #4
0
 public boolean isHidden(IVResource file) {
   IPath path = new Path(file.getPath());
   for (int i = 0; i < this.filterDirs.length; i++) {
     IPath fp = new Path(filterDirs[i]);
     if (fp.isPrefixOf(path)) return true;
   }
   return false;
 }
Example #5
0
  public static void copyFile(IVResource src, IVResource dest) throws IOException {
    InputStream in = null;
    OutputStream out = null;
    try {
      in = src.getInputStreem();
      out = dest.getOutputStreem();

      byte[] buf = new byte[1024];
      int len;
      while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
      }
      dest.flushWorkingCopy();
    } finally {
      if (in != null) in.close();
      if (out != null) out.close();
    }
  }
Example #6
0
 @Override
 public boolean isDirectory() {
   // TODO Auto-generated method stub
   return original.isDirectory();
 }
Example #7
0
 @Override
 public boolean mkdir() {
   // TODO Auto-generated method stub
   return original.mkdir();
 }
Example #8
0
 @Override
 public String getPath() {
   return original.getPath();
 }
Example #9
0
 @Override
 public URI getURI() throws URISyntaxException {
   // TODO Auto-generated method stub
   return original.getURI();
 }
Example #10
0
 @Override
 public IVResource getParent() {
   return original.getParent();
 }
Example #11
0
 @Override
 public IVResource[] getParents() {
   // TODO Auto-generated method stub
   return original.getParents();
 }
Example #12
0
 @Override
 public IVResource get(String childName) {
   return original.get(childName);
 }
Example #13
0
 @Override
 public IVResource create(String path) {
   // TODO Auto-generated method stub
   return original.create(path);
 }
Example #14
0
 @Override
 public IVResource[] find(String path) {
   // TODO Auto-generated method stub
   return original.find(path);
 }
Example #15
0
 @Override
 public void removeWorkingCopy() {
   original.removeWorkingCopy();
 }
Example #16
0
 @Override
 public boolean exists() {
   // TODO Auto-generated method stub
   return original.exists();
 }
Example #17
0
 @Override
 public boolean delete() {
   // TODO Auto-generated method stub
   return original.delete();
 }
Example #18
0
 @Override
 public void createNewInstance() throws IOException {
   original.createNewInstance();
 }
Example #19
0
 @Override
 public IVResource[] listFiles() {
   // TODO Auto-generated method stub
   return original.listFiles();
 }
Example #20
0
 @Override
 public String getName() {
   return original.getName();
 }
Example #21
0
 @Override
 public void flushWorkingCopy() {
   original.flushWorkingCopy();
 }
Example #22
0
 @Override
 public void add(IVResource v) {
   original.add(v);
 }