Skip to Content.
Sympa Menu

grouper-users - Re: [grouper-users] groupSave using REST web services

Subject: Grouper Users - Open Discussion List

List archive

Re: [grouper-users] groupSave using REST web services


Chronological Thread 
  • From: Erik Froese <>
  • To: Chris Hyzer <>
  • Cc: "" <>
  • Subject: Re: [grouper-users] groupSave using REST web services
  • Date: Wed, 23 Mar 2011 14:40:15 -0400

Thanks Chris!

I wasn't able to use the GrouperUtil method (bombs in OSGi env. Not
sure why yet).
I had tried serializing the bean with json-lib but didn't wrap it with
the container.

Erik

On Tue, Mar 22, 2011 at 9:37 PM, Chris Hyzer
<>
wrote:
> If you click on samples here:
>
> https://spaces.internet2.edu/display/Grouper/Group+Save
>
> Then go to a JSON one, e.g.:
>
> http://anonsvn.internet2.edu/cgi-bin/viewvc.cgi/i2mi/trunk/grouper-ws/grouper-ws/doc/samples/groupSave/WsSampleGroupSaveRest_json.txt?revision=6127&view=co
>
> You will see that it needs to look like the request below.  Which it looks
> like you are just missing the wrapper request bean object...  right?  Are
> you saying to augmented the sample and it didn't work?  Or you made the
> JSON in your email by toher means?  Btw, you can just string prepend/append
> the container around the request if you like... :)  Thanks, Chris
>
>
> {
>  "WsRestGroupSaveRequest":{
>    "wsGroupToSaves":[
>      {
>        "wsGroup":{
>          "description":"desc1",
>          "displayExtension":"disp1",
>          "extension":"whateverGroup",
>          "name":"aStem:whateverGroup"
>        },
>        "wsGroupLookup":{
>          "groupName":"aStem:whateverGroup"
>        }
>
>      },
>      {
>        "wsGroup":{
>          "description":"descs",
>          "displayExtension":"disp2",
>          "extension":"whateverGroup2",
>          "name":"aStem:whateverGroup2"
>        },
>        "wsGroupLookup":{
>          "groupName":"aStem:whateverGroup2"
>        }
>      }
>    ]
>  }
> }
>
> -----Original Message-----
> From:
>
>
> [mailto:]
> On Behalf Of Erik Froese
> Sent: Tuesday, March 22, 2011 6:57 PM
> To:
>
> Subject: [grouper-users] groupSave using REST web services
>
> Hey all,
>
> I'm trying to create a group using the REST WS and a JSON request.
>
> I stole a lot of the code from the example:
> http://anonsvn.internet2.edu/cgi-bin/viewvc.cgi/i2mi/trunk/grouper-ws/grouper-ws/src/test/edu/internet2/middleware/grouper/ws/samples/rest/group/WsSampleGroupSaveRest.java?revision=5539&view=co
>
> I'm just adding 1 group to the request, serializing it as a JSON
> String, and sending it off. Apparently grouper isn't liking what I'm
> doing.
>
>  // Fill out the group save request beans
> WsRestGroupSaveRequest groupSave = new WsRestGroupSaveRequest();
> WsGroupToSave wsGroupToSave = new WsGroupToSave();
> wsGroupToSave.setWsGroupLookup(new WsGroupLookup(fullGrouperName, null));
> WsGroup wsGroup = new WsGroup();
> wsGroup.setDescription("Created by Sakai3");
> wsGroup.setDisplayExtension(grouperName);
> wsGroup.setExtension(grouperName);
> wsGroup.setName(fullGrouperName);
> wsGroupToSave.setWsGroup(wsGroup);
> groupSave.setWsGroupToSaves(new WsGroupToSave[]{ wsGroupToSave });
>
> The JSON request looks like this:
> {"wsGroupToSaves":[{"wsGroup":{"description":"Created by
> Sakai3","displayExtension":"test12","extension":"test12","name":"nyu:apps:atlas:test12"},"wsGroupLookup":{"groupName":"nyu:apps:atlas:test12"}}]}.
>
> And I'm getting an error on the WS server that indicates it found an
> invalid request type.
>
>
> 2011-03-22 18:43:19,453: [http-8080-5] ERROR
> GrouperRestServlet.service(204) -  - Problem with request:  uri:
> /grouper-ws/servicesRest/1_6_003/groups, method: POST, decoded url
> strings: 0: '1_6_003', 1: 'groups'
> java.lang.RuntimeException: Problem unparsing string with converter:
> edu.internet2.middleware.grouper.ws.rest.json.DefaultJsonConverter, {
>  "wsGroupToSaves":[
>    {
>      "wsGroup":{
>        "description":"Created by Sakai3",
>        "displayExtension":"test12",
>        "extension":"test12",
>        "name":"nyu:apps:atlas:test12"
>      },
>      "wsGroupLookup":{
>        "groupName":"nyu:apps:atlas:test12"
>      }
>    }
>  ]
> }
> ...
> Caused by: java.lang.RuntimeException: Not allowed to unmarshal json:
> wsGroupToSaves, {"wsGroupToSaves":[{"wsGroup":{"description":"Created
> by
> Sakai3","displayExtension":"test12","extension":"test12","name":"nyu:apps:atlas:test12"},"wsGroupLookup":{"groupName":"nyu:apps:atlas:test12"}}]}
>
> This indicates that WsGroupsToSaves is not present in the
> conversionMap that maps request type names to beans for
> de-serialization.
>
> Indeed edu.internet2.middleware.grouper.ws.rest.WsRestClassLookup
> doens't seem to have a match for wsGroupToSaves.
>
> Any pointers as to how to make this read wsGroupToSave instead of
> wsGroupToSaves? Is that necessary?
>
> Erik
>



Archive powered by MHonArc 2.6.16.

Top of Page