[midPoint] Search filters in IDM Model WS Interface

Samu Viitanen zamppa90 at hotmail.com
Fri Nov 6 16:05:51 CET 2015


Hello Pavol,
Thank you for your response. I will use this code in my solution.
BR- Samu
To: midpoint at lists.evolveum.com
From: mederly at evolveum.com
Date: Thu, 5 Nov 2015 21:01:58 +0100
Subject: Re: [midPoint] Search filters in IDM Model WS Interface


  
    
  
  
    Hello Samu,

      

      because midPoint uses multiple formats for data serialization
      (XML, JSON, YAML - although the support for latter two is not
      fully finished yet), we don't rely on JAXB any more. We treat some
      data structures (mainly in the prism module) in quite a custom
      way. This causes some slight issues when trying to cooperate with
      JAXB serialization, namely, when interfacing via Web Services.

      

      So, to answer your questions: The weird setFilterClause method and
      its "Element" parameter is one of these issues. 

      

      One of the methods how to create queries can be seen in the
      model-client-sample:

      
      // WARNING: in a real case make sure that the username is properly escaped before putting it in XML
SearchFilterType filter = ModelClientUtil.parseSearchFilterType(
        "<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" +
                "<path>c:name</path>" +
                "<value>" + username + "</value>" +
                "</equal>"
);
QueryType query = new QueryType();
query.setFilter(filter);


      I tried to take your sample and make it working - it can be done
      in the following way:

      QueryType query = new QueryType();

SearchFilterType filter = new SearchFilterType();

PropertyComplexValueFilterClauseType fc = new PropertyComplexValueFilterClauseType();
ItemPathType path = new ItemPathType();
path.setValue("declare namespace c=\"http://midpoint.evolveum.com/xml/ns/public/common/common-3\"; c:name");
fc.setPath(path);
fc.setValue(username);

ObjectFactory factory = new ObjectFactory();
JAXBElement<PropertyComplexValueFilterClauseType> equal = factory.createEqual(fc);

JAXBContext jaxbContext = JAXBContext.newInstance("com.evolveum.midpoint.xml.ns._public.common.api_types_3:" +
        "com.evolveum.midpoint.xml.ns._public.common.common_3:" +
        "com.evolveum.prism.xml.ns._public.annotation_3:" +
        "com.evolveum.prism.xml.ns._public.query_3:" +
        "com.evolveum.prism.xml.ns._public.types_3:");
Marshaller marshaller = jaxbContext.createMarshaller();
DOMResult result = new DOMResult();
marshaller.marshal(equal, result);
filter.setFilterClause(((Document) result.getNode()).getDocumentElement());

query.setFilter(filter);


      (Of course, you can pre-create and cache jaxbContext or marshaller
      in order to avoid creating them each time.)

      

      Best regards,

      Pavol

      

      On 3. 11. 2015 16:12, Samu Viitanen wrote:

    
    
      
      Afternoon,

        

        I am having issues with the following code

        

                    QueryType query = new QueryType();

                    

                    ObjectFactory factory = new ObjectFactory();

        

                    SearchFilterType filter =
        factory.createSearchFilterType();

                    PropertyComplexValueFilterClauseType fc =
        factory.createPropertyComplexValueFilterClauseType();

                    ItemPathType path = new ItemPathType();

                    path.setValue("c:name");

                    fc.setPath(path);

                    fc.setValue("queryvalue");

                    filter.setFilterClause(??????);

                    

                    query.setFilter(filter);

        

        I noticed that SearchFilterType.setFilterClause only accepts
        org.w3c.dom.Element as a parameter. Is this intentional? If so,
        are there tools to create these dom elements? I was just
        wondering since there are plenty of ways to create the filter
        clauses, but I just dont seem to get my head around how I could
        actually set the filter clause.

        

        Sorry for the stupid question.

        

        BR

        

        Samu Viitanen

      
      

      
      

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

    
    

  


_______________________________________________
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/20151106/c9769a47/attachment.htm>


More information about the midPoint mailing list