[midPoint] search using midpoint script library

Pavol Mederly mederly at evolveum.com
Thu Mar 12 21:14:15 CET 2015


Hello Paul,

yes, midpoint.searchObjects can be used to implement that.

An example that I was able to create is this:

<expression>
     <script>
         <code>
import com.evolveum.midpoint.prism.query.EqualFilter
import com.evolveum.midpoint.prism.query.ObjectQuery
import javax.xml.namespace.QName
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType

prismContext = 
midpoint.createEmptyObject(UserType.class).asPrismObject().getPrismContext() 
// temporary solution until there's a midpoint.getPrismContext() method

log.info("Trying to find a user with a nickname = {}", input)
filter = EqualFilter.createEqual(new QName("nickName"), UserType.class, 
prismContext, null, input)
query = ObjectQuery.createObjectQuery(filter)
list = midpoint.searchObjects(UserType.class, query)
if (list.size() > 0) {
     'Found: ' + list.get(0).getFamilyName()
} else {
     'Nothing found'
}
         </code>
     </script>
</expression>

(Yes, I know it's a bit ugly. :-) Maybe someone could find a nicer 
solution.)

This specific script is used as an inbound expression for an attribute. 
It tries to find a user with a nickName (chosen as an example) equals to 
the value of the attribute.
And then it uses a user's familyName attribute to construct the return 
value.

I suppose we don't have anything like this in our examples because it is 
quite a non-usual thing - to search midPoint repository from within a 
mapping. Other aspects aside, I think it would be quite slow to execute. 
Maybe there would be some other way how to achieve what you'd like to do.

What exactly is your scenario, your requirement?

Best regards,
Pavol


On 12. 3. 2015 18:25, Paul Heaney wrote:
> Hi,
>
> We're looking to synchronise users assistants from Active Directory to 
> midPoint, to do this we need to do a search on midPoint based on the 
> received assistant value.  I believe we should be able to do this with 
> the searchObjects function within the midPoint script library (using 
> Groovy) though unfortunatly I'm having a few difficulties getting the 
> syntax of the query parameter correct in my groovy script.
>
> I've had a look at the samples and also the test scripts though don't 
> seem to be able to find an example, does anyone have an example or 
> pointers on this call?
>
> Thanks
> Paul
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20150312/884dcd41/attachment.htm>


More information about the midPoint mailing list