AnsweredAssumed Answered

Another method more efficient than getChildAssocsByPropertyValue?

Question asked by spilby on Apr 13, 2015
Latest reply on Apr 14, 2015 by spilby
Good morning,

before I create a new folder on a path, I need to know if the title of this folder exists on that path.

I do this to check it:


   List<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>();
   assocs = getNodeService().getChildAssocsByPropertyValue(nodeRef, 
               QName.createQName(Constants.modelAlfrescoNS, Constants.titleProperty), titleFolder);
   if (assocs==null || assocs.isEmpty()) {
       // A folder with this title not exists
       …
   }


At first this works ok, but now that I have a lot of folders, I can see that this operation takes too long (for example, a path with 40 folders takes up to 6 seconds to return the assocs, with a 1.500.000 documents on all alfresco system).

Are there another method to know it better than getChildAssocsByPropertyValue? I don't need to explore recursively on subfolders, only explore the direct sons of a folder to not repeat a title.

And I prefer not use a lucene search, because of I need to create a lot of classes quickly and some times a lucene search don't give me a result because it's not indexed yet.

Thank you very much!

Outcomes