Smart folder source path issue

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
toxnico
Member II

Smart folder source path issue

Jump to solution

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 Smiley Happy

Could anyone give me some clues please ?

Thanks a lot !

Nico

1 Solution

Accepted Solutions
afaust
Master

Re: Smart folder source path issue

Jump 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).

View solution in original post

2 Replies
afaust
Master

Re: Smart folder source path issue

Jump 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).

View solution in original post

toxnico
Member II

Re: Smart folder source path issue

Jump to solution

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 Smiley Happy

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