Skip to Content.
Sympa Menu

grouper-dev - [grouper-dev] WS source adapter

Subject: Grouper Developers Forum

List archive

[grouper-dev] WS source adapter


Chronological Thread 
  • From: Chris Hyzer <>
  • To: "" <>
  • Cc: Keith Hazelton <>
  • Subject: [grouper-dev] WS source adapter
  • Date: Thu, 28 Aug 2014 16:11:12 +0000
  • Accept-language: en-US

I was asked by Keith to help with a WS subject source adapter.  I did a sample implementation for getting a subject by id

 

https://bugs.internet2.edu/jira/browse/GRP-1029

 

Keith, maybe you can work in that github project to finish the implementation?  J  Or if not, let me know how the get by identifier and search will work and I can work on it some more…

 

https://github.com/Internet2/grouper/tree/master/grouper-misc/wsSourceAdapter

 

The example is in the POC

 

/**

* ws sample source adapter

*/

public class WsSourceAdapterPoc {

 

  /**

   *

   * @param args

   */

  public static void main(String[] args) {

 

    Subject subject = SourceManager.getInstance().getSource("ws").getSubject("urn:uuid:61c8922b-2d23-4fba-9bce-5f1dde6decf7", true);

   

    System.out.println("id: " + subject.getId());

    System.out.println("name: " + subject.getName());

    System.out.println("description: " + subject.getDescription());

    System.out.println("email: " + subject.getAttributeValue("email"));

   

  }

}

 

id: urn:uuid:61c8922b-2d23-4fba-9bce-5f1dde6decf7

name: Mr. John Doe

description: Mr. John Doe

email:

 

to use this, checkout the project and adjust the sources.xml for your env.

 

specifically change this to the real url:

 

    <init-param>

      <param-name>baseUrl</param-name>

      <param-value>http://somehost.whatever.org/bsp/</param-value>

    </init-param>

 

Note, the initial implementation only as get subejct by id, not identifier or search

 

Note, this is somewhat generic (xml only right now), you can use xpath to configure:

 

  <source adapterClass="edu.internet2.middleware.grouperWsSourceAdapter.WsSourceAdapter">

    <id>ws</id>

    <name>WS Source Adapter</name>

    <type>person</type>

   

    <init-param>

      <param-name>baseUrl</param-name>

      <param-value>http://somehost.whatever.org/bsp/</param-value>

    </init-param>

   

    <!--  http://somehost.whatever.org/bsp/contacts/urn:uuid:61c8922b-2d23-4fba-9bce-5f1dde6decf7 -->

    <!--  you can substitute $baseUrl$ for the base url, and $id$ for the id to search for -->

    <init-param>

      <param-name>searchByIdUrl</param-name>

      <param-value>$baseUrl$/contacts/$id$</param-value>

    </init-param>

   

    <init-param>

      <param-name>subjectIdXpath</param-name>

      <param-value>contacts:bambooContact/contacts:contactId/text()</param-value>

    </init-param>

   

    <init-param>

      <param-name>nameXpath</param-name>

      <param-value>contacts:bambooContact/contacts:displayName/text()</param-value>

    </init-param>

   

    <init-param>

      <param-name>descriptionXpath</param-name>

      <param-value>contacts:bambooContact/contacts:displayName/text()</param-value>

    </init-param>

   

    <!-- add subject attributes in pairs with index from 0 to 99 sequential -->   

    <init-param>

      <param-name>attribute_0_name</param-name>

      <param-value>email</param-value>

    </init-param>

 

    <init-param>

      <param-name>attribute_0_xpath</param-name>

      <param-value>contacts:bambooContact/contacts:emails[1]/email/text()</param-value>

    </init-param>

   

 

    <!-- add namespaces of xml for xpath to work, these are name value pairs and must go from index 0 to X sequential, max 99 -->   

    <init-param>

      <param-name>namespace_0_name</param-name>

      <param-value>contacts</param-value>

    </init-param>

    <init-param>

      <param-name>namespace_0_value</param-name>

      <param-value>http://projectbamboo.org/bsp/services/core/contact</param-value>

    </init-param>

   

    <init-param>

      <param-name>namespace_1_name</param-name>

      <param-value>dc</param-value>

    </init-param>

    <init-param>

      <param-name>namespace_1_value</param-name>

      <param-value>http://purl.org/dc/elements/1.1/</param-value>

    </init-param>

   

    <init-param>

      <param-name>namespace_2_name</param-name>

      <param-value>rdf</param-value>

    </init-param>

    <init-param>

      <param-name>namespace_2_value</param-name>

      <param-value>http://www.w3.org/1999/02/22-rdf-syntax-ns#</param-value>

    </init-param>

   

    <init-param>

      <param-name>namespace_3_name</param-name>

      <param-value>dcterms</param-value>

    </init-param>

    <init-param>

      <param-name>namespace_3_value</param-name>

      <param-value>http://purl.org/dc/terms/</param-value>

    </init-param>

   

    <init-param>

      <param-name>namespace_4_name</param-name>

      <param-value>foaf</param-value>

    </init-param>

    <init-param>

      <param-name>namespace_4_value</param-name>

      <param-value>http://xmlns.com/foaf/0.1/</param-value>

    </init-param>

   

    <init-param>

      <param-name>namespace_5_name</param-name>

      <param-value>bsp</param-value>

    </init-param>

    <init-param>

      <param-name>namespace_5_value</param-name>

      <param-value>http://projectbamboo.org/bsp/resource</param-value>

    </init-param>

   

  </source>

 

Thanks,

Chris

 




Archive powered by MHonArc 2.6.16.

Top of Page