Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

userManager.findAuthorizables(Query query)

Avatar

Level 5

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?

1 Accepted Solution

Avatar

Correct answer by
Level 7

@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

 

 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 7

@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

 

 

Avatar

Administrator

@goyalkritika Did you find the suggestions from @silk_route11 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