[midPoint] Search for user based on custom extension value in Maven Overlay

BOSCHMANS Glenn gboschmans at cibg.brussels
Tue May 30 11:27:53 CEST 2017


Hello Oskar,

Creating the query like this works.

Thank you for your help!

Best regards,
Glenn

From: midPoint [mailto:midpoint-bounces at lists.evolveum.com] On Behalf Of Oskar Butovic - AMI Praha a.s.
Sent: maandag 29 mei 2017 17:31
To: midPoint General Discussion
Subject: Re: [midPoint] Search for user based on custom extension value in Maven Overlay

Hello Glenn,

in groovy scripts in midPoint I use syntax like this:

briamId = "33c161e0-ed27-470c-9606-c863894c782b";
briamIdItem = new ItemPath(new ItemPath(PrismConstants.EXTENSION_LOCAL_NAME),new QName('http://cibg.brussels/xml/ns/idmSchema', 'briamId'));

ObjectFilter userFilter = QueryBuilder.queryFor(UserType.class, midpoint.getPrismContext()).item(briamIdItem).eq(briamId).buildFilter();
ObjectQuery userQuery = ObjectQuery.createObjectQuery(userFilter, ObjectPaging.createEmptyPaging()); // we don't need no paging

List<UserType> foundUsers = null;
try{
            foundUsers = midpoint.searchObjects(UserType.class, userQuery);
}catch(ObjectNotFoundException ex){
            //doesnt matter. carry on.
}

Try it. It should work also in the overlay.

Best Regards

Oskar Butovič

2017-05-29 17:17 GMT+02:00 BOSCHMANS Glenn <gboschmans at cibg.brussels<mailto:gboschmans at cibg.brussels>>:
Hi guys,

We are creating our own REST API with a Maven Overlay of midPoint (to limit the chatter over the network). We also have a custom schema for UserType. In our REST API I need to search for a user based on a value within the extension.

In the Query Playground I get a correct result for this query:
<query>
    <filter>
        <equal>
            <path>extension/briamId</path>
            <value>33c161e0-ed27-470c-9606-c863894c782b</value>
        </equal>
    </filter>
</query>

Because of that I wanted to replicate this query in Java code:

EqualFilter<String> filter = EqualFilter.createEqual(new ItemPath("extension/briamId"),null,null);
       PrismPropertyValue<String> value = new PrismPropertyValue<String>(briamId);
       filter.setValue(value);

       SearchResultList<PrismObject<UserType>> userPrismList =modelService.searchObjects(UserType.class, ObjectQuery.createObjectQuery(filter) , options, task, parentResult);

When I execute this code the following exception occurs:

2017-05-29 16:58:47,375 [] [http-nio-8080-exec-2] ERROR (com.evolveum.midpoint.repo.sql.helpers.BaseHelper): General checked exception occurred.
com.evolveum.midpoint.repo.sql.query.QueryException: Couldn't find a proper restriction for a ValueFilter: EQUAL:
  PATH: extension/briamId
  DEF: null
  VALUE:
    33c161e0-ed27-470c-9606-c863894c782b
                at com.evolveum.midpoint.repo.sql.query2.QueryInterpreter2.findAndCreateRestrictionInternal(QueryInterpreter2.java:230) ~[repo-sql-impl-3.5.1.jar:na]
                at com.evolveum.midpoint.repo.sql.query2.QueryInterpreter2.findAndCreateRestriction(QueryInterpreter2.java:176) ~[repo-sql-impl-3.5.1.jar:na]
                at com.evolveum.midpoint.repo.sql.query2.QueryInterpreter2.interpretFilter(QueryInterpreter2.java:156) ~[repo-sql-impl-3.5.1.jar:na]
                at com.evolveum.midpoint.repo.sql.query2.QueryInterpreter2.interpretQueryFilter(QueryInterpreter2.java:150) ~[repo-sql-impl-3.5.1.jar:na]
                at com.evolveum.midpoint.repo.sql.query2.QueryInterpreter2.interpret(QueryInterpreter2.java:120) ~[repo-sql-impl-3.5.1.jar:na]
                at com.evolveum.midpoint.repo.sql.query2.QueryEngine2.interpret(QueryEngine2.java:50) ~[repo-sql-impl-3.5.1.jar:na]
                at com.evolveum.midpoint.repo.sql.helpers.ObjectRetriever.searchObjectsAttempt(ObjectRetriever.java:373) ~[repo-sql-impl-3.5.1.jar:na]
                at com.evolveum.midpoint.repo.sql.SqlRepositoryServiceImpl.searchObjects(SqlRepositoryServiceImpl.java:251) [repo-sql-impl-3.5.1.jar:na]
                at com.evolveum.midpoint.repo.cache.RepositoryCache.searchObjects(RepositoryCache.java:165) [repo-cache-3.5.1.jar:na]
                at com.evolveum.midpoint.model.impl.controller.ModelController.searchObjects(ModelController.java:826) [model-impl-3.5.1.jar:na]
                at brussels.bric.midpoint.rest.UserService.getUser(UserService.java:104) [briam-midpoint-rest-server-1.0.0.jar:na]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
                at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
                …


