AnsweredAssumed Answered

[resolved] Retrieving Folders

Question asked by robobot on Aug 20, 2009
Latest reply on Aug 20, 2009 by robobot
Hello there, i have the following piece of code to find all folders and subfolders without any files.


  public List<String> getAllFoldersIn(String root) {

   //  path is PATH:"//app:company_home/app:user_homes/cm:Test/cm:MySpace/cm:Projects/cm:Job//."       
    String path = "PATH:\"/" + root + "//.\"";   
    final List<String> result = new ArrayList<String>();
    final Query query = new Query(Constants.QUERY_LANG_LUCENE, path);
    Node [] nodes = null;
    try {     
      nodes = WebServiceFactory.getRepositoryService().get(new Predicate(null,STORE,query));     
    } catch (RepositoryFault e) {
      e.printStackTrace();
    } catch (RemoteException e) {
      e.printStackTrace();
    }
    if (null != nodes){
      for (final Node node : nodes) {               
           result.add(node.getReference().getPath();
      }
    }
    return result;
  }

The Folder structure in Alfresco as follows:


Test
|_ __MySpace
                 |_____Projects
                                  |______Job
                                                |_____Job Subfolder 1
                                                                    |_________File 1.txt
                                                |______Job Subfolder 2

Now i get all content beneath Job (Folders and Files) . What can i do when i want to retrieve only all the folders without any documents ?

Best regards.

Outcomes