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

Oskar Butovič - AMI Praha a.s. oskar.butovic at ami.cz
Mon May 29 17:30:53 CEST 2017


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

> 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
>
> *Glenn Boschmans*
> Consultant
> Business Integrated Solutions
> Kunstlaan 21, 1000 Brussel - cibg.brussels - disclaimer
> <http://cibg.brussels/disclaimer-1>
> +32 2 282 47 70 <+32%202%20282%2047%2070> |
> Be green, leave it on the screen !
> <http://www.linkedin.com/company/cirb_cibg>
> <https://twitter.com/CIRB_CIBG>
> <http://www.leefmilieu.brussels/themas/duurzame-stad/label-ecodynamische-onderneming>
>
> _______________________________________________
> midPoint mailing list
> 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


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


[image: AMI Praha a.s.]

[image: 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/20170529/e7aa8a3a/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tw_20cfb408-d952-4ea7-a757-a8716eaac012.png
Type: image/png
Size: 464 bytes
Desc: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170529/e7aa8a3a/attachment.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: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170529/e7aa8a3a/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: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170529/e7aa8a3a/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ln_e679eb12-caaa-4d0d-b64d-b39c820c309b.png
Type: image/png
Size: 722 bytes
Desc: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170529/e7aa8a3a/attachment-0002.png>


More information about the midPoint mailing list