コード例 #1
0
 private List<Fileable> getChildren(Folder folder, String user, boolean usePwc) {
   List<Fileable> children = new ArrayList<Fileable>();
   for (String id : getIds()) {
     StoredObject obj = getObject(id);
     if (obj instanceof Fileable) {
       Fileable pathObj = (Fileable) obj;
       if ((null == user || hasReadAccess(user, obj))
           && pathObj.getParentIds().contains(folder.getId())) {
         if (pathObj instanceof VersionedDocument) {
           DocumentVersion ver;
           if (usePwc) {
             ver = ((VersionedDocument) pathObj).getPwc();
             if (null == ver) {
               ver = ((VersionedDocument) pathObj).getLatestVersion(false);
             }
           } else {
             ver = ((VersionedDocument) pathObj).getLatestVersion(false);
           }
           children.add(ver);
         } else if (!(pathObj instanceof DocumentVersion)) { // ignore
           // DocumentVersion
           children.add(pathObj);
         }
       }
     }
   }
   return children;
 }
コード例 #2
0
 private boolean hasChild(Folder folder, String name) {
   List<Fileable> children = getChildren(folder);
   for (Fileable child : children) {
     if (child.getName().equals(name)) {
       return true;
     }
   }
   return false;
 }
コード例 #3
0
 private Fileable findObjectWithPathInDescendents(
     String path, String user, String prefix, Fileable fo) {
   if (path.equals(prefix)) {
     return fo;
   } else if (fo instanceof Folder) {
     List<Fileable> children = getChildren((Folder) fo);
     for (Fileable child : children) {
       String foundPath =
           prefix.length() == 1
               ? prefix + child.getName()
               : prefix + Filing.PATH_SEPARATOR + child.getName();
       if (path.startsWith(foundPath)) {
         Fileable found = findObjectWithPathInDescendents(path, user, foundPath, child);
         if (null != found) {
           return found; // note that there can be multiple folders
           // with the same prefix like folder1,
           // folder10
         }
       }
     }
   }
   return null;
 }