userManager.findAuthorizables(Query query) | Community
Skip to main content
Level 4
October 10, 2023
Solved

userManager.findAuthorizables(Query query)

  • October 10, 2023
  • 2 replies
  • 848 views

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.
Best answer by A_H_M_Imrul

@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
October 10, 2023

@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

 

 

kautuk_sahni
Community Manager
Community Manager
October 11, 2023

@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.

Kautuk Sahni