Hi Rodrigo and all,

I've attached my simple jsonmessage.js file (mostly it just adds a toJsonObject method) and related diffs. With these changes, I create a message in the gadget with:

  var req = opensocial.newDataRequest();
  var message = opensocial.newMessage(msg);
  message.setField(opensocial.Message.Field.TYPE,
    opensocial.Message.Type.PRIVATE_MESSAGE);
  message.setField(opensocial.Message.Field.TITLE, subject);

  // not part of api, but in RPC proposal
  var recipients = [ tempToId ];
  message.setField("recipients", recipients);

and create a JsonRpcRequestItem with a param:

    rpc.params.message = message.toJsonObject();

On the server side, I can get the Message object (almost) in my MessageHandler with:

        Message incomingMessage =
            reqitem.getTypedParameter("message", Message.class);

...except that I'm running into an error in the bean json converter due to the list of recipients I've added (following the proposal to add recipients in an array in the message request).

Here's a description of the diffs.

jsonrpccontainer.js
- Added newMessage() function in order to return the new jsonmessage object.

feature.xml
- Added jsonmessage.js file so that it's loaded.

message.js
- Changed the text of the Type fields to match Message.java on the server, otherwise the json could not be converted to a pojo.

org.apache.shindig.social.opensocial.model.Message
- This is a minor change, but it's an API change so it's a bigger deal. To match the rest/rpc proposal, I added a list of recipients to the class so that they can be pulled out in the message handler. I see that's a todo in your handler; the recipients could be another param in the post body, but I don't think that works well in the rest case without clashing with the messaging URI template.

org.apache.shindig.social.core.model.MessageImpl
- Added List<String> of recipients to match interface. Just made the minimum change to compile.

I hope some of this is helpful. That list of recipients is giving me some grief in the converter, so I'll have to go with my workarounds for now (e.g. treating the incoming messages as a simple JSONObject) and can help more with this after you have a chance to look it over. One other issue is that, when returning a message to the client, there needs to be some way to include the sender information. Another field could be added to Message, or this could be handled in an impl- specific way.

Let me know please if you have any questions or would like me to try something else. You can see the server-side code as I commit it here (I hope to wrap up message support today, though with some workarounds):

https://socialsite.dev.java.net/source/browse/socialsite/trunk/src/java/com/sun/socialsite/web/rest/core/

Cheers,
Bobby



   The original attachment - jsonmessage.js - has been removed from this 
   message, as it is a type of file which has recently been used 
   to carry viruses and other malicious software. 

   The following extensions are no longer supported as valid 
   email attachments and will be removed since they are primarily 
   used to carry viruses and other malicious software:

      asp bas bat chm cmd com exe hlp hta inf isp js jse lnk msi mst
      pcd pif reg scr url vbe vbs ws wsh sun.com.zip



Reply via email to