partial client-side code for Message support
--------------------------------------------
Key: SHINDIG-629
URL: https://issues.apache.org/jira/browse/SHINDIG-629
Project: Shindig
Issue Type: New Feature
Components: OpenSocial feature (Javascript)
Environment: All
Reporter: Robert Bissett
Attachments: diff.out
Am filing issue to submit some JavaScript code to go along with initial support
for Message posting. See http://codereview.appspot.com/5702 for related work.
>From [EMAIL PROTECTED], the discussion thread starts here:
>http://tinyurl.com/4h9mlw
Description of files to attach:
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
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.