Skip to main content
Level 4
Oct 10, 2023 5:39 PM UTC
Solved

userManager.findAuthorizables(Query query)

For UserManager interface findAuthorizables(Query query) method, query interface needs to be of org.apache.jackrabbit.api.security.user API. 

I have to restrict path of an iteration that happens over a property jcr:primaryType with value rep:user. How can I create a query so that I can utilize the above method? Or is there any other way to achieve this?

 

Below is the query that is being executed.

/jcr:root/home//element(*)[@jcr:primaryType='rep:User']

 

I need to change the path from /home to /home/users. Is there a way I can do that?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
A_H_M_Imrul
A_H_M_ImrulAccepted solution
Community Advisor
Oct 10, 2023 6:30 PM UTC

@goyalkritika 

A query object can be passed to the findAuthorizable method. It has a single build(QueryBuilder) method, here are some examples: 

Iterator<Authorizable> result = userMgr.findAuthorizables(new Query() { public <T> void build(QueryBuilder<T> builder) { builder.setCondition(builder.eq("@name", vf.createValue("jackrabbit"))); } }); Iterator<Authorizable> result = userMgr.findAuthorizables(new Query() { public <T> void build(QueryBuilder<T> builder) { builder.setCondition(builder.gt("profile/@weight", vf.createValue(200.0))); } }); Iterator<Authorizable> result = userMgr.findAuthorizables(new Query() { public <T> void build(QueryBuilder<T> builder) { builder.setCondition(builder.contains("profile/@color", "gold")); } }); Iterator<Authorizable> result = userMgr.findAuthorizables(new Query() { public <T> void build(QueryBuilder<T> builder) { builder.setCondition(builder.exists("@poisonous")); } });

Reference: https://jackrabbit.apache.org/oak/docs/security/user/query.html

 

 

2 replies

A_H_M_Imrul
Community Advisor
A_H_M_ImrulCommunity AdvisorAccepted solution
Community Advisor
Oct 10, 2023 6:30 PM UTC

@goyalkritika 

A query object can be passed to the findAuthorizable method. It has a single build(QueryBuilder) method, here are some examples: 

Iterator<Authorizable> result = userMgr.findAuthorizables(new Query() { public <T> void build(QueryBuilder<T> builder) { builder.setCondition(builder.eq("@name", vf.createValue("jackrabbit"))); } }); Iterator<Authorizable> result = userMgr.findAuthorizables(new Query() { public <T> void build(QueryBuilder<T> builder) { builder.setCondition(builder.gt("profile/@weight", vf.createValue(200.0))); } }); Iterator<Authorizable> result = userMgr.findAuthorizables(new Query() { public <T> void build(QueryBuilder<T> builder) { builder.setCondition(builder.contains("profile/@color", "gold")); } }); Iterator<Authorizable> result = userMgr.findAuthorizables(new Query() { public <T> void build(QueryBuilder<T> builder) { builder.setCondition(builder.exists("@poisonous")); } });

Reference: https://jackrabbit.apache.org/oak/docs/security/user/query.html

 

 

Translate
kautuk_sahni
Level 9
Oct 11, 2023 11:50 AM UTC

@goyalkritika Did you find the suggestions from @a_h_m_imrul helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Translate
Kautuk Sahni