cancel
Showing results for 
Search instead for 
Did you mean: 

[resolved] Retrieving Folders

robobot
Champ in-the-making
Champ in-the-making
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.
2 REPLIES 2

mikeh
Star Contributor
Star Contributor
You can add +TYPE:"{http://www.alfresco.org/model/content/1.0}folder" to the query.

Thanks,
Mike

robobot
Champ in-the-making
Champ in-the-making
oh thank you very mutch - that works!