I have no idea what I’m missing. Any ideas?

Thanks!

Best regards,
Glenn
[cid:image002.png at 01D2D929.999F5BD0]


Glenn Boschmans
Consultant
Business Integrated Solutions
Kunstlaan 21, 1000 Brussel - cibg.brussels<http://cibg.brussels> - disclaimer<http://cibg.brussels/disclaimer-1>
+32 2 282 47 70<tel:+32%202%20282%2047%2070> |
Be green, leave it on the screen !                                                       [cid:image003.png at 01D2D929.999F5BD0] <http://www.linkedin.com/company/cirb_cibg>   [cid:image004.png at 01D2D929.999F5BD0] <https://twitter.com/CIRB_CIBG>   [cid:image005.jpg at 01D2D929.999F5BD0] <http://www.leefmilieu.brussels/themas/duurzame-stad/label-ecodynamische-onderneming>


_______________________________________________
midPoint mailing list
midPoint at lists.evolveum.com<mailto:midPoint at lists.evolveum.com>
http://lists.evolveum.com/mailman/listinfo/midpoint



--

Oskar Butovič
solution architect

gsm: [+420] 774 480 101
e-mail: oskar.butovic at ami.cz<mailto:oskar.butovic at ami.cz>






AMI Praha a.s.
Pláničkova 11
162 00 Praha 6
tel.: [+420] 274 783 239
web: www.ami.cz<http://www.ami.cz/>






[AMI Praha a.s.]


[AMI Praha a.s.]<http://www.ami.cz/reseni-a-sluzby/bezpecnost-dat/identity-management>


Textem tohoto e-mailu podepisující neslibuje uzavřít ani neuzavírá za společnost AMI Praha a.s.
jakoukoliv smlouvu. Každá smlouva, pokud bude uzavřena, musí mít výhradně písemnou formu.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170530/681fee20/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 26658 bytes
Desc: image002.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170530/681fee20/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 722 bytes
Desc: image003.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170530/681fee20/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 464 bytes
Desc: image004.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170530/681fee20/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.jpg
Type: image/jpeg
Size: 1260 bytes
Desc: image005.jpg
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170530/681fee20/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cibg_aee22c14-e9ed-4d7b-8c27-f6c4a26e7736.png
Type: image/png
Size: 11221 bytes
Desc: cibg_aee22c14-e9ed-4d7b-8c27-f6c4a26e7736.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170530/681fee20/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ln_e679eb12-caaa-4d0d-b64d-b39c820c309b.png
Type: image/png
Size: 722 bytes
Desc: ln_e679eb12-caaa-4d0d-b64d-b39c820c309b.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170530/681fee20/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tw_20cfb408-d952-4ea7-a757-a8716eaac012.png
Type: image/png
Size: 464 bytes
Desc: tw_20cfb408-d952-4ea7-a757-a8716eaac012.png
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170530/681fee20/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo_eco_mail_e3e2fbdd-9cbf-4a5b-b0c1-1624e00ef4cd.jpg
Type: image/jpeg
Size: 1260 bytes
Desc: logo_eco_mail_e3e2fbdd-9cbf-4a5b-b0c1-1624e00ef4cd.jpg
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170530/681fee20/attachment-0001.jpg>


More information about the midPoint mailing list