AnsweredAssumed Answered

Query folders containing documents filtered by custom metada

Question asked by hanumeshm on Feb 2, 2011
Latest reply on Feb 2, 2011 by hanumeshm
I am new to Alfresco.
I am associating custom metadata 'targetUser' for the document while uploading. This is to specify who can access the document.
Now user 'testUser' logins to application. Then I should display the folders which contain atleast one document whose custom metadata 'targetUser' matches his userId i.e. (testUser).
Can any help in this regard.  ( I am using Alfresco 3.3 Enterprise ).
Currenlty, I am displaying all folders as soon as user logs in.

ResultSet rs = getSearchService().query(storeRef, SearchService.LANGUAGE_XPATH, folderPath);
nodeRef = rs.getNodeRef(0);
List<FileInfo> foldersInfo = fileFolderService.listFolders(selectedFolderNodeRef);
if(null != foldersInfo && !foldersInfo.isEmpty()){
  for(FileInfo fileInfo : foldersInfo){
     Folder folder = new Folder();

something like to following might be helpful. but I am not sure what does this mean (Qname, namespacePrefixResolver…)

QueryParameterDefImpl paramDef = new QueryParameterDefImpl(QName.createQName("alf:lemur",  
                                  namespacePrefixResolver), (org.alfresco.service.cmr.dictionary.PropertyDefinition) null, true, "fox");
ResultSet results = getSearchService().query(storeRef, "lucene", "TEXT:\"${alf:lemur}\"",  new QueryParameterDefinition[] { paramDef });

Context: There may be 1000 folders(under folderPath), out of which the user has access to 3 documents only scattered across 3 folders. Then I need to avoid rest of folders for display as there will not be documents intended for him.

Its very urgent. If anybody come across such situation or have idea, please do share information.

Thanks in advance,