Hello,
I'm currently implementing a smart folder, and I can't find the documentation I need.
The goal of the smart folder is to list all the documents located in other people's home folders, which have been made accessible to the current user.
For example, my name is Nico, and I grant read access to document1.docx to the user Mike.
In this case, Mike should see, in the smart folder, the document1.docx.
In natural language, the query would look like this :
"Show me all the documents from the folder User Homes, except my own personal folder".
The permission system will naturally hide the documents I'm not allowed to access.
I'm a big newbie in the alfresco document model and found very few documentation about the PATH criteria in smart folder queries.
I guess it might look like this :
"query": "(PATH:'/app:company_home/User Homes//*') AND NOT (PATH:'/app:company_home/User Homes/%MY_PERSONAL_FOLDER%')"
But of course not
Could anyone give me some clues please ?
Thanks a lot !
Nico
Solved! Go to Solution.
The documentation (https://docs.alfresco.com/6.1/concepts/sf-ref-template-guidance.html) contains details on which placeholders are actually supported in Smart Folder queries. In essence you'd need to replace %MY_PERSONAL_FOLDER% with %CURRENT_USER%. The PATH field allows for queries against the qname path of a node. As such, it must reflect the qname path of the search context, not the display path. E.g. PATH:'/app:company_home/User Homes//*' actually contains mixed elements - "app:company_home" is a qname path element, while "User Homes" is a display path. You can check the qname path by using the Node Browser admin tool to browse Alfresco's data structures, which lists the "path" for each node at the top of the details.
Querying for content in user homes e.g. requires the query PATH:'/app:company_home/app:user_homes//*' and excluding contents of any users home requires PATH:'/app:company_home/app:user_homes/cm:userName//*'. It is important to note that the local names in qname path elements must be properly encoded according to the XPath specification, so e.g. a user name of "User 123" will result in a home folder qname path element of "cm:User_x0020_123" as the white space must be encoded. For that reason, it may be problematic to use the %CURRENT_USER% placeholder to construct the PATH query, unless it can be guaranteed that no user name will ever contain a character that needs to be encoded (i.e. non-ASCII / non-alphanumerical characters, leading digits).
The documentation (https://docs.alfresco.com/6.1/concepts/sf-ref-template-guidance.html) contains details on which placeholders are actually supported in Smart Folder queries. In essence you'd need to replace %MY_PERSONAL_FOLDER% with %CURRENT_USER%. The PATH field allows for queries against the qname path of a node. As such, it must reflect the qname path of the search context, not the display path. E.g. PATH:'/app:company_home/User Homes//*' actually contains mixed elements - "app:company_home" is a qname path element, while "User Homes" is a display path. You can check the qname path by using the Node Browser admin tool to browse Alfresco's data structures, which lists the "path" for each node at the top of the details.
Querying for content in user homes e.g. requires the query PATH:'/app:company_home/app:user_homes//*' and excluding contents of any users home requires PATH:'/app:company_home/app:user_homes/cm:userName//*'. It is important to note that the local names in qname path elements must be properly encoded according to the XPath specification, so e.g. a user name of "User 123" will result in a home folder qname path element of "cm:User_x0020_123" as the white space must be encoded. For that reason, it may be problematic to use the %CURRENT_USER% placeholder to construct the PATH query, unless it can be guaranteed that no user name will ever contain a character that needs to be encoded (i.e. non-ASCII / non-alphanumerical characters, leading digits).
Thank you very much for your help afaust !
Meanwhile I found the node explorer that actually helped me a lot to find the right names and test my queries
My final query looks like this and I feel good with it for now !
"(PATH:'/app:company_home/app:user_homes//*') AND (NOT (=cm:creator:%CURRENT_USER%)) AND -TYPE:\"cm:folder\""
Cheers !
Nico
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.