Review Board 1.7.22


Make RestfulCollection object to be backed by a map with the put and get methods exposed

Review Request #5134 - Created May 16, 2012 and submitted

Erik Bi
shindig-1779
Reviewers
shindig
ddumont, rbaxter, ssievers
shindig
There are requirements to expose some specific attributes in the feed result.  These attributes are not specific to any entry i.e. global in scope. for example, it is possible that user may require additional attributes to be passed like "Configuration parameters used by the front end to present Activity entries"
Would like the RestfulCollection object to be backed by a map with the put and get methods exposed, similar to how ActivityEntry and ActivityObject are currently handled. 

The code in Shindig trunk does not pass extra items at the Stream level, only down at the Activity level. This JIRA seeks to migrate this patch back to Shindig such that other feed producers/renders can leverage it as well.

Example: 
{
  // Want to put custom attributes here and have them returned, 
  isAdmin: true,
  ....

  "items" : [
      {
        "published": "2011-02-10T15:04:55Z",
        "foo": "some extension property",
        "generator": {
          "url": "http://example.org/activities-app"
        },
        "provider": {
          "url": "http://example.org/activity-stream"
        },
        "title": "Martin posted a new video to his album.",
        "actor": {
          "url": "http://example.org/martin",
          "objectType": "person",
          "id": "tag:example.org,2011:martin",
          "foo2": "some other extension property",
          "image": {
            "url": "http://example.org/martin/image",
            "width": 250,
            "height": 250
          },
          "displayName": "Martin Smith"
        },
        "verb": "post",
        "object" : {
          "url": "http://example.org/album/my_fluffy_cat.jpg",
          "objectType": "photo",
          "id": "tag:example.org,2011:my_fluffy_cat",
          "image": {
            "url": "http://example.org/album/my_fluffy_cat_thumb.jpg",
            "width": 250,
            "height": 250
          }
        },
        "target": {
          "url": "http://example.org/album/",
          "objectType": "photo-album",
          "id": "tag:example.org,2011:abc123",
          "displayName": "Martin's Photo Album",
          "image": {
            "url": "http://example.org/album/thumbnail.jpg",
            "width": 250,
            "height": 250
          }
        }
      }
    ]
  }



 
http://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/JsonSerializer.java
Revision 1327432 New Change
[20] 17 lines
[+20]
18
 */
18
 */
19
package org.apache.shindig.common;
19
package org.apache.shindig.common;
20

    
   
20

   
21
import org.apache.shindig.common.util.DateUtil;
21
import org.apache.shindig.common.util.DateUtil;
22
import org.apache.shindig.common.uri.Uri;
22
import org.apache.shindig.common.uri.Uri;

    
   
23
import org.apache.shindig.protocol.RestfulCollection;
23
import org.joda.time.DateTime;
24
import org.joda.time.DateTime;
24
import org.json.JSONArray;
25
import org.json.JSONArray;
25
import org.json.JSONObject;
26
import org.json.JSONObject;
26

    
   
27

   
27
import com.google.common.collect.Multimap;
28
import com.google.common.collect.Multimap;
[+20] [20] 133 lines
[+20] [+] public static void append(Appendable buf, Object value) throws IOException {
161
      appendString(buf, DateUtil.formatIso8601Date((Date)value));
162
      appendString(buf, DateUtil.formatIso8601Date((Date)value));
162
    } else if (value instanceof JSONObject) {
163
    } else if (value instanceof JSONObject) {
163
      appendJsonObject(buf, (JSONObject) value);
164
      appendJsonObject(buf, (JSONObject) value);
164
    } else if (value instanceof JSONArray) {
165
    } else if (value instanceof JSONArray) {
165
      appendJsonArray(buf, (JSONArray) value);
166
      appendJsonArray(buf, (JSONArray) value);

    
   
167
    } else if (value instanceof RestfulCollection<?>) {

    
   
168
      appendPojo(buf, value);
166
    } else if (value instanceof Map) {
169
    } else if (value instanceof Map) {
167
      appendMap(buf, (Map<String, Object>) value);
170
      appendMap(buf, (Map<String, Object>) value);
168
    } else if (value instanceof Multimap) {
171
    } else if (value instanceof Multimap) {
169
      appendMultimap(buf, (Multimap<String, Object>) value);
172
      appendMultimap(buf, (Multimap<String, Object>) value);
170
    } else if (value instanceof Collection) {
173
    } else if (value instanceof Collection) {
[+20] [20] 269 lines
http://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/RestfulCollection.java
Revision 1339011 New Change
 
http://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/conversion/BeanXStreamConverter.java
Revision 1327432 New Change
 
http://svn.apache.org/repos/asf/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomFeed.java
Revision 1339014 New Change
 
  1. http://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/JsonSerializer.java: Loading...
  2. http://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/RestfulCollection.java: Loading...
  3. http://svn.apache.org/repos/asf/shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/conversion/BeanXStreamConverter.java: Loading...
  4. http://svn.apache.org/repos/asf/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/util/atom/AtomFeed.java: Loading...