Expand my Community achievements bar.

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
Community Advisor

@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
Community Advisor

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