You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Cassie <do...@google.com> on 2008/08/21 19:56:24 UTC

Re: svn commit: r687235 [1/2] - in /incubator/shindig/trunk: config/ features/ features/opensocial-current/ java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ java/server/src/main/webapp/WEB-INF/ java/server/src/test/java/org/apache/shind

On Tue, Aug 19, 2008 at 9:14 PM, <lr...@apache.org> wrote:

> Author: lryan
> Date: Tue Aug 19 21:14:39 2008
> New Revision: 687235
>
> URL: http://svn.apache.org/viewvc?rev=687235&view=rev
> Log:
> Initial JSON-RPC implementation including...
>  - Batch support
>  - Execution via GET with JSON<-->URL encoding
>  - opensocial JS now uses JSON-RPC
>  - removed RESTful batching code in Java
>
> I've left the old opensocial container code backed by the RESTful API so
> PHP folks have a migration path. See feature.xml in opensocial-current.
>
> Added:
>    incubator/shindig/trunk/features/opensocial-current/jsonrpccontainer.js
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ApiServlet.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonConversionUtils.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonRpcServlet.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/RestfulRequestItem.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/RpcRequestItem.java
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/JsonConversionUtilsTest.java
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/JsonRpcServletTest.java
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RestfulRequestItemTest.java
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RpcRequestItemTest.java
> Removed:
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulBatchTest.java
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RequestItemTest.java
> Modified:
>    incubator/shindig/trunk/config/container.js
>    incubator/shindig/trunk/features/opensocial-current/feature.xml
>    incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
>    incubator/shindig/trunk/features/pom.xml
>
>  incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingTask.java
>    incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.full.xml
>
>  incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.social.xml
>    incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml
>
>  incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ActivityHandler.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/AppDataHandler.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataRequestHandler.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServlet.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServletFetcher.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/RequestItem.java
>
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/sample/service/SampleContainerHandler.java
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ActivityHandlerTest.java
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/AppDataHandlerTest.java
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/DataServiceServletTest.java
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/PersonHandlerTest.java
>
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/DataRequestHandlerTest.java
>
> Modified: incubator/shindig/trunk/config/container.js
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/config/container.js?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> --- incubator/shindig/trunk/config/container.js (original)
> +++ incubator/shindig/trunk/config/container.js Tue Aug 19 21:14:39 2008
> @@ -109,7 +109,7 @@
>   "opensocial-0.8" : {
>     // Path to fetch opensocial data from
>     // Must be on the same domain as the gadget rendering server
> -    "path" : "/social/rest",
> +    "path" : "/social",
>     "domain" : "shindig",
>     "enableCaja" : false,
>     "supportedFields" : {
>
> Modified: incubator/shindig/trunk/features/opensocial-current/feature.xml
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-current/feature.xml?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> --- incubator/shindig/trunk/features/opensocial-current/feature.xml
> (original)
> +++ incubator/shindig/trunk/features/opensocial-current/feature.xml Tue Aug
> 19 21:14:39 2008
> @@ -25,7 +25,7 @@
>   <!-- gadgets when "use caja" is checked -->
>   <gadget>
>     <script src="jsonperson.js"></script>
> -    <script src="jsonactivity.js"></script>
> +    <!--
>     <script src="restfulcontainer.js"></script>
>     <script>
>       var requiredConfig = {
> @@ -53,5 +53,33 @@
>       });
>
>     </script>
> +    -->
> +    <script src="jsonrpccontainer.js" inline="false"></script>
> +    <script>
> +      var requiredConfig = {
> +        "path": gadgets.config.NonEmptyStringValidator,
> +        "domain": gadgets.config.NonEmptyStringValidator,
> +        "enableCaja": gadgets.config.BooleanValidator,
> +        "supportedFields": gadgets.config.ExistsValidator
> +      };
> +
> +      gadgets.config.register("opensocial-0.8", requiredConfig,
> +        function(config) {
> +          var configParams = config["opensocial-0.8"];
> +
> +          ShindigContainer = function() {
> +            JsonRpcContainer.call(this, configParams.path,
> +            configParams.domain, configParams.supportedFields);
> +          };
> +          ShindigContainer.inherits(JsonRpcContainer);
> +
> +          opensocial.Container.setContainer(new ShindigContainer());
> +
> +          if (window['caja']) {
> +            opensocial.Container.get().enableCaja();
> +          }
> +      });
> +
> +    </script>
>   </gadget>
>  </feature>
>
> Added:
> incubator/shindig/trunk/features/opensocial-current/jsonrpccontainer.js
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-current/jsonrpccontainer.js?rev=687235&view=auto
>
> ==============================================================================
> --- incubator/shindig/trunk/features/opensocial-current/jsonrpccontainer.js
> (added)
> +++ incubator/shindig/trunk/features/opensocial-current/jsonrpccontainer.js
> Tue Aug 19 21:14:39 2008
> @@ -0,0 +1,373 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations under the
> License.
> + */
> +
> +/**
> + * @fileoverview JSON-RPC based opensocial container.
> + */
> +
> +var JsonRpcContainer = function(baseUrl, domain, supportedFieldsArray) {
> +  opensocial.Container.call(this);
> +
> +  var supportedFieldsMap = {};
> +  for (var objectType in supportedFieldsArray) {
> +    if (supportedFieldsArray.hasOwnProperty(objectType)) {
> +      supportedFieldsMap[objectType] = {};
> +      for (var i = 0; i < supportedFieldsArray[objectType].length; i++) {
> +        var supportedField = supportedFieldsArray[objectType][i];
> +        supportedFieldsMap[objectType][supportedField] = true;
> +      }
> +    }
> +  }
> +
> +  this.environment_ = new opensocial.Environment(domain,
> supportedFieldsMap);
> +  this.baseUrl_ = baseUrl;
> +
> +  this.securityToken_ = shindig.auth.getSecurityToken();
> +};
> +JsonRpcContainer.inherits(opensocial.Container);
> +
> +JsonRpcContainer.prototype.getEnvironment = function() {
> +  return this.environment_;
> +};
> +
> +JsonRpcContainer.prototype.requestCreateActivity = function(activity,
> +                                                            priority,
> opt_callback) {
> +  opt_callback = opt_callback || {};
> +
> +  var req = opensocial.newDataRequest();
> +  var viewer = new opensocial.IdSpec({'userId' : 'VIEWER'});
> +  req.add(this.newCreateActivityRequest(viewer, activity), 'key');
> +  req.send(function(response) {
> +    opt_callback(response.get('key'));
> +  });
> +};
> +
> +JsonRpcContainer.prototype.requestData = function(dataRequest, callback) {
> +  callback = callback || {};
> +
> +  var requestObjects = dataRequest.getRequestObjects();
> +  var totalRequests = requestObjects.length;
> +
> +  if (totalRequests == 0) {
> +    callback(new opensocial.DataResponse({}, true));
> +    return;
> +  }
> +
> +  var jsonBatchData = new Array(totalRequests);
> +  var systemKeyIndex = 0;
> +
> +  for (var j = 0; j < totalRequests; j++) {
> +    var requestObject = requestObjects[j];
> +
> +    if (!requestObject.key) {
> +      requestObject.key = "systemKey" + systemKeyIndex;
> +      while (jsonBatchData[requestObject.key]) {
> +        // If the key exists, choose another and try again
> +        systemKeyIndex++;
> +        requestObject.key = "systemKey" + systemKeyIndex;
> +      }
> +    }
> +
> +    jsonBatchData[j] = requestObject.request.rpc;
> +    jsonBatchData[j].id = requestObject.key;
> +
> +    if (requestObject.request.postData) {
> +      jsonBatchData[j].postData = requestObject.request.postData;
> +    }
> +  }
> +
> +  var sendResponse = function(result) {
> +    if (result.errors[0]) {
> +      JsonRpcContainer.generateErrorResponse(result, requestObjects,
> callback);
> +      return;
> +    }
> +
> +    result = result.data;
> +
> +    var globalError = false;
> +    var responseMap = {};
> +
> +    // Map from indices to ids.
> +    for (var i = 0; i < result.length; i++) {
> +      result[result[i].id] = result[i];
> +    }


why do you turn these into a map and then below index them by key?


>
> +
> +    for (var k = 0; k < requestObjects.length; k++) {
> +      var request = requestObjects[k];
> +      var response = result[request.key];


couldn't we just do result[k] here?
this would allow us to get rid of the hacky systemKey code which really
needs to be deleted.


>
> +
> +      var rawData = response.data;
> +      var error = response.error;
> +      var errorMessage = "";
> +
> +      if (error) {
> +        errorMessage = error.message;
> +      }
> +
> +      var processedData = request.request.processResponse(
> +          request.request, rawData, error, errorMessage);
> +      globalError = globalError || processedData.hadError();
> +      responseMap[request.key] = processedData;
> +    }
> +
> +    var dataResponse = new opensocial.DataResponse(responseMap,
> globalError);
> +    callback(dataResponse);
> +  };
> +
> +  // TODO: get the jsonbatch url from the container config
> +  var makeRequestParams = {
> +    "CONTENT_TYPE" : "JSON",
> +    "METHOD" : "POST",
> +    "AUTHORIZATION" : "SIGNED",
> +    "POST_DATA" : gadgets.json.stringify(jsonBatchData)
> +  };
> +
> +  gadgets.io.makeNonProxiedRequest(
> +      this.baseUrl_ + "/rpc?st=" +
> encodeURIComponent(shindig.auth.getSecurityToken()),
> +      sendResponse, makeRequestParams, "application/json");
> +};
> +
> +JsonRpcContainer.generateErrorResponse = function(result, requestObjects,
> callback) {
> +  var globalErrorCode =
> JsonRpcContainer.translateHttpError(result.errors[0] || result.data.error)
> +      || opensocial.ResponseItem.Error.INTERNAL_ERROR;
> +
> +  var errorResponseMap = {};
> +  for (var i = 0; i < requestObjects.length; i++) {
> +    errorResponseMap[requestObjects[i].key] = new opensocial.ResponseItem(
> +        requestObjects[i].request, null, globalErrorCode);
> +  }
> +  callback(new opensocial.DataResponse(errorResponseMap, true));
> +};
> +
> +JsonRpcContainer.translateHttpError = function(httpError) {
> +  if (httpError == "Error 501") {
> +    return opensocial.ResponseItem.Error.NOT_IMPLEMENTED;
> +  } else if (httpError == "Error 401") {
> +    return opensocial.ResponseItem.Error.UNAUTHORIZED;
> +  } else if (httpError == "Error 403") {
> +    return opensocial.ResponseItem.Error.FORBIDDEN;
> +  } else if (httpError == "Error 400") {
> +    return opensocial.ResponseItem.Error.BAD_REQUEST;
> +  } else if (httpError == "Error 500") {
> +    return opensocial.ResponseItem.Error.INTERNAL_ERROR;
> +  } else if (httpError == "Error 404") {
> +    return opensocial.ResponseItem.Error.BAD_REQUEST;
> +  // TODO: Which one should the limit exceeded error be?
> +    // } else if (httpError == "Error ???") {
> +    //   return opensocial.ResponseItem.Error.LIMIT_EXCEEDED;
> +  }
> +};
> +
> +JsonRpcContainer.prototype.makeIdSpec = function(id) {
> +  return new opensocial.IdSpec({'userId' : id});
> +};
> +
> +JsonRpcContainer.prototype.translateIdSpec = function(newIdSpec) {
> +  var userId = newIdSpec.getField('userId');
> +  var groupId = newIdSpec.getField('groupId');
> +
> +  if (userId == 'OWNER') {
> +    userId = '@owner';
> +  } else if (userId == 'VIEWER') {
> +    userId = '@viewer';
> +  } else if (opensocial.Container.isArray(newIdSpec)) {
> +    for (var i = 0; i < newIdSpec.length; i++) {
> +      // TODO: We will need multiple urls here....don't want to think
> about
> +      // that yet


don't we handle this now?
the todo should be removed and replaced with the right impl.


>
> +    }
> +  }
> +
> +  if (groupId == 'FRIENDS') {
> +    groupId = "@friends";
> +  } else if (!groupId) {
> +    groupId = "@self";
> +  }
> +
> +  return { userId : userId, groupId : groupId};
> +};
> +
> +JsonRpcContainer.prototype.newFetchPersonRequest = function(id,
> opt_params) {
> +  var peopleRequest = this.newFetchPeopleRequest(
> +      this.makeIdSpec(id), opt_params);
> +
> +  var me = this;
> +  return new JsonRpcRequestItem(peopleRequest.rpc,
> +      function(rawJson) {
> +        return me.createPersonFromJson(rawJson);
> +      });
> +};
> +
> +JsonRpcContainer.prototype.newFetchPeopleRequest = function(idSpec,
> +                                                            opt_params) {
> +  var rpc = { method : "people.get" };
> +  rpc.params = this.translateIdSpec(idSpec);
> +  if (opt_params['profileDetail']) {
> +    rpc.params.fields = opt_params['profileDetail'];
> +  }
> +  if (opt_params['first']) {
> +    rpc.params.startIndex = opt_params['first'];
> +  }
> +  if (opt_params['max']) {
> +    rpc.params.count = opt_params['max'];
> +  }
> +  if (opt_params['sortOrder']) {
> +    rpc.params.orderBy = opt_params['sortOrder'];
> +  }
> +  if (opt_params['filter']) {
> +    rpc.params.filterBy = opt_params['filter'];
> +  }
> +  if (idSpec.getField('networkDistance')) {
> +    rpc.params.networkDistance = idSpec.getField('networkDistance');
> +  }
> +
> +  var me = this;
> +  return new JsonRpcRequestItem(rpc,
> +      function(rawJson) {
> +        var jsonPeople;
> +        if (rawJson['list']) {
> +          // For the array of people response
> +          jsonPeople = rawJson['list'];
> +        } else {
> +          // For the single person response
> +          jsonPeople = [rawJson];
> +        }
> +
> +        var people = [];
> +        for (var i = 0; i < jsonPeople.length; i++) {
> +          people.push(me.createPersonFromJson(jsonPeople[i]));
> +        }
> +        return new opensocial.Collection(people,
> +            rawJson['startIndex'], rawJson['totalResults']);
> +      });
> +};
> +
> +JsonRpcContainer.prototype.createPersonFromJson = function(serverJson) {
> +  return new JsonPerson(serverJson);
> +};
> +
> +JsonRpcContainer.prototype.getFieldsList = function(keys) {
> +  // datarequest.js guarantees that keys is an array
> +  if (this.hasNoKeys(keys) || this.isWildcardKey(keys[0])) {
> +    return [];
> +  } else {
> +    return keys;
> +  }
> +};
> +
> +JsonRpcContainer.prototype.hasNoKeys = function(keys) {
> +  return !keys || keys.length == 0;
> +};
> +
> +JsonRpcContainer.prototype.isWildcardKey = function(key) {
> +  // Some containers support * to mean all keys in the js apis.
> +  // This allows the RESTful apis to be compatible with them.
> +  return key == "*";
> +};
> +
> +JsonRpcContainer.prototype.newFetchPersonAppDataRequest = function(idSpec,
> +                                                                   keys,
> opt_params) {
> +  var rpc = { method : "appdata.get" };
> +  rpc.params = this.translateIdSpec(idSpec);
> +  rpc.params.app = "@app";
> +  rpc.params.fields = this.getFieldsList(keys);
> +  if (idSpec.getField('networkDistance')) {
> +    rpc.params.networkDistance = idSpec.getField('networkDistance');
> +  }
> +
> +  return new JsonRpcRequestItem(rpc,
> +      function (appData) {
> +        return  opensocial.Container.escape(appData['data'], opt_params,
> true);
> +      });
> +};
> +
> +JsonRpcContainer.prototype.newUpdatePersonAppDataRequest = function(id,
> key,
> +                                                                    value)
> {


your indent style seems off for your js files. this should be 4 spaces in.
this occurs in several places.


>
> +  var rpc = { method : "appdata.update" };
> +  rpc.params = this.translateIdSpec(this.makeIdSpec(id));
> +  rpc.params.app = "@app";
> +  rpc.params.data = {};
> +  rpc.params.data[key] = value;
> +  return new JsonRpcRequestItem(rpc);
> +};
> +
> +JsonRpcContainer.prototype.newRemovePersonAppDataRequest = function(id,
> keys) {
> +  var rpc = { method : "appdata.delete" };
> +  rpc.params = this.translateIdSpec(this.makeIdSpec(id));
> +  rpc.params.app = "@app";
> +  rpc.params.keys = keys;
> +
> +  return new JsonRpcRequestItem(rpc);
> +};
> +
> +JsonRpcContainer.prototype.newFetchActivitiesRequest = function(idSpec,
> +
>  opt_params) {
> +  var rpc = { method : "activities.get" };
> +  rpc.params = this.translateIdSpec(idSpec);
> +  rpc.params.app = "@app";
> +  if (idSpec.getField('networkDistance')) {
> +    rpc.params.networkDistance = idSpec.getField('networkDistance');
> +  }
> +
> +  return new JsonRpcRequestItem(rpc,
> +      function(rawJson) {
> +        rawJson = rawJson['list'];
> +        var activities = [];
> +        for (var i = 0; i < rawJson.length; i++) {
> +          activities.push(new JsonActivity(rawJson[i]));
> +        }
> +        return new opensocial.Collection(activities);
> +      });
> +};
> +
> +JsonRpcContainer.prototype.newActivity = function(opt_params) {
> +  return new JsonActivity(opt_params, true);
> +};
> +
> +JsonRpcContainer.prototype.newMediaItem = function(mimeType, url,
> opt_params) {
> +  opt_params = opt_params || {};
> +  opt_params['mimeType'] = mimeType;
> +  opt_params['url'] = url;
> +  return new JsonMediaItem(opt_params);
> +};
> +
> +JsonRpcContainer.prototype.newCreateActivityRequest = function(idSpec,
> +                                                               activity) {
> +  var rpc = { method : "activities.create" };
> +  rpc.params = this.translateIdSpec(idSpec);
> +  rpc.params.app = "@app";
> +  if (idSpec.getField('networkDistance')) {
> +    rpc.params.networkDistance = idSpec.getField('networkDistance');
> +  }
> +  rpc.params.activity = activity.toJsonObject();
> +
> +  return new JsonRpcRequestItem(rpc);
> +};
> +
> +var JsonRpcRequestItem = function(rpc, opt_processData) {
> +  this.rpc = rpc;
> +  this.processData = opt_processData ||
> +                     function (rawJson) {
> +                       return rawJson;
> +                     };
> +
> +  this.processResponse = function(originalDataRequest, rawJson, error,
> +                                  errorMessage) {
> +    return new opensocial.ResponseItem(originalDataRequest,
> +        error ? null : this.processData(rawJson), error, errorMessage);
> +  }
> +};
>
> Modified:
> incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> --- incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> (original)
> +++ incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> Tue Aug 19 21:14:39 2008
> @@ -19,8 +19,7 @@
>  /**
>  * @fileoverview RESTful based opensocial container.
>  *
> - * TODO: We should probably use a url builder of some sort to construct
> the restful urls.
> - * They are getting a little too complex for string concatenation
> + * TODO: THIS IS NOW DEPRECATED. Remove once PHP implements rpc support
>  */
>
>  var RestfulContainer = function(baseUrl, domain, supportedFieldsArray) {
> @@ -133,8 +132,8 @@
>   };
>
>   gadgets.io.makeNonProxiedRequest(
> -    this.baseUrl_ + "/jsonBatch?st=" +
> encodeURIComponent(shindig.auth.getSecurityToken()),
> -    sendResponse, makeRequestParams, "application/json");
> +      this.baseUrl_ + "/rest/jsonBatch?st=" +
> encodeURIComponent(shindig.auth.getSecurityToken()),
> +      sendResponse, makeRequestParams, "application/json");
>  };
>
>  RestfulContainer.generateErrorResponse = function(result, requestObjects,
> callback) {
> @@ -163,8 +162,8 @@
>   } else if (httpError == "Error 404") {
>     return opensocial.ResponseItem.Error.BAD_REQUEST;
>   // TODO: Which one should the limit exceeded error be?
> -  // } else if (httpError == "Error ???") {
> -  //   return opensocial.ResponseItem.Error.LIMIT_EXCEEDED;
> +    // } else if (httpError == "Error ???") {
> +    //   return opensocial.ResponseItem.Error.LIMIT_EXCEEDED;
>   }
>  };
>
>
> Modified: incubator/shindig/trunk/features/pom.xml
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/pom.xml?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> --- incubator/shindig/trunk/features/pom.xml (original)
> +++ incubator/shindig/trunk/features/pom.xml Tue Aug 19 21:14:39 2008
> @@ -17,7 +17,9 @@
>  specific language governing permissions and limitations
>  under the License.
>  -->
> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd
> ">
> +<project xmlns="http://maven.apache.org/POM/4.0.0"
> +         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> +         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>
>   <parent>
> @@ -32,18 +34,21 @@
>
>   <name>Apache Shindig Features</name>
>   <description>Packages all the features that shindig provides into a
> single jar file to allow
> -               loading from the classpath</description>
> +    loading from the classpath
> +  </description>
>
>   <scm>
> -    <connection>scm:svn:
> http://svn.apache.org/repos/asf/incubator/shindig/trunk/features
> </connection>
> -    <developerConnection>scm:svn:
> https://svn.apache.org/repos/asf/incubator/shindig/trunk/features
> </developerConnection>
> +    <connection>scm:svn:
> http://svn.apache.org/repos/asf/incubator/shindig/trunk/features
> +    </connection>
> +    <developerConnection>scm:svn:
> https://svn.apache.org/repos/asf/incubator/shindig/trunk/features
> +    </developerConnection>
>     <url>http://svn.apache.org/viewvc/incubator/shindig/trunk/features
> </url>
>   </scm>
>
>   <build>
>     <plugins>
>       <plugin>
> -        <groupId>org.apache.maven.plugins </groupId>
> +        <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-eclipse-plugin</artifactId>
>       </plugin>
>       <plugin>
> @@ -60,90 +65,91 @@
>             <goals>
>               <goal>compress</goal>
>             </goals>
> -            </execution>
> -          </executions>
> -          <configuration>
> -            <suffix>.opt</suffix>
> -            <excludes>
> -              <exclude>target/**</exclude>
> -              <!-- don't bother with other file types. -->
> -              <exclude>**/*.xml</exclude>
> -              <exclude>**/*.html</exclude>
> -              <exclude>**/*.gif</exclude>
> -              <exclude>**/*.jpeg</exclude>
> -              <exclude>**/*.png</exclude>
> -              <!-- Caja is already minified -->
> -              <exclude>**/caja/*.js</exclude>
> -            </excludes>
> -          </configuration>
> -        </plugin>
> -        <plugin>
> -          <groupId>de.berlios.jsunit</groupId>
> -          <artifactId>jsunit-maven2-plugin</artifactId>
> -          <executions>
> -            <execution>
> -              <configuration>
> -                <sourceDirectory>${basedir}</sourceDirectory>
> -                <sources>
> -                  <source>mocks/env.js</source>
> -                  <source>mocks/xhr.js</source>
> -                  <source>core/config.js</source>
> -                  <source>core/json.js</source>
> -                  <source>core/auth.js</source>
> -                  <source>core/util.js</source>
> -                  <source>core/prefs.js</source>
> -                  <source>core.io/io.js</source>
> -                  <source>views/views.js</source>
> -                  <source>opensocial-reference/opensocial.js</source>
> -                  <source>opensocial-reference/activity.js</source>
> -                  <source>opensocial-reference/address.js</source>
> -                  <source>opensocial-reference/bodytype.js</source>
> -                  <source>opensocial-reference/collection.js</source>
> -                  <source>opensocial-reference/container.js</source>
> -                  <source>opensocial-reference/datarequest.js</source>
> -                  <source>opensocial-reference/dataresponse.js</source>
> -                  <source>opensocial-reference/email.js</source>
> -                  <source>opensocial-reference/enum.js</source>
> -                  <source>opensocial-reference/environment.js</source>
> -                  <source>opensocial-reference/idspec.js</source>
> -                  <source>opensocial-reference/mediaitem.js</source>
> -                  <source>opensocial-reference/message.js</source>
> -                  <source>opensocial-reference/name.js</source>
> -
>  <source>opensocial-reference/navigationparameters.js</source>
> -                  <source>opensocial-reference/organization.js</source>
> -                  <source>opensocial-reference/person.js</source>
> -                  <source>opensocial-reference/phone.js</source>
> -                  <source>opensocial-reference/responseitem.js</source>
> -                  <source>opensocial-reference/url.js</source>
> -                  <source>opensocial-current/jsonactivity.js</source>
> -                  <source>opensocial-current/jsonperson.js</source>
> -                  <source>opensocial-current/restfulcontainer.js</source>
> -                </sources>
> -                <testSourceDirectory>${basedir}</testSourceDirectory>
> -                <testSuites>
> -                   <testSuite>
> -                    <name>GadgetsJSAPITests</name>
> -                    <type>TESTCASES</type>
> -                    <includes>
> -                      <include>core/*test.js</include>
> -                      <include>core.io/*test.js</include>
> -                      <include>views/*test.js</include>
> -                    </includes>
> -                  </testSuite>
> -                 <testSuite>
> -                    <name>OpenSocialJsTests</name>
> -                    <type>TESTCASES</type>
> -                    <includes>
> -                      <include>opensocial-reference/*test.js</include>
> -                      <include>opensocial-current/*test.js</include>
> -                    </includes>
> -                  </testSuite>
> -                </testSuites>
> -              </configuration>
> -              <goals>
> -                <goal>jsunit-test</goal>
> -              </goals>
> -            </execution>
> +          </execution>
> +        </executions>
> +        <configuration>
> +          <suffix>.opt</suffix>
> +          <excludes>
> +            <exclude>target/**</exclude>
> +            <!-- don't bother with other file types. -->
> +            <exclude>**/*.xml</exclude>
> +            <exclude>**/*.html</exclude>
> +            <exclude>**/*.gif</exclude>
> +            <exclude>**/*.jpeg</exclude>
> +            <exclude>**/*.png</exclude>
> +            <!-- Caja is already minified -->
> +            <exclude>**/caja/*.js</exclude>
> +          </excludes>
> +        </configuration>
> +      </plugin>
> +      <plugin>
> +        <groupId>de.berlios.jsunit</groupId>
> +        <artifactId>jsunit-maven2-plugin</artifactId>
> +        <executions>
> +          <execution>
> +            <configuration>
> +              <sourceDirectory>${basedir}</sourceDirectory>
> +              <sources>
> +                <source>mocks/env.js</source>
> +                <source>mocks/xhr.js</source>
> +                <source>core/config.js</source>
> +                <source>core/json.js</source>
> +                <source>core/auth.js</source>
> +                <source>core/util.js</source>
> +                <source>core/prefs.js</source>
> +                <source>core.io/io.js</source>
> +                <source>views/views.js</source>
> +                <source>opensocial-reference/opensocial.js</source>
> +                <source>opensocial-reference/activity.js</source>
> +                <source>opensocial-reference/address.js</source>
> +                <source>opensocial-reference/bodytype.js</source>
> +                <source>opensocial-reference/collection.js</source>
> +                <source>opensocial-reference/container.js</source>
> +                <source>opensocial-reference/datarequest.js</source>
> +                <source>opensocial-reference/dataresponse.js</source>
> +                <source>opensocial-reference/email.js</source>
> +                <source>opensocial-reference/enum.js</source>
> +                <source>opensocial-reference/environment.js</source>
> +                <source>opensocial-reference/idspec.js</source>
> +                <source>opensocial-reference/mediaitem.js</source>
> +                <source>opensocial-reference/message.js</source>
> +                <source>opensocial-reference/name.js</source>
> +
>  <source>opensocial-reference/navigationparameters.js</source>
> +                <source>opensocial-reference/organization.js</source>
> +                <source>opensocial-reference/person.js</source>
> +                <source>opensocial-reference/phone.js</source>
> +                <source>opensocial-reference/responseitem.js</source>
> +                <source>opensocial-reference/url.js</source>
> +                <source>opensocial-current/jsonactivity.js</source>
> +                <source>opensocial-current/jsonperson.js</source>
> +                <source>opensocial-current/restfulcontainer.js</source>
> +                <source>opensocial-current/jsonrpccontainer.js</source>
> +              </sources>
> +              <testSourceDirectory>${basedir}</testSourceDirectory>
> +              <testSuites>
> +                <testSuite>
> +                  <name>GadgetsJSAPITests</name>
> +                  <type>TESTCASES</type>
> +                  <includes>
> +                    <include>core/*test.js</include>
> +                    <include>core.io/*test.js</include>
> +                    <include>views/*test.js</include>
> +                  </includes>
> +                </testSuite>
> +                <testSuite>
> +                  <name>OpenSocialJsTests</name>
> +                  <type>TESTCASES</type>
> +                  <includes>
> +                    <include>opensocial-reference/*test.js</include>
> +                    <include>opensocial-current/*test.js</include>
> +                  </includes>
> +                </testSuite>
> +              </testSuites>
> +            </configuration>
> +            <goals>
> +              <goal>jsunit-test</goal>
> +            </goals>
> +          </execution>
>         </executions>
>       </plugin>
>     </plugins>
>
> Modified:
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingTask.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingTask.java?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingTask.java
> (original)
> +++
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingTask.java
> Tue Aug 19 21:14:39 2008
> @@ -19,8 +19,6 @@
>
>  package org.apache.shindig.gadgets.servlet;
>
> -import com.google.inject.Inject;
> -
>  import org.apache.shindig.common.ContainerConfig;
>  import org.apache.shindig.common.SecurityToken;
>  import org.apache.shindig.common.SecurityTokenDecoder;
> @@ -42,6 +40,9 @@
>  import org.apache.shindig.gadgets.spec.ModulePrefs;
>  import org.apache.shindig.gadgets.spec.Preload;
>  import org.apache.shindig.gadgets.spec.View;
> +
> +import com.google.inject.Inject;
> +
>  import org.json.JSONArray;
>  import org.json.JSONException;
>  import org.json.JSONObject;
>
> Modified:
> incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.full.xml
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.full.xml?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.full.xml
> (original)
> +++
> incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.full.xml Tue
> Aug 19 21:14:39 2008
> @@ -18,15 +18,17 @@
>   under the License.
>  -->
>  <!DOCTYPE web-app
> -        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> -        "http://java.sun.com/dtd/web-app_2_3.dtd">
> +    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> +    "http://java.sun.com/dtd/web-app_2_3.dtd">
>
>  <web-app>
>   <!-- configuration -->
>   <!-- If you have your own Guice module(s), put them here as a
> colon-separated list. -->
>   <context-param>
>     <param-name>guice-modules</param-name>
> -
>  <param-value>org.apache.shindig.gadgets.servlet.HttpGuiceModule:org.apache.shindig.social.core.config.SocialApiGuiceModule</param-value>
> +    <param-value>
> +
>  org.apache.shindig.gadgets.servlet.HttpGuiceModule:org.apache.shindig.social.core.config.SocialApiGuiceModule
> +    </param-value>
>   </context-param>
>
>   <filter>
> @@ -104,6 +106,14 @@
>     </servlet-class>
>   </servlet>
>
> +  <!-- Serve RPC api -->
> +  <servlet>
> +    <servlet-name>jsonRpcServlet</servlet-name>
> +    <servlet-class>
> +      org.apache.shindig.social.opensocial.service.JsonRpcServlet
> +    </servlet-class>
> +  </servlet>
> +
>   <servlet-mapping>
>     <servlet-name>js</servlet-name>
>     <url-pattern>/gadgets/js/*</url-pattern>
> @@ -143,4 +153,9 @@
>     <servlet-name>restapiServlet</servlet-name>
>     <url-pattern>/social/rest/*</url-pattern>
>   </servlet-mapping>
> +
> +  <servlet-mapping>
> +    <servlet-name>jsonRpcServlet</servlet-name>
> +    <url-pattern>/social/rpc/*</url-pattern>
> +  </servlet-mapping>
>  </web-app>
>
> Modified:
> incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.social.xml
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.social.xml?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.social.xml
> (original)
> +++
> incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.social.xml
> Tue Aug 19 21:14:39 2008
> @@ -18,8 +18,8 @@
>   under the License.
>  -->
>  <!DOCTYPE web-app
> -        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> -        "http://java.sun.com/dtd/web-app_2_3.dtd">
> +    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> +    "http://java.sun.com/dtd/web-app_2_3.dtd">
>
>  <web-app>
>   <!-- configuration -->
> @@ -51,8 +51,21 @@
>     </servlet-class>
>   </servlet>
>
> +  <!-- Serve RPC api -->
> +  <servlet>
> +    <servlet-name>jsonRpcServlet</servlet-name>
> +    <servlet-class>
> +      org.apache.shindig.social.opensocial.service.JsonRpcServlet
> +    </servlet-class>
> +  </servlet>
> +
>   <servlet-mapping>
>     <servlet-name>restapiServlet</servlet-name>
>     <url-pattern>/social/rest/*</url-pattern>
>   </servlet-mapping>
> +
> +  <servlet-mapping>
> +    <servlet-name>jsonRpcServlet</servlet-name>
> +    <url-pattern>/social/rpc/*</url-pattern>
> +  </servlet-mapping>
>  </web-app>
>
> Modified:
> incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> --- incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml
> (original)
> +++ incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml Tue
> Aug 19 21:14:39 2008
> @@ -18,17 +18,19 @@
>   under the License.
>  -->
>  <!DOCTYPE web-app
> -        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> -        "http://java.sun.com/dtd/web-app_2_3.dtd">
> +    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> +    "http://java.sun.com/dtd/web-app_2_3.dtd">
>
>  <web-app>
>   <!-- configuration -->
>   <!-- If you have your own Guice module(s), put them here as a
> colon-separated list. -->
>   <context-param>
>     <param-name>guice-modules</param-name>
> -
>  <param-value>org.apache.shindig.gadgets.servlet.HttpGuiceModule:org.apache.shindig.social.core.config.SocialApiGuiceModule</param-value>
> +    <param-value>
> +
>  org.apache.shindig.gadgets.servlet.HttpGuiceModule:org.apache.shindig.social.core.config.SocialApiGuiceModule
> +    </param-value>
>   </context-param>
> -
> +
>   <filter>
>     <filter-name>oauthFilter</filter-name>
>
> <filter-class>org.apache.shindig.social.core.oauth.AuthenticationServletFilter</filter-class>
> @@ -105,6 +107,14 @@
>     </servlet-class>
>   </servlet>
>
> +  <!-- Serve RPC api -->
> +  <servlet>
> +    <servlet-name>jsonRpcServlet</servlet-name>
> +    <servlet-class>
> +      org.apache.shindig.social.opensocial.service.JsonRpcServlet
> +    </servlet-class>
> +  </servlet>
> +
>   <servlet-mapping>
>     <servlet-name>js</servlet-name>
>     <url-pattern>/gadgets/js/*</url-pattern>
> @@ -144,4 +154,9 @@
>     <servlet-name>restapiServlet</servlet-name>
>     <url-pattern>/social/rest/*</url-pattern>
>   </servlet-mapping>
> +
> +  <servlet-mapping>
> +    <servlet-name>jsonRpcServlet</servlet-name>
> +    <url-pattern>/social/rpc/*</url-pattern>
> +  </servlet-mapping>
>  </web-app>
>
> Modified:
> incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java
> (original)
> +++
> incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java
> Tue Aug 19 21:14:39 2008
> @@ -17,15 +17,16 @@
>  */
>  package org.apache.shindig.server.endtoend;
>
> -import com.google.common.base.Join;
> -import com.google.common.collect.Maps;
> -
>  import org.apache.shindig.common.servlet.GuiceServletContextListener;
>  import org.apache.shindig.gadgets.servlet.ConcatProxyServlet;
>  import org.apache.shindig.gadgets.servlet.GadgetRenderingServlet;
>  import org.apache.shindig.gadgets.servlet.HttpGuiceModule;
> -import org.apache.shindig.social.opensocial.service.DataServiceServlet;
>  import org.apache.shindig.social.core.oauth.AuthenticationServletFilter;
> +import org.apache.shindig.social.opensocial.service.DataServiceServlet;
> +import org.apache.shindig.social.opensocial.service.JsonRpcServlet;
> +
> +import com.google.common.base.Join;
> +import com.google.common.collect.Maps;
>
>  import org.mortbay.jetty.Server;
>  import org.mortbay.jetty.handler.ResourceHandler;
> @@ -51,7 +52,8 @@
>  public class EndToEndServer {
>   private static final int JETTY_PORT = 9003;
>   private static final String GADGET_BASE = "/gadgets/ifr";
> -  private static final String JSON_BASE = "/social/rest/*";
> +  private static final String REST_BASE = "/social/rest/*";
> +  private static final String JSON_RPC_BASE = "/social/rpc/*";
>   private static final String CONCAT_BASE = "/gadgets/concat";
>   public static final String SERVER_URL = "http://localhost:" +
> JETTY_PORT;
>   public static final String GADGET_BASEURL = SERVER_URL + GADGET_BASE;
> @@ -112,10 +114,16 @@
>     context.addServlet(gadgetServletHolder, GADGET_BASE);
>
>     // Attach DataServiceServlet, wrapped in a proxy to fake errors
> -    ServletHolder jsonServletHolder = new ServletHolder(new
> ForceErrorServlet(
> +    ServletHolder restServletHolder = new ServletHolder(new
> ForceErrorServlet(
>         new DataServiceServlet()));
> -    context.addServlet(jsonServletHolder, JSON_BASE);
> -    context.addFilter(AuthenticationServletFilter.class, JSON_BASE, 0);
> +    context.addServlet(restServletHolder, REST_BASE);
> +    context.addFilter(AuthenticationServletFilter.class, REST_BASE, 0);
> +
> +    // Attach JsonRpcServlet, wrapped in a proxy to fake errors
> +    ServletHolder rpcServletHolder = new ServletHolder(new
> ForceErrorServlet(
> +        new JsonRpcServlet()));
> +    context.addServlet(rpcServletHolder, JSON_RPC_BASE);
> +    context.addFilter(AuthenticationServletFilter.class, JSON_RPC_BASE,
> 0);
>
>     // Attach the ConcatProxyServlet - needed for
>     ServletHolder concatHolder = new ServletHolder(new
> ConcatProxyServlet());
>
> Modified:
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ActivityHandler.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ActivityHandler.java?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ActivityHandler.java
> (original)
> +++
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ActivityHandler.java
> Tue Aug 19 21:14:39 2008
> @@ -31,7 +31,7 @@
>
>  public class ActivityHandler extends DataRequestHandler {
>
> -  private ActivityService service;
> +  private final ActivityService service;
>
>   // TODO: The appId should come from the url. The spec needs to be fixed!
>   private static final String ACTIVITY_ID_PATH =
> "/activities/{userId}+/{groupId}/{activityId}+";
> @@ -50,7 +50,7 @@
>    * examples: /activities/john.doe/@self/1
>    */
>   protected Future<? extends ResponseItem> handleDelete(RequestItem
> request) {
> -    request.parseUrlWithTemplate(ACTIVITY_ID_PATH);
> +    request.applyUrlTemplate(ACTIVITY_ID_PATH);
>
>     Set<UserId> userIds = request.getUsers();
>     Set<String> activityIds =
> Sets.newLinkedHashSet(request.getListParameter("activityId"));
> @@ -77,7 +77,7 @@
>    * examples: /activities/john.doe/@self - postBody is an activity object
>    */
>   protected Future<? extends ResponseItem> handlePost(RequestItem request)
> {
> -    request.parseUrlWithTemplate(GROUP_PATH);
> +    request.applyUrlTemplate(GROUP_PATH);
>
>     Set<UserId> userIds = request.getUsers();
>     List<String> activityIds = request.getListParameter("activityId");
> @@ -88,7 +88,8 @@
>     Preconditions.requireEmpty(activityIds, "Cannot specify activityId in
> create");
>
>     return service.createActivity(userIds.iterator().next(),
> request.getGroup(),
> -        request.getAppId(), request.getFields(),
> request.getPostData(Activity.class),
> +        request.getAppId(), request.getFields(),
> +        request.getTypedParameter("activity", Activity.class),
>         request.getToken());
>   }
>
> @@ -100,7 +101,7 @@
>    * /activities/john.doe,jane.doe/@friends
>    */
>   protected Future<? extends ResponseItem> handleGet(RequestItem request) {
> -    request.parseUrlWithTemplate(ACTIVITY_ID_PATH);
> +    request.applyUrlTemplate(ACTIVITY_ID_PATH);
>
>     Set<UserId> userIds = request.getUsers();
>     Set<String> optionalActivityIds =
> Sets.newLinkedHashSet(request.getListParameter("activityId"));
>
> Added:
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ApiServlet.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ApiServlet.java?rev=687235&view=auto
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ApiServlet.java
> (added)
> +++
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ApiServlet.java
> Tue Aug 19 21:14:39 2008
> @@ -0,0 +1,103 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations under the
> License.
> + */
> +package org.apache.shindig.social.opensocial.service;
> +
> +import org.apache.shindig.common.SecurityToken;
> +import org.apache.shindig.common.servlet.InjectedServlet;
> +import org.apache.shindig.common.util.ImmediateFuture;
> +import org.apache.shindig.social.ResponseError;
> +import org.apache.shindig.social.ResponseItem;
> +import org.apache.shindig.social.core.oauth.AuthenticationServletFilter;
> +import org.apache.shindig.social.core.util.BeanJsonConverter;
> +
> +import com.google.inject.Inject;
> +import com.google.inject.Injector;
> +import com.google.inject.name.Named;
> +
> +import java.util.Map;
> +import java.util.concurrent.ExecutionException;
> +import java.util.concurrent.Future;
> +
> +import javax.servlet.http.HttpServletRequest;
> +
> +/**
> + * Common base class for API servlets.
> + */
> +public class ApiServlet extends InjectedServlet {
> +
> +  private Map<String, Class<? extends DataRequestHandler>> handlers;
> +
> +  protected BeanJsonConverter jsonConverter;
> +
> +  protected BeanConverter xmlConverter;
> +
> +  @Inject
> +  public void setHandlers(HandlerProvider handlers) {
> +    this.handlers = handlers.get();
> +  }
> +
> +  @Inject
> +  public void setBeanConverters(
> +      @Named("shindig.bean.converter.json")BeanConverter jsonConverter,
> +      @Named("shindig.bean.converter.xml")BeanConverter xmlConverter) {
> +    // fix this
> +    this.jsonConverter = (BeanJsonConverter) jsonConverter;
> +    this.xmlConverter = xmlConverter;
> +  }
> +
> +  // Only for testing use. Do not override the injector.
> +  public void setInjector(Injector injector) {
> +    this.injector = injector;
> +  }
> +
> +  protected SecurityToken getSecurityToken(HttpServletRequest
> servletRequest) {
> +    return ((AuthenticationServletFilter.SecurityTokenRequest)
> servletRequest).getToken();
> +  }
> +
> +  /**
> +   * Delivers a request item to the appropriate DataRequestHandler.
> +   */
> +  protected Future<? extends ResponseItem> handleRequestItem(RequestItem
> requestItem) {
> +    Class<? extends DataRequestHandler> handlerClass =
> handlers.get(requestItem.getService());
> +
> +    if (handlerClass == null) {
> +      return ImmediateFuture.newInstance(new
> ResponseItem<Object>(ResponseError.NOT_IMPLEMENTED,
> +          "The service " + requestItem.getService() + " is not
> implemented", null));
> +    }
> +
> +    DataRequestHandler handler = injector.getInstance(handlerClass);
> +    return handler.handleItem(requestItem);
> +  }
> +
> +  protected ResponseItem getResponseItem(Future<? extends ResponseItem>
> future) {
> +    ResponseItem response;
> +    try {
> +      // TODO: use timeout methods?
> +      response = future.get();
> +    } catch (InterruptedException ie) {
> +      response = responseItemFromException(ie);
> +    } catch (ExecutionException ee) {
> +      response = responseItemFromException(ee.getCause());
> +    }
> +    return response;
> +  }
> +
> +  protected ResponseItem<?> responseItemFromException(Throwable t) {
> +    return new ResponseItem<Void>(ResponseError.INTERNAL_ERROR,
> t.getMessage(), null);
> +  }
> +}
>
> Modified:
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/AppDataHandler.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/AppDataHandler.java?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/AppDataHandler.java
> (original)
> +++
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/AppDataHandler.java
> Tue Aug 19 21:14:39 2008
> @@ -32,7 +32,7 @@
>
>  public class AppDataHandler extends DataRequestHandler {
>
> -  private AppDataService service;
> +  private final AppDataService service;
>
>   private static final String APP_DATA_PATH =
> "/people/{userId}+/{groupId}/{appId}";
>
> @@ -51,7 +51,7 @@
>    * overridden.
>    */
>   protected Future<? extends ResponseItem> handleDelete(RequestItem
> request) {
> -    request.parseUrlWithTemplate(APP_DATA_PATH);
> +    request.applyUrlTemplate(APP_DATA_PATH);
>
>     Set<UserId> userIds = request.getUsers();
>
> @@ -84,14 +84,14 @@
>    * values and set. If there are no fields vars then all of the data will
> be overridden.
>    */
>   protected Future<? extends ResponseItem> handlePost(RequestItem request)
> {
> -    request.parseUrlWithTemplate(APP_DATA_PATH);
> +    request.applyUrlTemplate(APP_DATA_PATH);
>
>     Set<UserId> userIds = request.getUsers();
>
>     Preconditions.requireNotEmpty(userIds, "No userId specified");
>     Preconditions.requireSingular(userIds, "Multiple userIds not
> supported");
>
> -    Map<String, String> values = request.getPostData(HashMap.class);
> +    Map<String, String> values = request.getTypedParameter("data",
> HashMap.class);
>     for (String key : values.keySet()) {
>       if (!isValidKey(key)) {
>         return ImmediateFuture.newInstance(new
> ResponseItem<Object>(ResponseError.BAD_REQUEST,
> @@ -109,7 +109,7 @@
>    * examples: /appdata/john.doe/@friends/app?fields=count
> /appdata/john.doe/@self/app
>    */
>   protected Future<? extends ResponseItem> handleGet(RequestItem request) {
> -    request.parseUrlWithTemplate(APP_DATA_PATH);
> +    request.applyUrlTemplate(APP_DATA_PATH);
>
>     Set<UserId> userIds = request.getUsers();
>
>
> Modified:
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataRequestHandler.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataRequestHandler.java?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataRequestHandler.java
> (original)
> +++
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataRequestHandler.java
> Tue Aug 19 21:14:39 2008
> @@ -21,32 +21,44 @@
>  import org.apache.shindig.social.ResponseError;
>  import org.apache.shindig.social.ResponseItem;
>
> +import com.google.common.collect.Sets;
> +
>  import java.util.Collection;
> +import java.util.Set;
>  import java.util.concurrent.Future;
>
>  public abstract class DataRequestHandler {
>
> +  private static final Set<String> GET_SYNONYMS = Sets.newHashSet("get");
> +  private static final Set<String> CREATE_SYNONYMS =
> Sets.newHashSet("put", "create");
> +  private static final Set<String> UPDATE_SYNONYMS =
> Sets.newHashSet("post", "update");
> +  private static final Set<String> DELETE_SYNONYMS =
> Sets.newHashSet("delete", "delete");
> +
>   public Future<? extends ResponseItem> handleItem(RequestItem request) {
> -    String httpMethod = request.getMethod();
> +    if (request.getOperation() == null) {
> +      return error(ResponseError.NOT_IMPLEMENTED, "Unserviced operation ",
> null);
> +    }
> +    String operation = request.getOperation().toLowerCase();
>     Future<? extends ResponseItem> responseItem;
> -
>     try {
> -      if ("GET".equals(httpMethod)) {
> +      if (GET_SYNONYMS.contains(operation)) {
>         responseItem = handleGet(request);
> -      } else if ("POST".equals(httpMethod)) {
> +      } else if (UPDATE_SYNONYMS.contains(operation)) {
>         responseItem = handlePost(request);
> -      } else if ("PUT".equals(httpMethod)) {
> +      } else if (CREATE_SYNONYMS.contains(operation)) {
>         responseItem = handlePut(request);
> -      } else if ("DELETE".equals(httpMethod)) {
> +      } else if (DELETE_SYNONYMS.contains(operation)) {
>         responseItem = handleDelete(request);
>       } else {
> -        return error(ResponseError.NOT_IMPLEMENTED, "Unserviced Http
> method type", httpMethod);
> +        return error(ResponseError.NOT_IMPLEMENTED, "Unserviced
> operation", operation);
>       }
> -      return responseItem;
>     } catch (IllegalArgumentException iae) {
> -      // Upconvert IllegalArgumentExceptions to errors.
> +      // Upconvert IllegalArgumentExceptions to BAD_REQUEST.
>       return error(ResponseError.BAD_REQUEST, iae.getMessage(), null);
> +    } catch (Throwable t) {
> +      return error(ResponseError.INTERNAL_ERROR, "Unknown error " +
> t.getMessage(), null);
>     }
> +    return responseItem;
>   }
>
>   protected abstract Future<? extends ResponseItem>
> handleDelete(RequestItem request);
>
> Modified:
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServlet.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServlet.java?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServlet.java
> (original)
> +++
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServlet.java
> Tue Aug 19 21:14:39 2008
> @@ -18,37 +18,19 @@
>  package org.apache.shindig.social.opensocial.service;
>
>  import org.apache.shindig.common.SecurityToken;
> -import org.apache.shindig.common.servlet.InjectedServlet;
> -import org.apache.shindig.common.util.ImmediateFuture;
>  import org.apache.shindig.social.ResponseError;
>  import org.apache.shindig.social.ResponseItem;
> -import org.apache.shindig.social.core.oauth.AuthenticationServletFilter;
>
> -import com.google.common.collect.Maps;
> -import com.google.inject.Inject;
> -import com.google.inject.Injector;
> -import com.google.inject.name.Named;
> -import org.apache.commons.io.IOUtils;
> -import org.apache.commons.lang.StringUtils;
> -import org.json.JSONException;
> -import org.json.JSONObject;
> +import java.io.IOException;
> +import java.io.PrintWriter;
> +import java.util.logging.Logger;
>
>  import javax.servlet.ServletException;
>  import javax.servlet.http.HttpServletRequest;
>  import javax.servlet.http.HttpServletResponse;
> -import java.io.IOException;
> -import java.io.PrintWriter;
> -import java.util.Iterator;
> -import java.util.Map;
> -import java.util.concurrent.ExecutionException;
> -import java.util.concurrent.Future;
> -import java.util.logging.Logger;
>
> -public class DataServiceServlet extends InjectedServlet {
> +public class DataServiceServlet extends ApiServlet {
>
> -  protected static final String X_HTTP_METHOD_OVERRIDE =
> "X-HTTP-Method-Override";
> -  protected static final String SECURITY_TOKEN_PARAM = "st";
> -  protected static final String REQUEST_PARAMETER = "request";
>   protected static final String FORMAT_PARAM = "format";
>   protected static final String ATOM_FORMAT = "atom";
>
> @@ -59,29 +41,6 @@
>   private static final Logger logger = Logger.getLogger(
>       "org.apache.shindig.social.opensocial.spi");
>
> -  private transient Map<String, Class<? extends DataRequestHandler>>
> handlers;
> -  private transient BeanConverter jsonConverter;
> -  private transient BeanConverter xmlConverter;
> -
> -  private static final String JSON_BATCH_ROUTE = "jsonBatch";
> -
> -  @Inject
> -  public void setHandlers(HandlerProvider handlers) {
> -    this.handlers = handlers.get();
> -  }
> -
> -  @Inject
> -  public void setBeanConverters(@Named("shindig.bean.converter.json")
> BeanConverter jsonConverter,
> -    @Named("shindig.bean.converter.xml")  BeanConverter xmlConverter) {
> -    this.jsonConverter = jsonConverter;
> -    this.xmlConverter = xmlConverter;
> -  }
> -
> -  // Only for testing use. Do not override the injector.
> -  public void setInjector(Injector injector) {
> -    this.injector = injector;
> -  }
> -
>   protected void doGet(HttpServletRequest servletRequest,
>       HttpServletResponse servletResponse)
>       throws ServletException, IOException {
> @@ -117,32 +76,22 @@
>
>     BeanConverter converter = getConverterForRequest(servletRequest);
>
> -    if (isBatchUrl(servletRequest)) {
> -      try {
> -        handleBatchRequest(servletRequest, servletResponse, token,
> converter);
> -      } catch (JSONException e) {
> -        sendError(servletResponse, new
> ResponseItem<Object>(ResponseError.BAD_REQUEST,
> -            "The batch request had an invalid format.", null));
> -      }
> -    } else {
> -      handleSingleRequest(servletRequest, servletResponse, token,
> converter);
> -    }
> +    handleSingleRequest(servletRequest, servletResponse, token,
> converter);
>   }
>
>   private void sendError(HttpServletResponse servletResponse, ResponseItem
> responseItem)
>       throws IOException {
>     servletResponse.sendError(responseItem.getError().getHttpErrorCode(),
> -          responseItem.getErrorMessage());
> +        responseItem.getErrorMessage());
>   }
>
> -  /** Handler for non-batch requests */
> +  /**
> +   * Handler for non-batch requests
> +   */
>   private void handleSingleRequest(HttpServletRequest servletRequest,
>       HttpServletResponse servletResponse, SecurityToken token,
>       BeanConverter converter) throws IOException {
> -    String method = getHttpMethodFromParameter(servletRequest.getMethod(),
> -        servletRequest.getParameter(X_HTTP_METHOD_OVERRIDE));
> -
> -    RequestItem requestItem = new RequestItem(servletRequest, token,
> method, converter);
> +    RestfulRequestItem requestItem = new
> RestfulRequestItem(servletRequest, token, converter);
>     ResponseItem responseItem =
> getResponseItem(handleRequestItem(requestItem));
>
>     if (responseItem.getError() == null) {
> @@ -153,81 +102,6 @@
>     }
>   }
>
> -  private void handleBatchRequest(HttpServletRequest servletRequest,
> -      HttpServletResponse servletResponse, SecurityToken token,
> -      BeanConverter converter) throws IOException, JSONException {
> -
> -    byte[] postedBytes =
> IOUtils.toByteArray(servletRequest.getInputStream());
> -    JSONObject requests = new JSONObject(new String(postedBytes));
> -    Map<String, Future<? extends ResponseItem>> responses =
> Maps.newHashMap();
> -
> -    // Gather all Futures.  We do this up front so that
> -    // the first call to get() comes after all futures are created,
> -    // which allows for implementations that batch multiple Futures
> -    // into single requests.
> -    Iterator keys = requests.keys();
> -    while (keys.hasNext()) {
> -      String key = (String) keys.next();
> -      String request = requests.getString(key);
> -
> -      RequestItem requestItem = converter.convertToObject(request,
> RequestItem.class);
> -      requestItem.setToken(token);
> -      requestItem.setConverter(converter);
> -
> -      responses.put(key, handleRequestItem(requestItem));
> -    }
> -
> -    // Resolve each Future into a response.
> -    // TODO: should use shared deadline across each request
> -    Map<String, ResponseItem> resolvedResponses = Maps.newHashMap();
> -    for (Map.Entry<String, Future<? extends ResponseItem>> responseEntry :
> responses.entrySet()) {
> -      ResponseItem response = getResponseItem(responseEntry.getValue());
> -      resolvedResponses.put(responseEntry.getKey(), response);
> -    }
> -
> -    PrintWriter writer = servletResponse.getWriter();
> -    writer.write(converter.convertToString(
> -        Maps.immutableMap("error", false, "responses",
> resolvedResponses)));
> -  }
> -
> -  private ResponseItem getResponseItem(Future<? extends ResponseItem>
> future) {
> -    ResponseItem response;
> -    try {
> -      // TODO: use timeout methods?
> -      response = future.get();
> -    } catch (InterruptedException ie) {
> -      response = responseItemFromException(ie);
> -    } catch (ExecutionException ee) {
> -      response = responseItemFromException(ee.getCause());
> -    }
> -    return response;
> -  }
> -
> -  /**
> -   * Delivers a request item to the appropriate DataRequestHandler.
> -   *
> -   * @return the resulting ResponseItem
> -   */
> -  Future<? extends ResponseItem> handleRequestItem(RequestItem
> requestItem) {
> -    String route = getRouteFromParameter(requestItem.getUrl());
> -    Class<? extends DataRequestHandler> handlerClass =
> handlers.get(route);
> -
> -    if (handlerClass == null) {
> -      return ImmediateFuture.newInstance(new
> ResponseItem<Object>(ResponseError.BAD_REQUEST,
> -          "The url path " + route + " is not supported", null));
> -    }
> -
> -    DataRequestHandler handler = injector.getInstance(handlerClass);
> -    return handler.handleItem(requestItem);
> -  }
> -
> -  private ResponseItem<?> responseItemFromException(Throwable t) {
> -    return new ResponseItem<Void>(ResponseError.INTERNAL_ERROR,
> t.getMessage(), null);
> -  }
> -
> -  SecurityToken getSecurityToken(HttpServletRequest servletRequest) {
> -    return ((AuthenticationServletFilter.SecurityTokenRequest)
> servletRequest).getToken();
> -  }
>
>   BeanConverter getConverterForRequest(HttpServletRequest servletRequest) {
>     String formatString = servletRequest.getParameter(FORMAT_PARAM);
> @@ -236,26 +110,4 @@
>     }
>     return jsonConverter;
>   }
> -
> -  String getHttpMethodFromParameter(String method, String
> overrideParameter) {
> -    if (!StringUtils.isBlank(overrideParameter)) {
> -      return overrideParameter;
> -    } else {
> -      return method;
> -    }
> -  }
> -
> -  String getRouteFromParameter(String pathInfo) {
> -    pathInfo = pathInfo.substring(1);
> -    int indexOfNextPathSeparator = pathInfo.indexOf('/');
> -    if ( indexOfNextPathSeparator != -1 ) {
> -      return pathInfo.substring(0, indexOfNextPathSeparator);
> -    }
> -    return pathInfo;
> -  }
> -
> -  boolean isBatchUrl(HttpServletRequest servletRequest) {
> -    String[] parts = servletRequest.getPathInfo().split("/");
> -    return parts[parts.length - 1].equals(JSON_BATCH_ROUTE);
> -  }
>  }
>
> Modified:
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServletFetcher.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServletFetcher.java?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServletFetcher.java
> (original)
> +++
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServletFetcher.java
> Tue Aug 19 21:14:39 2008
> @@ -15,7 +15,6 @@
>  * KIND, either express or implied. See the License for the
>  * specific language governing permissions and limitations under the
> License.
>  */
> -
>  package org.apache.shindig.social.opensocial.service;
>
>  import org.apache.shindig.common.SecurityTokenDecoder;
> @@ -23,15 +22,16 @@
>
>  import com.google.common.collect.Maps;
>
> -import javax.servlet.http.HttpServletRequest;
>  import java.util.Map;
>
> +import javax.servlet.http.HttpServletRequest;
> +
>  /**
> - * Default implementation for the GadgetDataServlet parameter fetcher. Do
> not
> - * change unless you have a compelling need to pass more parameters into
> the
> - * createResponse method.
> + * Default implementation for the GadgetDataServlet parameter fetcher. Do
> not change unless you have
> + * a compelling need to pass more parameters into the createResponse
> method.
>  */
>  public class DataServiceServletFetcher implements ParameterFetcher {
> +
>   public Map<String, String> fetch(HttpServletRequest req) {
>     return Maps.immutableMap(SecurityTokenDecoder.SECURITY_TOKEN_NAME,
> req.getParameter("st"));
>   }
>
> Added:
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonConversionUtils.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonConversionUtils.java?rev=687235&view=auto
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonConversionUtils.java
> (added)
> +++
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonConversionUtils.java
> Tue Aug 19 21:14:39 2008
> @@ -0,0 +1,201 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations under the
> License.
> + */
> +package org.apache.shindig.social.opensocial.service;
> +
> +import com.google.common.collect.Maps;
> +import com.google.common.collect.Sets;
> +import com.google.common.collect.ImmutableSet;
> +
> +import org.json.JSONArray;
> +import org.json.JSONException;
> +import org.json.JSONObject;
> +
> +import java.util.Iterator;
> +import java.util.Map;
> +import java.util.Set;
> +import java.util.regex.Matcher;
> +import java.util.regex.Pattern;
> +
> +import javax.servlet.http.HttpServletRequest;
> +
> +/**
> + * Utilities for converting a JSON object to and from a URL encoding
> + */
> +public class JsonConversionUtils {
> +
> +  private static final Pattern ARRAY_MATCH =
> Pattern.compile("(\\w+)\\((\\d+)\\)");
> +
> +  private static final Set<String> RESERVED_PARAMS =
> ImmutableSet.of("method", "id", "st");
> +
> +  public static JSONObject fromRequest(HttpServletRequest request) throws
> JSONException {
> +    //String methodName = request.getPathInfo().replaceAll("/", "");
> +
> +    JSONObject root = new JSONObject();
> +    Map<String, String[]> params = (Map<String, String[]>)
> request.getParameterMap();


I still don't understand why you have so much custom code in this class.
This is so specific to json and isn't hidden behind the BeanConverter
interface which means supporting xml is going to be a nightmare...

We could at least build a cleaned up map here from String to String and have
the converter turn that into an object for us.


>
> +    root.put("method", params.get("method")[0]);
> +    if (params.containsKey("id")) {
> +      root.put("id", params.get("id")[0]);
> +    }
> +    JSONObject paramsRoot = new JSONObject();
> +    for (Map.Entry<String, String[]> entry : params.entrySet()) {
> +      if (!RESERVED_PARAMS.contains(entry.getKey().toLowerCase())) {
> +        String[] path = entry.getKey().split("\\.");
> +        JSONObject holder = buildHolder(paramsRoot, path, 0);
> +        holder.put(path[path.length - 1],
> convertToJsonValue(entry.getValue()[0]));
> +      }
> +    }
> +    if (paramsRoot.length() > 0) {
> +      root.put("params", paramsRoot);
> +    }
> +    return root;
> +  }
> +
> +  public static Map<String, String> fromJson(JSONObject obj) throws
> JSONException {
> +    Map<String, String> result = Maps.newHashMap();
> +    collect(obj, "", result);
> +    return result;
> +  }
> +
> +  private static void collect(Object current, String prefix, Map<String,
> String> result)
> +      throws JSONException {
> +    if (current == null) {
> +      result.put(prefix, "null");
> +      return;
> +    }
> +
> +    if (current instanceof JSONObject) {
> +      JSONObject json = (JSONObject) current;
> +      Iterator keys = json.keys();
> +      while (keys.hasNext()) {
> +        String key = (String) keys.next();
> +        if (json.isNull(key)) {
> +          result.put(prefix + "." + key, "null");
> +        } else {
> +          collect(json.get(key), prefix + "." + key, result);
> +        }
> +      }
> +    } else if (current instanceof JSONArray) {
> +      JSONArray jsonArr = (JSONArray) current;
> +      if (isAllLiterals(jsonArr)) {
> +        // The array is all simple value types
> +        String jsonArrayString = jsonArr.toString();
> +        //Strip [ & ]
> +        jsonArrayString = jsonArrayString.substring(1,
> jsonArrayString.length() - 1);
> +        if (jsonArr.length() == 1) {
> +          jsonArrayString = "(" + jsonArrayString + ")";
> +        }
> +        result.put(prefix, jsonArrayString);
> +      } else {
> +        for (int i = 0; i < jsonArr.length(); i++) {
> +          if (jsonArr.isNull(i)) {
> +            result.put(prefix + "(" + i + ")", "null");
> +          } else {
> +            collect(jsonArr.get(i), prefix + "(" + i + ")", result);
> +          }
> +        }
> +      }
> +    } else {
> +      result.put(prefix, current.toString());
> +    }
> +  }
> +
> +  public static boolean isAllLiterals(JSONArray jsonArr) throws
> JSONException {
> +    for (int i = 0; i < jsonArr.length(); i++) {
> +      if (!jsonArr.isNull(i) &&
> +          (jsonArr.get(i) instanceof JSONObject ||
> +              jsonArr.get(i) instanceof JSONArray)) {
> +        return false;
> +      }
> +    }
> +    return true;
> +  }
> +
> +  static JSONObject parametersToJsonObject(Map<String, String> params)
> throws JSONException {
> +    JSONObject root = new JSONObject();
> +
> +    for (Map.Entry<String, String> entry : params.entrySet()) {
> +      String[] path = entry.getKey().split("\\.");
> +      JSONObject holder = buildHolder(root, path, 0);
> +      if (path.length > 1) {
> +        holder.put(path[path.length - 1],
> convertToJsonValue(entry.getValue()));
> +      } else {
> +        holder.put(path[0], convertToJsonValue(entry.getValue()));
> +      }
> +    }
> +
> +    return root;
> +  }
> +
> +  /**
> +   * Parse the steps in the path into JSON Objects.
> +   */
> +  static JSONObject buildHolder(JSONObject root, String[] steps, int
> currentStep)
> +      throws JSONException {
> +    if (currentStep > steps.length - 2) {
> +      return root;
> +    } else {
> +      Matcher matcher = ARRAY_MATCH.matcher(steps[currentStep]);
> +      if (matcher.matches()) {
> +        // Handle as array
> +        String fieldName = matcher.group(1);
> +        int index = Integer.parseInt(matcher.group(2));
> +        JSONArray newArrayStep;
> +        if (root.has(fieldName)) {
> +          newArrayStep = root.getJSONArray(fieldName);
> +        } else {
> +          newArrayStep = new JSONArray();
> +          root.put(fieldName, newArrayStep);
> +        }
> +        JSONObject newStep = new JSONObject();
> +        newArrayStep.put(index, newStep);
> +        return buildHolder(newStep, steps, ++currentStep);
> +      } else {
> +        JSONObject newStep;
> +        if (root.has(steps[currentStep])) {
> +          newStep = root.getJSONObject(steps[currentStep]);
> +        } else {
> +          newStep = new JSONObject();
> +          root.put(steps[currentStep], newStep);
> +        }
> +        return buildHolder(newStep, steps, ++currentStep);
> +      }
> +    }
> +  }
> +
> +  static Object convertToJsonValue(String value) throws JSONException {
> +    if (value == null) {
> +      return null;
> +    } else if (value.startsWith("(") && value.endsWith(")")) {
> +      // explicit form of literal array
> +      return new JSONArray("[" + value.substring(1, value.length() - 1) +
> "]");
> +    } else {
> +      try {
> +        // inferred parsing of literal array
> +        // Attempt to parse as an array of literals
> +        JSONArray parsedArray = new JSONArray("[" + value + "]");
> +        if (parsedArray.length() == 1) {
> +          // Not an array
> +          return parsedArray.get(0);
> +        }
> +        return parsedArray;
> +      } catch (JSONException je) {
> +        return value;
> +      }
> +    }
> +  }
> +}
>
> Added:
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonRpcServlet.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonRpcServlet.java?rev=687235&view=auto
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonRpcServlet.java
> (added)
> +++
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonRpcServlet.java
> Tue Aug 19 21:14:39 2008
> @@ -0,0 +1,164 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations under the
> License.
> + */
> +package org.apache.shindig.social.opensocial.service;
> +
> +import org.apache.shindig.common.SecurityToken;
> +import org.apache.shindig.social.ResponseItem;
> +import org.apache.shindig.social.ResponseError;
> +import org.apache.shindig.social.opensocial.spi.DataCollection;
> +import org.apache.shindig.social.opensocial.spi.RestfulCollection;
> +
> +import com.google.common.collect.Maps;
> +import com.google.common.collect.Lists;
> +
> +import org.apache.commons.io.IOUtils;
> +import org.json.JSONArray;
> +import org.json.JSONException;
> +import org.json.JSONObject;
> +
> +import java.io.IOException;
> +import java.util.Map;
> +import java.util.List;
> +import java.util.concurrent.Future;
> +
> +import javax.servlet.ServletException;
> +import javax.servlet.http.HttpServletRequest;
> +import javax.servlet.http.HttpServletResponse;
> +
> +/**
> + * JSON-RPC handler servlet.
> + */
> +public class JsonRpcServlet extends ApiServlet {
> +
> +  protected void doGet(HttpServletRequest servletRequest,
> +      HttpServletResponse servletResponse)
> +      throws ServletException, IOException {
> +    try {
> +      JSONObject request =
> JsonConversionUtils.fromRequest(servletRequest);
> +      SecurityToken token = getSecurityToken(servletRequest);
> +      dispatch(request, servletResponse, token);
> +    } catch (JSONException je) {
> +      // FIXME
> +    }
> +  }
> +
> +  protected void doPost(HttpServletRequest servletRequest,
> +      HttpServletResponse servletResponse)
> +      throws ServletException, IOException {
> +    SecurityToken token = getSecurityToken(servletRequest);
> +    try {
> +      String content = IOUtils.toString(servletRequest.getReader());
> +      if ((content.indexOf('[') != -1) && content.indexOf('[') <
> content.indexOf('{')) {
> +        //Is a batch
> +        JSONArray batch = new JSONArray(content);
> +        dispatchBatch(batch, servletResponse, token);
> +      } else {
> +        JSONObject request = new JSONObject(content);
> +        dispatch(request, servletResponse, token);
> +      }
> +    } catch (JSONException je) {
> +      sendBadRequest(je, servletResponse);
> +    }
> +
> +  }
> +
> +  private void dispatchBatch(JSONArray batch, HttpServletResponse
> servletResponse,
> +      SecurityToken token) throws JSONException, IOException {
> +    // Use linked hash map to preserve order
> +    List<Future<? extends ResponseItem>> responses =
> Lists.newArrayListWithExpectedSize(batch.length());
> +
> +    // Gather all Futures.  We do this up front so that
> +    // the first call to get() comes after all futures are created,
> +    // which allows for implementations that batch multiple Futures
> +    // into single requests.
> +    for (int i = 0; i < batch.length(); i++) {
> +      JSONObject batchObj = batch.getJSONObject(i);
> +      RpcRequestItem requestItem = new RpcRequestItem(batchObj, token,
> jsonConverter);
> +      responses.add(handleRequestItem(requestItem));
> +    }
> +
> +    // Resolve each Future into a response.
> +    // TODO: should use shared deadline across each request
> +    JSONArray result = new JSONArray();
> +    for (int i = 0; i < batch.length(); i++) {
> +      JSONObject batchObj = batch.getJSONObject(i);
> +      String key = null;
> +      if (batchObj.has("id")) {
> +        key = batchObj.getString("id");
> +      }
> +      result.put(getJSONResponse(key, getResponseItem(responses.get(i))));
> +    }
> +    servletResponse.getWriter().write(result.toString());
> +  }
> +
> +  private void dispatch(JSONObject request, HttpServletResponse
> servletResponse,
> +      SecurityToken token) throws JSONException, IOException {
> +    String key = null;
> +    if (request.has("id")) {
> +      key = request.getString("id");
> +    }
> +    RpcRequestItem requestItem = new RpcRequestItem(request, token,
> jsonConverter);
> +
> +    // Resolve each Future into a response.
> +    // TODO: should use shared deadline across each request
> +    ResponseItem response =
> getResponseItem(handleRequestItem(requestItem));
> +    JSONObject result = getJSONResponse(key, response);
> +    servletResponse.getWriter().write(result.toString());
> +  }
> +
> +  private JSONObject getJSONResponse(String key, ResponseItem response)
> throws JSONException {
> +    JSONObject result = new JSONObject();
> +    if (key != null) {
> +      result.put("id", key);
> +    }
> +    if (response.getError() != null) {
> +      JSONObject error = new JSONObject();
> +      error.put("code", response.getError().getHttpErrorCode());
> +      error.put("message", response.getErrorMessage());
> +      result.put("error", error);
> +    } else {
> +      if (response.getResponse() instanceof RestfulCollection) {
> +        //FIXME this is a little hacky because of the field names in the
> DataCollection
> +        JSONObject coll = (JSONObject)
> jsonConverter.convertToJson(response.getResponse());
> +        coll.put("list", coll.remove("entry"));
> +        result.put("data", coll);
> +      } else if (response.getResponse() instanceof DataCollection) {
> +        //FIXME this is a little hacky because of the field names in the
> DataCollection
> +        JSONObject coll = (JSONObject)
> jsonConverter.convertToJson(response.getResponse());
> +        result.put("data", coll.get("entry"));
> +      } else {
> +        result.put("data",
> jsonConverter.convertToJson(response.getResponse()));
> +      }
> +    }
> +    return result;
> +  }
> +
> +  private void sendBadRequest(Throwable t, HttpServletResponse response)
> throws IOException {
> +    try {
> +      JSONObject error = new JSONObject();
> +      error.put("code", ResponseError.BAD_REQUEST.getHttpErrorCode());
> +      error.put("message", "Invalid batch - " + t.getMessage());
> +      response.getWriter().write(error.toString());
> +    } catch (JSONException je) {
> +      // This really shouldnt ever happen
> +      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
> +          "Error generating error response " + je.getMessage());
> +    }
> +  }
> +
> +}
>
> Modified:
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java
> URL:
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java?rev=687235&r1=687234&r2=687235&view=diff
>
> ==============================================================================
> ---
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java
> (original)
> +++
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java
> Tue Aug 19 21:14:39 2008
> @@ -33,7 +33,7 @@
>
>  public class PersonHandler extends DataRequestHandler {
>
> -  private PersonService personService;
> +  private final PersonService personService;
>
>   private static final String PEOPLE_PATH =
> "/people/{userId}+/{groupId}/{personId}+";
>
> @@ -60,7 +60,7 @@
>    * examples: /people/john.doe/@all /people/john.doe/@friends
> /people/john.doe/@self
>    */
>   protected Future<? extends ResponseItem> handleGet(RequestItem request) {
> -    request.parseUrlWithTemplate(PEOPLE_PATH);
> +    request.applyUrlTemplate(PEOPLE_PATH);
>
>     GroupId groupId = request.getGroup();
>     Set<String> optionalPersonId =
> Sets.newLinkedHashSet(request.getListParameter("personId"));
>
>
>

Re: svn commit: r687235 [1/2] - in /incubator/shindig/trunk: config/ features/ features/opensocial-current/ java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ java/server/src/main/webapp/WEB-INF/ java/server/src/test/java/org/apache/shind

Posted by Chris Chabot <ch...@xs4all.nl>.
Added a hard coded config["opensocial-0.8"].impl = "rest" to the  
gadget renderer, should tie us over until we finish the json-rpc  
interface on the php side.

Thanks for the help in getting this fixed!

	-- Chris

On Aug 22, 2008, at 6:48 PM, Louis Ryan wrote:

> The default container config file now has a flag "impl" which  
> selects which
> implementation to use. The default is set to "rpc" currently so it  
> will
> still need to be altered in PHP to use "rest" instead. I dont have a  
> good
> way of testing the Rest variant in Java which is why I made rpc the
> default.
> For the PHP code we would need to do one of the following
> - Emit a JS snippet that does  config["opensocial-0.8"].impl = "rest"
> inline in the rendered gadget
> - fork the config file until we converge again
>
> I don't feel qualified to make either of those changes in PHP land.
>
> If no one has time to do any of the above Ill fork the config for  
> the Java
> code and make the default "rest".
>
> Another option would be to have the different implementations emit  
> some
> version and platform information and have the config file read it  
> and branch
> appropriately which maybe a useful feature to have in our pocket  
> whenever
> this situation arises again..
> Thoughts?
>
> On Fri, Aug 22, 2008 at 9:28 AM, Louis Ryan <lr...@google.com> wrote:
>
>> Getting ahead of myself obviously. Patch coming now...
>>
>> On Fri, Aug 22, 2008 at 5:21 AM, Chris Chabot <ch...@xs4all.nl>  
>> wrote:
>>
>>> Hey Louis,
>>>
>>> Before you committed the java json-rpc implementation we had a  
>>> quick gtalk
>>> where I indicated that unfortunately while switching jobs i might  
>>> be a bit
>>> restricted on time, so while i'll do my best to catch up with the  
>>> json-rpc
>>> changes asap, i can't guarantee it will be done quickly enough to  
>>> prevent
>>> any headaches if stuff was broken, that's why i asked for a config  
>>> flag +
>>> working old (plain rest or old custom rpc method) to be in place  
>>> until i
>>> would have the time to catch up.
>>>
>>> Now when i do a clean checkout however, none of the social calls  
>>> work any
>>> more since they default to the 'new json-rpc- style  
>>> interface' (which php
>>> shindig doesn't have yet), and there are no obvious configuration  
>>> keys in
>>> config/container.js either.
>>>
>>> I applaud your enthusiasm to try to make some progress, but this  
>>> has left
>>> us in the situation that anyone checking out php shindig now, gets  
>>> nothing
>>> but a broken environment, without any documentation on how to  
>>> solve this or
>>> (apparent) configuration options that make things work again.
>>>
>>> Previously (while working on REST for instance), we always made  
>>> sure the
>>> default out of the box experience would work for both  
>>> implementations, and
>>> have a config switch in place to check the shiny new code, that  
>>> way things
>>> could be tested and developed, and at the same time make sure that  
>>> no one
>>> was hindered by the development work.
>>>
>>> There's about 6 social networks sites currently working on  
>>> integrating php
>>> shindig into their SNS, with an reach of ~ 82 million registered  
>>> users, 3
>>> live php shindig sites with ~ 78 mil registered users.. and i  
>>> would much
>>> prefer to keep being able to offer them a working system; Next to  
>>> that
>>> there's also some blog posts online now about php shindig and  
>>> partuza, which
>>> hopefully could lead a few new interested people; And the upcoming  
>>> GDD's in
>>> europe where i'd also like to show people a working system ...
>>>
>>> So I think the impact of breaking what was a well working system,  
>>> is quite
>>> large and potentially extends out to a relatively large segment of  
>>> the open
>>> social world, and how people will perceive shindig as a project.
>>>
>>> Could you please by any chance change the default container to the  
>>> restful
>>> one for now (which used to work before we implemented the custom  
>>> json rpc
>>> mechanism, needs double checking though), and add a config flag  
>>> that allows
>>> those who want to use it to switch over to the json-rpc interface/ 
>>> container
>>> code? That way we have a clean upgrade path, and no broken  
>>> installations &
>>> everything that comes with that.
>>>
>>> Thanks in advance!
>>>
>>>       -- Chris
>>>
>>
>>


Re: svn commit: r687235 [1/2] - in /incubator/shindig/trunk: config/ features/ features/opensocial-current/ java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ java/server/src/main/webapp/WEB-INF/ java/server/src/test/java/org/apache/shind

Posted by Louis Ryan <lr...@google.com>.
The default container config file now has a flag "impl" which selects which
implementation to use. The default is set to "rpc" currently so it will
still need to be altered in PHP to use "rest" instead. I dont have a good
way of testing the Rest variant in Java which is why I made rpc the
default.
For the PHP code we would need to do one of the following
- Emit a JS snippet that does  config["opensocial-0.8"].impl = "rest"
 inline in the rendered gadget
- fork the config file until we converge again

I don't feel qualified to make either of those changes in PHP land.

If no one has time to do any of the above Ill fork the config for the Java
code and make the default "rest".

Another option would be to have the different implementations emit some
version and platform information and have the config file read it and branch
appropriately which maybe a useful feature to have in our pocket whenever
this situation arises again..
Thoughts?

On Fri, Aug 22, 2008 at 9:28 AM, Louis Ryan <lr...@google.com> wrote:

> Getting ahead of myself obviously. Patch coming now...
>
> On Fri, Aug 22, 2008 at 5:21 AM, Chris Chabot <ch...@xs4all.nl> wrote:
>
>> Hey Louis,
>>
>> Before you committed the java json-rpc implementation we had a quick gtalk
>> where I indicated that unfortunately while switching jobs i might be a bit
>> restricted on time, so while i'll do my best to catch up with the json-rpc
>> changes asap, i can't guarantee it will be done quickly enough to prevent
>> any headaches if stuff was broken, that's why i asked for a config flag +
>> working old (plain rest or old custom rpc method) to be in place until i
>> would have the time to catch up.
>>
>> Now when i do a clean checkout however, none of the social calls work any
>> more since they default to the 'new json-rpc- style interface' (which php
>> shindig doesn't have yet), and there are no obvious configuration keys in
>> config/container.js either.
>>
>> I applaud your enthusiasm to try to make some progress, but this has left
>> us in the situation that anyone checking out php shindig now, gets nothing
>> but a broken environment, without any documentation on how to solve this or
>> (apparent) configuration options that make things work again.
>>
>> Previously (while working on REST for instance), we always made sure the
>> default out of the box experience would work for both implementations, and
>> have a config switch in place to check the shiny new code, that way things
>> could be tested and developed, and at the same time make sure that no one
>> was hindered by the development work.
>>
>> There's about 6 social networks sites currently working on integrating php
>> shindig into their SNS, with an reach of ~ 82 million registered users, 3
>> live php shindig sites with ~ 78 mil registered users.. and i would much
>> prefer to keep being able to offer them a working system; Next to that
>> there's also some blog posts online now about php shindig and partuza, which
>> hopefully could lead a few new interested people; And the upcoming GDD's in
>> europe where i'd also like to show people a working system ...
>>
>> So I think the impact of breaking what was a well working system, is quite
>> large and potentially extends out to a relatively large segment of the open
>> social world, and how people will perceive shindig as a project.
>>
>> Could you please by any chance change the default container to the restful
>> one for now (which used to work before we implemented the custom json rpc
>> mechanism, needs double checking though), and add a config flag that allows
>> those who want to use it to switch over to the json-rpc interface/container
>> code? That way we have a clean upgrade path, and no broken installations &
>> everything that comes with that.
>>
>> Thanks in advance!
>>
>>        -- Chris
>>
>
>

Re: svn commit: r687235 [1/2] - in /incubator/shindig/trunk: config/ features/ features/opensocial-current/ java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ java/server/src/main/webapp/WEB-INF/ java/server/src/test/java/org/apache/shind

Posted by Louis Ryan <lr...@google.com>.
Getting ahead of myself obviously. Patch coming now...
On Fri, Aug 22, 2008 at 5:21 AM, Chris Chabot <ch...@xs4all.nl> wrote:

> Hey Louis,
>
> Before you committed the java json-rpc implementation we had a quick gtalk
> where I indicated that unfortunately while switching jobs i might be a bit
> restricted on time, so while i'll do my best to catch up with the json-rpc
> changes asap, i can't guarantee it will be done quickly enough to prevent
> any headaches if stuff was broken, that's why i asked for a config flag +
> working old (plain rest or old custom rpc method) to be in place until i
> would have the time to catch up.
>
> Now when i do a clean checkout however, none of the social calls work any
> more since they default to the 'new json-rpc- style interface' (which php
> shindig doesn't have yet), and there are no obvious configuration keys in
> config/container.js either.
>
> I applaud your enthusiasm to try to make some progress, but this has left
> us in the situation that anyone checking out php shindig now, gets nothing
> but a broken environment, without any documentation on how to solve this or
> (apparent) configuration options that make things work again.
>
> Previously (while working on REST for instance), we always made sure the
> default out of the box experience would work for both implementations, and
> have a config switch in place to check the shiny new code, that way things
> could be tested and developed, and at the same time make sure that no one
> was hindered by the development work.
>
> There's about 6 social networks sites currently working on integrating php
> shindig into their SNS, with an reach of ~ 82 million registered users, 3
> live php shindig sites with ~ 78 mil registered users.. and i would much
> prefer to keep being able to offer them a working system; Next to that
> there's also some blog posts online now about php shindig and partuza, which
> hopefully could lead a few new interested people; And the upcoming GDD's in
> europe where i'd also like to show people a working system ...
>
> So I think the impact of breaking what was a well working system, is quite
> large and potentially extends out to a relatively large segment of the open
> social world, and how people will perceive shindig as a project.
>
> Could you please by any chance change the default container to the restful
> one for now (which used to work before we implemented the custom json rpc
> mechanism, needs double checking though), and add a config flag that allows
> those who want to use it to switch over to the json-rpc interface/container
> code? That way we have a clean upgrade path, and no broken installations &
> everything that comes with that.
>
> Thanks in advance!
>
>        -- Chris
>

Re: svn commit: r687235 [1/2] - in /incubator/shindig/trunk: config/ features/ features/opensocial-current/ java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ java/server/src/main/webapp/WEB-INF/ java/server/src/test/java/org/apache/shind

Posted by Chris Chabot <ch...@xs4all.nl>.
Hey Louis,

Before you committed the java json-rpc implementation we had a quick  
gtalk where I indicated that unfortunately while switching jobs i  
might be a bit restricted on time, so while i'll do my best to catch  
up with the json-rpc changes asap, i can't guarantee it will be done  
quickly enough to prevent any headaches if stuff was broken, that's  
why i asked for a config flag + working old (plain rest or old custom  
rpc method) to be in place until i would have the time to catch up.

Now when i do a clean checkout however, none of the social calls work  
any more since they default to the 'new json-rpc- style  
interface' (which php shindig doesn't have yet), and there are no  
obvious configuration keys in config/container.js either.

I applaud your enthusiasm to try to make some progress, but this has  
left us in the situation that anyone checking out php shindig now,  
gets nothing but a broken environment, without any documentation on  
how to solve this or (apparent) configuration options that make things  
work again.

Previously (while working on REST for instance), we always made sure  
the default out of the box experience would work for both  
implementations, and have a config switch in place to check the shiny  
new code, that way things could be tested and developed, and at the  
same time make sure that no one was hindered by the development work.

There's about 6 social networks sites currently working on integrating  
php shindig into their SNS, with an reach of ~ 82 million registered  
users, 3 live php shindig sites with ~ 78 mil registered users.. and i  
would much prefer to keep being able to offer them a working system;  
Next to that there's also some blog posts online now about php shindig  
and partuza, which hopefully could lead a few new interested people;  
And the upcoming GDD's in europe where i'd also like to show people a  
working system ...

So I think the impact of breaking what was a well working system, is  
quite large and potentially extends out to a relatively large segment  
of the open social world, and how people will perceive shindig as a  
project.

Could you please by any chance change the default container to the  
restful one for now (which used to work before we implemented the  
custom json rpc mechanism, needs double checking though), and add a  
config flag that allows those who want to use it to switch over to the  
json-rpc interface/container code? That way we have a clean upgrade  
path, and no broken installations & everything that comes with that.

Thanks in advance!

	-- Chris

Re: svn commit: r687235 [1/2] - in /incubator/shindig/trunk: config/ features/ features/opensocial-current/ java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ java/server/src/main/webapp/WEB-INF/ java/server/src/test/java/org/apache/shind

Posted by Louis Ryan <lr...@google.com>.
Comments below...

On Thu, Aug 21, 2008 at 10:56 AM, Cassie <do...@google.com> wrote:

> On Tue, Aug 19, 2008 at 9:14 PM, <lr...@apache.org> wrote:
>
> > Author: lryan
> > Date: Tue Aug 19 21:14:39 2008
> > New Revision: 687235
> >
> > URL: http://svn.apache.org/viewvc?rev=687235&view=rev
> > Log:
> > Initial JSON-RPC implementation including...
> >  - Batch support
> >  - Execution via GET with JSON<-->URL encoding
> >  - opensocial JS now uses JSON-RPC
> >  - removed RESTful batching code in Java
> >
> > I've left the old opensocial container code backed by the RESTful API so
> > PHP folks have a migration path. See feature.xml in opensocial-current.
> >
> > Added:
> >
>  incubator/shindig/trunk/features/opensocial-current/jsonrpccontainer.js
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ApiServlet.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonConversionUtils.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonRpcServlet.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/RestfulRequestItem.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/RpcRequestItem.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/JsonConversionUtilsTest.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/JsonRpcServletTest.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RestfulRequestItemTest.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RpcRequestItemTest.java
> > Removed:
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulBatchTest.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/RequestItemTest.java
> > Modified:
> >    incubator/shindig/trunk/config/container.js
> >    incubator/shindig/trunk/features/opensocial-current/feature.xml
> >
>  incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> >    incubator/shindig/trunk/features/pom.xml
> >
> >
>  incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingTask.java
> >
>  incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.full.xml
> >
> >
>  incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.social.xml
> >    incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml
> >
> >
>  incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ActivityHandler.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/AppDataHandler.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataRequestHandler.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServlet.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServletFetcher.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/RequestItem.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/sample/service/SampleContainerHandler.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/ActivityHandlerTest.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/AppDataHandlerTest.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/DataServiceServletTest.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/service/PersonHandlerTest.java
> >
> >
>  incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/spi/DataRequestHandlerTest.java
> >
> > Modified: incubator/shindig/trunk/config/container.js
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/config/container.js?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > --- incubator/shindig/trunk/config/container.js (original)
> > +++ incubator/shindig/trunk/config/container.js Tue Aug 19 21:14:39 2008
> > @@ -109,7 +109,7 @@
> >   "opensocial-0.8" : {
> >     // Path to fetch opensocial data from
> >     // Must be on the same domain as the gadget rendering server
> > -    "path" : "/social/rest",
> > +    "path" : "/social",
> >     "domain" : "shindig",
> >     "enableCaja" : false,
> >     "supportedFields" : {
> >
> > Modified: incubator/shindig/trunk/features/opensocial-current/feature.xml
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-current/feature.xml?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > --- incubator/shindig/trunk/features/opensocial-current/feature.xml
> > (original)
> > +++ incubator/shindig/trunk/features/opensocial-current/feature.xml Tue
> Aug
> > 19 21:14:39 2008
> > @@ -25,7 +25,7 @@
> >   <!-- gadgets when "use caja" is checked -->
> >   <gadget>
> >     <script src="jsonperson.js"></script>
> > -    <script src="jsonactivity.js"></script>
> > +    <!--
> >     <script src="restfulcontainer.js"></script>
> >     <script>
> >       var requiredConfig = {
> > @@ -53,5 +53,33 @@
> >       });
> >
> >     </script>
> > +    -->
> > +    <script src="jsonrpccontainer.js" inline="false"></script>
> > +    <script>
> > +      var requiredConfig = {
> > +        "path": gadgets.config.NonEmptyStringValidator,
> > +        "domain": gadgets.config.NonEmptyStringValidator,
> > +        "enableCaja": gadgets.config.BooleanValidator,
> > +        "supportedFields": gadgets.config.ExistsValidator
> > +      };
> > +
> > +      gadgets.config.register("opensocial-0.8", requiredConfig,
> > +        function(config) {
> > +          var configParams = config["opensocial-0.8"];
> > +
> > +          ShindigContainer = function() {
> > +            JsonRpcContainer.call(this, configParams.path,
> > +            configParams.domain, configParams.supportedFields);
> > +          };
> > +          ShindigContainer.inherits(JsonRpcContainer);
> > +
> > +          opensocial.Container.setContainer(new ShindigContainer());
> > +
> > +          if (window['caja']) {
> > +            opensocial.Container.get().enableCaja();
> > +          }
> > +      });
> > +
> > +    </script>
> >   </gadget>
> >  </feature>
> >
> > Added:
> > incubator/shindig/trunk/features/opensocial-current/jsonrpccontainer.js
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-current/jsonrpccontainer.js?rev=687235&view=auto
> >
> >
> ==============================================================================
> > ---
> incubator/shindig/trunk/features/opensocial-current/jsonrpccontainer.js
> > (added)
> > +++
> incubator/shindig/trunk/features/opensocial-current/jsonrpccontainer.js
> > Tue Aug 19 21:14:39 2008
> > @@ -0,0 +1,373 @@
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF) under one
> > + * or more contributor license agreements. See the NOTICE file
> > + * distributed with this work for additional information
> > + * regarding copyright ownership. The ASF licenses this file
> > + * to you under the Apache License, Version 2.0 (the
> > + * "License"); you may not use this file except in compliance
> > + * with the License. You may obtain a copy of the License at
> > + *
> > + *     http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing,
> > + * software distributed under the License is distributed on an
> > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> > + * KIND, either express or implied. See the License for the
> > + * specific language governing permissions and limitations under the
> > License.
> > + */
> > +
> > +/**
> > + * @fileoverview JSON-RPC based opensocial container.
> > + */
> > +
> > +var JsonRpcContainer = function(baseUrl, domain, supportedFieldsArray) {
> > +  opensocial.Container.call(this);
> > +
> > +  var supportedFieldsMap = {};
> > +  for (var objectType in supportedFieldsArray) {
> > +    if (supportedFieldsArray.hasOwnProperty(objectType)) {
> > +      supportedFieldsMap[objectType] = {};
> > +      for (var i = 0; i < supportedFieldsArray[objectType].length; i++)
> {
> > +        var supportedField = supportedFieldsArray[objectType][i];
> > +        supportedFieldsMap[objectType][supportedField] = true;
> > +      }
> > +    }
> > +  }
> > +
> > +  this.environment_ = new opensocial.Environment(domain,
> > supportedFieldsMap);
> > +  this.baseUrl_ = baseUrl;
> > +
> > +  this.securityToken_ = shindig.auth.getSecurityToken();
> > +};
> > +JsonRpcContainer.inherits(opensocial.Container);
> > +
> > +JsonRpcContainer.prototype.getEnvironment = function() {
> > +  return this.environment_;
> > +};
> > +
> > +JsonRpcContainer.prototype.requestCreateActivity = function(activity,
> > +                                                            priority,
> > opt_callback) {
> > +  opt_callback = opt_callback || {};
> > +
> > +  var req = opensocial.newDataRequest();
> > +  var viewer = new opensocial.IdSpec({'userId' : 'VIEWER'});
> > +  req.add(this.newCreateActivityRequest(viewer, activity), 'key');
> > +  req.send(function(response) {
> > +    opt_callback(response.get('key'));
> > +  });
> > +};
> > +
> > +JsonRpcContainer.prototype.requestData = function(dataRequest, callback)
> {
> > +  callback = callback || {};
> > +
> > +  var requestObjects = dataRequest.getRequestObjects();
> > +  var totalRequests = requestObjects.length;
> > +
> > +  if (totalRequests == 0) {
> > +    callback(new opensocial.DataResponse({}, true));
> > +    return;
> > +  }
> > +
> > +  var jsonBatchData = new Array(totalRequests);
> > +  var systemKeyIndex = 0;
> > +
> > +  for (var j = 0; j < totalRequests; j++) {
> > +    var requestObject = requestObjects[j];
> > +
> > +    if (!requestObject.key) {
> > +      requestObject.key = "systemKey" + systemKeyIndex;
> > +      while (jsonBatchData[requestObject.key]) {
> > +        // If the key exists, choose another and try again
> > +        systemKeyIndex++;
> > +        requestObject.key = "systemKey" + systemKeyIndex;
> > +      }
> > +    }
> > +
> > +    jsonBatchData[j] = requestObject.request.rpc;
> > +    jsonBatchData[j].id = requestObject.key;
> > +
> > +    if (requestObject.request.postData) {
> > +      jsonBatchData[j].postData = requestObject.request.postData;
> > +    }
> > +  }
> > +
> > +  var sendResponse = function(result) {
> > +    if (result.errors[0]) {
> > +      JsonRpcContainer.generateErrorResponse(result, requestObjects,
> > callback);
> > +      return;
> > +    }
> > +
> > +    result = result.data;
> > +
> > +    var globalError = false;
> > +    var responseMap = {};
> > +
> > +    // Map from indices to ids.
> > +    for (var i = 0; i < result.length; i++) {
> > +      result[result[i].id] = result[i];
> > +    }
>
>
> why do you turn these into a map and then below index them by key?


Safest to check both. Updating to correlate by index and verify keys still
match if a key is defined

>
>
>
> >
> > +
> > +    for (var k = 0; k < requestObjects.length; k++) {
> > +      var request = requestObjects[k];
> > +      var response = result[request.key];
>
>
> couldn't we just do result[k] here?
> this would allow us to get rid of the hacky systemKey code which really
> needs to be deleted.


Done

>
>
>
> >
> > +
> > +      var rawData = response.data;
> > +      var error = response.error;
> > +      var errorMessage = "";
> > +
> > +      if (error) {
> > +        errorMessage = error.message;
> > +      }
> > +
> > +      var processedData = request.request.processResponse(
> > +          request.request, rawData, error, errorMessage);
> > +      globalError = globalError || processedData.hadError();
> > +      responseMap[request.key] = processedData;
> > +    }
> > +
> > +    var dataResponse = new opensocial.DataResponse(responseMap,
> > globalError);
> > +    callback(dataResponse);
> > +  };
> > +
> > +  // TODO: get the jsonbatch url from the container config
> > +  var makeRequestParams = {
> > +    "CONTENT_TYPE" : "JSON",
> > +    "METHOD" : "POST",
> > +    "AUTHORIZATION" : "SIGNED",
> > +    "POST_DATA" : gadgets.json.stringify(jsonBatchData)
> > +  };
> > +
> > +  gadgets.io.makeNonProxiedRequest(
> > +      this.baseUrl_ + "/rpc?st=" +
> > encodeURIComponent(shindig.auth.getSecurityToken()),
> > +      sendResponse, makeRequestParams, "application/json");
> > +};
> > +
> > +JsonRpcContainer.generateErrorResponse = function(result,
> requestObjects,
> > callback) {
> > +  var globalErrorCode =
> > JsonRpcContainer.translateHttpError(result.errors[0] ||
> result.data.error)
> > +      || opensocial.ResponseItem.Error.INTERNAL_ERROR;
> > +
> > +  var errorResponseMap = {};
> > +  for (var i = 0; i < requestObjects.length; i++) {
> > +    errorResponseMap[requestObjects[i].key] = new
> opensocial.ResponseItem(
> > +        requestObjects[i].request, null, globalErrorCode);
> > +  }
> > +  callback(new opensocial.DataResponse(errorResponseMap, true));
> > +};
> > +
> > +JsonRpcContainer.translateHttpError = function(httpError) {
> > +  if (httpError == "Error 501") {
> > +    return opensocial.ResponseItem.Error.NOT_IMPLEMENTED;
> > +  } else if (httpError == "Error 401") {
> > +    return opensocial.ResponseItem.Error.UNAUTHORIZED;
> > +  } else if (httpError == "Error 403") {
> > +    return opensocial.ResponseItem.Error.FORBIDDEN;
> > +  } else if (httpError == "Error 400") {
> > +    return opensocial.ResponseItem.Error.BAD_REQUEST;
> > +  } else if (httpError == "Error 500") {
> > +    return opensocial.ResponseItem.Error.INTERNAL_ERROR;
> > +  } else if (httpError == "Error 404") {
> > +    return opensocial.ResponseItem.Error.BAD_REQUEST;
> > +  // TODO: Which one should the limit exceeded error be?
> > +    // } else if (httpError == "Error ???") {
> > +    //   return opensocial.ResponseItem.Error.LIMIT_EXCEEDED;
> > +  }
> > +};
> > +
> > +JsonRpcContainer.prototype.makeIdSpec = function(id) {
> > +  return new opensocial.IdSpec({'userId' : id});
> > +};
> > +
> > +JsonRpcContainer.prototype.translateIdSpec = function(newIdSpec) {
> > +  var userId = newIdSpec.getField('userId');
> > +  var groupId = newIdSpec.getField('groupId');
> > +
> > +  if (userId == 'OWNER') {
> > +    userId = '@owner';
> > +  } else if (userId == 'VIEWER') {
> > +    userId = '@viewer';
> > +  } else if (opensocial.Container.isArray(newIdSpec)) {
> > +    for (var i = 0; i < newIdSpec.length; i++) {
> > +      // TODO: We will need multiple urls here....don't want to think
> > about
> > +      // that yet
>
> made code more obvious. this branch would never have been hit as we don't
> allow arrays of idSpecs anywhere.
>
>
> >
> > +    }
> > +  }
> > +
> > +  if (groupId == 'FRIENDS') {
> > +    groupId = "@friends";
> > +  } else if (!groupId) {
> > +    groupId = "@self";
> > +  }
> > +
> > +  return { userId : userId, groupId : groupId};
> > +};
> > +
> > +JsonRpcContainer.prototype.newFetchPersonRequest = function(id,
> > opt_params) {
> > +  var peopleRequest = this.newFetchPeopleRequest(
> > +      this.makeIdSpec(id), opt_params);
> > +
> > +  var me = this;
> > +  return new JsonRpcRequestItem(peopleRequest.rpc,
> > +      function(rawJson) {
> > +        return me.createPersonFromJson(rawJson);
> > +      });
> > +};
> > +
> > +JsonRpcContainer.prototype.newFetchPeopleRequest = function(idSpec,
> > +                                                            opt_params)
> {
> > +  var rpc = { method : "people.get" };
> > +  rpc.params = this.translateIdSpec(idSpec);
> > +  if (opt_params['profileDetail']) {
> > +    rpc.params.fields = opt_params['profileDetail'];
> > +  }
> > +  if (opt_params['first']) {
> > +    rpc.params.startIndex = opt_params['first'];
> > +  }
> > +  if (opt_params['max']) {
> > +    rpc.params.count = opt_params['max'];
> > +  }
> > +  if (opt_params['sortOrder']) {
> > +    rpc.params.orderBy = opt_params['sortOrder'];
> > +  }
> > +  if (opt_params['filter']) {
> > +    rpc.params.filterBy = opt_params['filter'];
> > +  }
> > +  if (idSpec.getField('networkDistance')) {
> > +    rpc.params.networkDistance = idSpec.getField('networkDistance');
> > +  }
> > +
> > +  var me = this;
> > +  return new JsonRpcRequestItem(rpc,
> > +      function(rawJson) {
> > +        var jsonPeople;
> > +        if (rawJson['list']) {
> > +          // For the array of people response
> > +          jsonPeople = rawJson['list'];
> > +        } else {
> > +          // For the single person response
> > +          jsonPeople = [rawJson];
> > +        }
> > +
> > +        var people = [];
> > +        for (var i = 0; i < jsonPeople.length; i++) {
> > +          people.push(me.createPersonFromJson(jsonPeople[i]));
> > +        }
> > +        return new opensocial.Collection(people,
> > +            rawJson['startIndex'], rawJson['totalResults']);
> > +      });
> > +};
> > +
> > +JsonRpcContainer.prototype.createPersonFromJson = function(serverJson) {
> > +  return new JsonPerson(serverJson);
> > +};
> > +
> > +JsonRpcContainer.prototype.getFieldsList = function(keys) {
> > +  // datarequest.js guarantees that keys is an array
> > +  if (this.hasNoKeys(keys) || this.isWildcardKey(keys[0])) {
> > +    return [];
> > +  } else {
> > +    return keys;
> > +  }
> > +};
> > +
> > +JsonRpcContainer.prototype.hasNoKeys = function(keys) {
> > +  return !keys || keys.length == 0;
> > +};
> > +
> > +JsonRpcContainer.prototype.isWildcardKey = function(key) {
> > +  // Some containers support * to mean all keys in the js apis.
> > +  // This allows the RESTful apis to be compatible with them.
> > +  return key == "*";
> > +};
> > +
> > +JsonRpcContainer.prototype.newFetchPersonAppDataRequest =
> function(idSpec,
> > +                                                                   keys,
> > opt_params) {
> > +  var rpc = { method : "appdata.get" };
> > +  rpc.params = this.translateIdSpec(idSpec);
> > +  rpc.params.app = "@app";
> > +  rpc.params.fields = this.getFieldsList(keys);
> > +  if (idSpec.getField('networkDistance')) {
> > +    rpc.params.networkDistance = idSpec.getField('networkDistance');
> > +  }
> > +
> > +  return new JsonRpcRequestItem(rpc,
> > +      function (appData) {
> > +        return  opensocial.Container.escape(appData['data'], opt_params,
> > true);
> > +      });
> > +};
> > +
> > +JsonRpcContainer.prototype.newUpdatePersonAppDataRequest = function(id,
> > key,
> > +
>  value)
> > {
>
>
> your indent style seems off for your js files. this should be 4 spaces in.
> this occurs in several places.


Not sure why this is happening. IntelliJ is doing this automatically for JS
but not for Java. Ive been trying to keep it in check :(

>
>
>
> >
> > +  var rpc = { method : "appdata.update" };
> > +  rpc.params = this.translateIdSpec(this.makeIdSpec(id));
> > +  rpc.params.app = "@app";
> > +  rpc.params.data = {};
> > +  rpc.params.data[key] = value;
> > +  return new JsonRpcRequestItem(rpc);
> > +};
> > +
> > +JsonRpcContainer.prototype.newRemovePersonAppDataRequest = function(id,
> > keys) {
> > +  var rpc = { method : "appdata.delete" };
> > +  rpc.params = this.translateIdSpec(this.makeIdSpec(id));
> > +  rpc.params.app = "@app";
> > +  rpc.params.keys = keys;
> > +
> > +  return new JsonRpcRequestItem(rpc);
> > +};
> > +
> > +JsonRpcContainer.prototype.newFetchActivitiesRequest = function(idSpec,
> > +
> >  opt_params) {
> > +  var rpc = { method : "activities.get" };
> > +  rpc.params = this.translateIdSpec(idSpec);
> > +  rpc.params.app = "@app";
> > +  if (idSpec.getField('networkDistance')) {
> > +    rpc.params.networkDistance = idSpec.getField('networkDistance');
> > +  }
> > +
> > +  return new JsonRpcRequestItem(rpc,
> > +      function(rawJson) {
> > +        rawJson = rawJson['list'];
> > +        var activities = [];
> > +        for (var i = 0; i < rawJson.length; i++) {
> > +          activities.push(new JsonActivity(rawJson[i]));
> > +        }
> > +        return new opensocial.Collection(activities);
> > +      });
> > +};
> > +
> > +JsonRpcContainer.prototype.newActivity = function(opt_params) {
> > +  return new JsonActivity(opt_params, true);
> > +};
> > +
> > +JsonRpcContainer.prototype.newMediaItem = function(mimeType, url,
> > opt_params) {
> > +  opt_params = opt_params || {};
> > +  opt_params['mimeType'] = mimeType;
> > +  opt_params['url'] = url;
> > +  return new JsonMediaItem(opt_params);
> > +};
> > +
> > +JsonRpcContainer.prototype.newCreateActivityRequest = function(idSpec,
> > +                                                               activity)
> {
> > +  var rpc = { method : "activities.create" };
> > +  rpc.params = this.translateIdSpec(idSpec);
> > +  rpc.params.app = "@app";
> > +  if (idSpec.getField('networkDistance')) {
> > +    rpc.params.networkDistance = idSpec.getField('networkDistance');
> > +  }
> > +  rpc.params.activity = activity.toJsonObject();
> > +
> > +  return new JsonRpcRequestItem(rpc);
> > +};
> > +
> > +var JsonRpcRequestItem = function(rpc, opt_processData) {
> > +  this.rpc = rpc;
> > +  this.processData = opt_processData ||
> > +                     function (rawJson) {
> > +                       return rawJson;
> > +                     };
> > +
> > +  this.processResponse = function(originalDataRequest, rawJson, error,
> > +                                  errorMessage) {
> > +    return new opensocial.ResponseItem(originalDataRequest,
> > +        error ? null : this.processData(rawJson), error, errorMessage);
> > +  }
> > +};
> >
> > Modified:
> > incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> > (original)
> > +++
> incubator/shindig/trunk/features/opensocial-current/restfulcontainer.js
> > Tue Aug 19 21:14:39 2008
> > @@ -19,8 +19,7 @@
> >  /**
> >  * @fileoverview RESTful based opensocial container.
> >  *
> > - * TODO: We should probably use a url builder of some sort to construct
> > the restful urls.
> > - * They are getting a little too complex for string concatenation
> > + * TODO: THIS IS NOW DEPRECATED. Remove once PHP implements rpc support
> >  */
> >
> >  var RestfulContainer = function(baseUrl, domain, supportedFieldsArray) {
> > @@ -133,8 +132,8 @@
> >   };
> >
> >   gadgets.io.makeNonProxiedRequest(
> > -    this.baseUrl_ + "/jsonBatch?st=" +
> > encodeURIComponent(shindig.auth.getSecurityToken()),
> > -    sendResponse, makeRequestParams, "application/json");
> > +      this.baseUrl_ + "/rest/jsonBatch?st=" +
> > encodeURIComponent(shindig.auth.getSecurityToken()),
> > +      sendResponse, makeRequestParams, "application/json");
> >  };
> >
> >  RestfulContainer.generateErrorResponse = function(result,
> requestObjects,
> > callback) {
> > @@ -163,8 +162,8 @@
> >   } else if (httpError == "Error 404") {
> >     return opensocial.ResponseItem.Error.BAD_REQUEST;
> >   // TODO: Which one should the limit exceeded error be?
> > -  // } else if (httpError == "Error ???") {
> > -  //   return opensocial.ResponseItem.Error.LIMIT_EXCEEDED;
> > +    // } else if (httpError == "Error ???") {
> > +    //   return opensocial.ResponseItem.Error.LIMIT_EXCEEDED;
> >   }
> >  };
> >
> >
> > Modified: incubator/shindig/trunk/features/pom.xml
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/pom.xml?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > --- incubator/shindig/trunk/features/pom.xml (original)
> > +++ incubator/shindig/trunk/features/pom.xml Tue Aug 19 21:14:39 2008
> > @@ -17,7 +17,9 @@
> >  specific language governing permissions and limitations
> >  under the License.
> >  -->
> > -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> > http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd
> > ">
> > +<project xmlns="http://maven.apache.org/POM/4.0.0"
> > +         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > +         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/maven-v4_0_0.xsd">
> >   <modelVersion>4.0.0</modelVersion>
> >
> >   <parent>
> > @@ -32,18 +34,21 @@
> >
> >   <name>Apache Shindig Features</name>
> >   <description>Packages all the features that shindig provides into a
> > single jar file to allow
> > -               loading from the classpath</description>
> > +    loading from the classpath
> > +  </description>
> >
> >   <scm>
> > -    <connection>scm:svn:
> > http://svn.apache.org/repos/asf/incubator/shindig/trunk/features
> > </connection>
> > -    <developerConnection>scm:svn:
> > https://svn.apache.org/repos/asf/incubator/shindig/trunk/features
> > </developerConnection>
> > +    <connection>scm:svn:
> > http://svn.apache.org/repos/asf/incubator/shindig/trunk/features
> > +    </connection>
> > +    <developerConnection>scm:svn:
> > https://svn.apache.org/repos/asf/incubator/shindig/trunk/features
> > +    </developerConnection>
> >     <url>http://svn.apache.org/viewvc/incubator/shindig/trunk/features
> > </url>
> >   </scm>
> >
> >   <build>
> >     <plugins>
> >       <plugin>
> > -        <groupId>org.apache.maven.plugins </groupId>
> > +        <groupId>org.apache.maven.plugins</groupId>
> >         <artifactId>maven-eclipse-plugin</artifactId>
> >       </plugin>
> >       <plugin>
> > @@ -60,90 +65,91 @@
> >             <goals>
> >               <goal>compress</goal>
> >             </goals>
> > -            </execution>
> > -          </executions>
> > -          <configuration>
> > -            <suffix>.opt</suffix>
> > -            <excludes>
> > -              <exclude>target/**</exclude>
> > -              <!-- don't bother with other file types. -->
> > -              <exclude>**/*.xml</exclude>
> > -              <exclude>**/*.html</exclude>
> > -              <exclude>**/*.gif</exclude>
> > -              <exclude>**/*.jpeg</exclude>
> > -              <exclude>**/*.png</exclude>
> > -              <!-- Caja is already minified -->
> > -              <exclude>**/caja/*.js</exclude>
> > -            </excludes>
> > -          </configuration>
> > -        </plugin>
> > -        <plugin>
> > -          <groupId>de.berlios.jsunit</groupId>
> > -          <artifactId>jsunit-maven2-plugin</artifactId>
> > -          <executions>
> > -            <execution>
> > -              <configuration>
> > -                <sourceDirectory>${basedir}</sourceDirectory>
> > -                <sources>
> > -                  <source>mocks/env.js</source>
> > -                  <source>mocks/xhr.js</source>
> > -                  <source>core/config.js</source>
> > -                  <source>core/json.js</source>
> > -                  <source>core/auth.js</source>
> > -                  <source>core/util.js</source>
> > -                  <source>core/prefs.js</source>
> > -                  <source>core.io/io.js</source>
> > -                  <source>views/views.js</source>
> > -                  <source>opensocial-reference/opensocial.js</source>
> > -                  <source>opensocial-reference/activity.js</source>
> > -                  <source>opensocial-reference/address.js</source>
> > -                  <source>opensocial-reference/bodytype.js</source>
> > -                  <source>opensocial-reference/collection.js</source>
> > -                  <source>opensocial-reference/container.js</source>
> > -                  <source>opensocial-reference/datarequest.js</source>
> > -                  <source>opensocial-reference/dataresponse.js</source>
> > -                  <source>opensocial-reference/email.js</source>
> > -                  <source>opensocial-reference/enum.js</source>
> > -                  <source>opensocial-reference/environment.js</source>
> > -                  <source>opensocial-reference/idspec.js</source>
> > -                  <source>opensocial-reference/mediaitem.js</source>
> > -                  <source>opensocial-reference/message.js</source>
> > -                  <source>opensocial-reference/name.js</source>
> > -
> >  <source>opensocial-reference/navigationparameters.js</source>
> > -                  <source>opensocial-reference/organization.js</source>
> > -                  <source>opensocial-reference/person.js</source>
> > -                  <source>opensocial-reference/phone.js</source>
> > -                  <source>opensocial-reference/responseitem.js</source>
> > -                  <source>opensocial-reference/url.js</source>
> > -                  <source>opensocial-current/jsonactivity.js</source>
> > -                  <source>opensocial-current/jsonperson.js</source>
> > -
>  <source>opensocial-current/restfulcontainer.js</source>
> > -                </sources>
> > -                <testSourceDirectory>${basedir}</testSourceDirectory>
> > -                <testSuites>
> > -                   <testSuite>
> > -                    <name>GadgetsJSAPITests</name>
> > -                    <type>TESTCASES</type>
> > -                    <includes>
> > -                      <include>core/*test.js</include>
> > -                      <include>core.io/*test.js</include>
> > -                      <include>views/*test.js</include>
> > -                    </includes>
> > -                  </testSuite>
> > -                 <testSuite>
> > -                    <name>OpenSocialJsTests</name>
> > -                    <type>TESTCASES</type>
> > -                    <includes>
> > -                      <include>opensocial-reference/*test.js</include>
> > -                      <include>opensocial-current/*test.js</include>
> > -                    </includes>
> > -                  </testSuite>
> > -                </testSuites>
> > -              </configuration>
> > -              <goals>
> > -                <goal>jsunit-test</goal>
> > -              </goals>
> > -            </execution>
> > +          </execution>
> > +        </executions>
> > +        <configuration>
> > +          <suffix>.opt</suffix>
> > +          <excludes>
> > +            <exclude>target/**</exclude>
> > +            <!-- don't bother with other file types. -->
> > +            <exclude>**/*.xml</exclude>
> > +            <exclude>**/*.html</exclude>
> > +            <exclude>**/*.gif</exclude>
> > +            <exclude>**/*.jpeg</exclude>
> > +            <exclude>**/*.png</exclude>
> > +            <!-- Caja is already minified -->
> > +            <exclude>**/caja/*.js</exclude>
> > +          </excludes>
> > +        </configuration>
> > +      </plugin>
> > +      <plugin>
> > +        <groupId>de.berlios.jsunit</groupId>
> > +        <artifactId>jsunit-maven2-plugin</artifactId>
> > +        <executions>
> > +          <execution>
> > +            <configuration>
> > +              <sourceDirectory>${basedir}</sourceDirectory>
> > +              <sources>
> > +                <source>mocks/env.js</source>
> > +                <source>mocks/xhr.js</source>
> > +                <source>core/config.js</source>
> > +                <source>core/json.js</source>
> > +                <source>core/auth.js</source>
> > +                <source>core/util.js</source>
> > +                <source>core/prefs.js</source>
> > +                <source>core.io/io.js</source>
> > +                <source>views/views.js</source>
> > +                <source>opensocial-reference/opensocial.js</source>
> > +                <source>opensocial-reference/activity.js</source>
> > +                <source>opensocial-reference/address.js</source>
> > +                <source>opensocial-reference/bodytype.js</source>
> > +                <source>opensocial-reference/collection.js</source>
> > +                <source>opensocial-reference/container.js</source>
> > +                <source>opensocial-reference/datarequest.js</source>
> > +                <source>opensocial-reference/dataresponse.js</source>
> > +                <source>opensocial-reference/email.js</source>
> > +                <source>opensocial-reference/enum.js</source>
> > +                <source>opensocial-reference/environment.js</source>
> > +                <source>opensocial-reference/idspec.js</source>
> > +                <source>opensocial-reference/mediaitem.js</source>
> > +                <source>opensocial-reference/message.js</source>
> > +                <source>opensocial-reference/name.js</source>
> > +
> >  <source>opensocial-reference/navigationparameters.js</source>
> > +                <source>opensocial-reference/organization.js</source>
> > +                <source>opensocial-reference/person.js</source>
> > +                <source>opensocial-reference/phone.js</source>
> > +                <source>opensocial-reference/responseitem.js</source>
> > +                <source>opensocial-reference/url.js</source>
> > +                <source>opensocial-current/jsonactivity.js</source>
> > +                <source>opensocial-current/jsonperson.js</source>
> > +                <source>opensocial-current/restfulcontainer.js</source>
> > +                <source>opensocial-current/jsonrpccontainer.js</source>
> > +              </sources>
> > +              <testSourceDirectory>${basedir}</testSourceDirectory>
> > +              <testSuites>
> > +                <testSuite>
> > +                  <name>GadgetsJSAPITests</name>
> > +                  <type>TESTCASES</type>
> > +                  <includes>
> > +                    <include>core/*test.js</include>
> > +                    <include>core.io/*test.js</include>
> > +                    <include>views/*test.js</include>
> > +                  </includes>
> > +                </testSuite>
> > +                <testSuite>
> > +                  <name>OpenSocialJsTests</name>
> > +                  <type>TESTCASES</type>
> > +                  <includes>
> > +                    <include>opensocial-reference/*test.js</include>
> > +                    <include>opensocial-current/*test.js</include>
> > +                  </includes>
> > +                </testSuite>
> > +              </testSuites>
> > +            </configuration>
> > +            <goals>
> > +              <goal>jsunit-test</goal>
> > +            </goals>
> > +          </execution>
> >         </executions>
> >       </plugin>
> >     </plugins>
> >
> > Modified:
> >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingTask.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingTask.java?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingTask.java
> > (original)
> > +++
> >
> incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingTask.java
> > Tue Aug 19 21:14:39 2008
> > @@ -19,8 +19,6 @@
> >
> >  package org.apache.shindig.gadgets.servlet;
> >
> > -import com.google.inject.Inject;
> > -
> >  import org.apache.shindig.common.ContainerConfig;
> >  import org.apache.shindig.common.SecurityToken;
> >  import org.apache.shindig.common.SecurityTokenDecoder;
> > @@ -42,6 +40,9 @@
> >  import org.apache.shindig.gadgets.spec.ModulePrefs;
> >  import org.apache.shindig.gadgets.spec.Preload;
> >  import org.apache.shindig.gadgets.spec.View;
> > +
> > +import com.google.inject.Inject;
> > +
> >  import org.json.JSONArray;
> >  import org.json.JSONException;
> >  import org.json.JSONObject;
> >
> > Modified:
> > incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.full.xml
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.full.xml?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> > incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.full.xml
> > (original)
> > +++
> > incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.full.xml
> Tue
> > Aug 19 21:14:39 2008
> > @@ -18,15 +18,17 @@
> >   under the License.
> >  -->
> >  <!DOCTYPE web-app
> > -        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > -        "http://java.sun.com/dtd/web-app_2_3.dtd">
> > +    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > +    "http://java.sun.com/dtd/web-app_2_3.dtd">
> >
> >  <web-app>
> >   <!-- configuration -->
> >   <!-- If you have your own Guice module(s), put them here as a
> > colon-separated list. -->
> >   <context-param>
> >     <param-name>guice-modules</param-name>
> > -
> >
>  <param-value>org.apache.shindig.gadgets.servlet.HttpGuiceModule:org.apache.shindig.social.core.config.SocialApiGuiceModule</param-value>
> > +    <param-value>
> > +
> >
>  org.apache.shindig.gadgets.servlet.HttpGuiceModule:org.apache.shindig.social.core.config.SocialApiGuiceModule
> > +    </param-value>
> >   </context-param>
> >
> >   <filter>
> > @@ -104,6 +106,14 @@
> >     </servlet-class>
> >   </servlet>
> >
> > +  <!-- Serve RPC api -->
> > +  <servlet>
> > +    <servlet-name>jsonRpcServlet</servlet-name>
> > +    <servlet-class>
> > +      org.apache.shindig.social.opensocial.service.JsonRpcServlet
> > +    </servlet-class>
> > +  </servlet>
> > +
> >   <servlet-mapping>
> >     <servlet-name>js</servlet-name>
> >     <url-pattern>/gadgets/js/*</url-pattern>
> > @@ -143,4 +153,9 @@
> >     <servlet-name>restapiServlet</servlet-name>
> >     <url-pattern>/social/rest/*</url-pattern>
> >   </servlet-mapping>
> > +
> > +  <servlet-mapping>
> > +    <servlet-name>jsonRpcServlet</servlet-name>
> > +    <url-pattern>/social/rpc/*</url-pattern>
> > +  </servlet-mapping>
> >  </web-app>
> >
> > Modified:
> >
> incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.social.xml
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.social.xml?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.social.xml
> > (original)
> > +++
> >
> incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.social.xml
> > Tue Aug 19 21:14:39 2008
> > @@ -18,8 +18,8 @@
> >   under the License.
> >  -->
> >  <!DOCTYPE web-app
> > -        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > -        "http://java.sun.com/dtd/web-app_2_3.dtd">
> > +    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > +    "http://java.sun.com/dtd/web-app_2_3.dtd">
> >
> >  <web-app>
> >   <!-- configuration -->
> > @@ -51,8 +51,21 @@
> >     </servlet-class>
> >   </servlet>
> >
> > +  <!-- Serve RPC api -->
> > +  <servlet>
> > +    <servlet-name>jsonRpcServlet</servlet-name>
> > +    <servlet-class>
> > +      org.apache.shindig.social.opensocial.service.JsonRpcServlet
> > +    </servlet-class>
> > +  </servlet>
> > +
> >   <servlet-mapping>
> >     <servlet-name>restapiServlet</servlet-name>
> >     <url-pattern>/social/rest/*</url-pattern>
> >   </servlet-mapping>
> > +
> > +  <servlet-mapping>
> > +    <servlet-name>jsonRpcServlet</servlet-name>
> > +    <url-pattern>/social/rpc/*</url-pattern>
> > +  </servlet-mapping>
> >  </web-app>
> >
> > Modified:
> > incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > --- incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml
> > (original)
> > +++ incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml
> Tue
> > Aug 19 21:14:39 2008
> > @@ -18,17 +18,19 @@
> >   under the License.
> >  -->
> >  <!DOCTYPE web-app
> > -        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > -        "http://java.sun.com/dtd/web-app_2_3.dtd">
> > +    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > +    "http://java.sun.com/dtd/web-app_2_3.dtd">
> >
> >  <web-app>
> >   <!-- configuration -->
> >   <!-- If you have your own Guice module(s), put them here as a
> > colon-separated list. -->
> >   <context-param>
> >     <param-name>guice-modules</param-name>
> > -
> >
>  <param-value>org.apache.shindig.gadgets.servlet.HttpGuiceModule:org.apache.shindig.social.core.config.SocialApiGuiceModule</param-value>
> > +    <param-value>
> > +
> >
>  org.apache.shindig.gadgets.servlet.HttpGuiceModule:org.apache.shindig.social.core.config.SocialApiGuiceModule
> > +    </param-value>
> >   </context-param>
> > -
> > +
> >   <filter>
> >     <filter-name>oauthFilter</filter-name>
> >
> >
> <filter-class>org.apache.shindig.social.core.oauth.AuthenticationServletFilter</filter-class>
> > @@ -105,6 +107,14 @@
> >     </servlet-class>
> >   </servlet>
> >
> > +  <!-- Serve RPC api -->
> > +  <servlet>
> > +    <servlet-name>jsonRpcServlet</servlet-name>
> > +    <servlet-class>
> > +      org.apache.shindig.social.opensocial.service.JsonRpcServlet
> > +    </servlet-class>
> > +  </servlet>
> > +
> >   <servlet-mapping>
> >     <servlet-name>js</servlet-name>
> >     <url-pattern>/gadgets/js/*</url-pattern>
> > @@ -144,4 +154,9 @@
> >     <servlet-name>restapiServlet</servlet-name>
> >     <url-pattern>/social/rest/*</url-pattern>
> >   </servlet-mapping>
> > +
> > +  <servlet-mapping>
> > +    <servlet-name>jsonRpcServlet</servlet-name>
> > +    <url-pattern>/social/rpc/*</url-pattern>
> > +  </servlet-mapping>
> >  </web-app>
> >
> > Modified:
> >
> incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java
> > (original)
> > +++
> >
> incubator/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndServer.java
> > Tue Aug 19 21:14:39 2008
> > @@ -17,15 +17,16 @@
> >  */
> >  package org.apache.shindig.server.endtoend;
> >
> > -import com.google.common.base.Join;
> > -import com.google.common.collect.Maps;
> > -
> >  import org.apache.shindig.common.servlet.GuiceServletContextListener;
> >  import org.apache.shindig.gadgets.servlet.ConcatProxyServlet;
> >  import org.apache.shindig.gadgets.servlet.GadgetRenderingServlet;
> >  import org.apache.shindig.gadgets.servlet.HttpGuiceModule;
> > -import org.apache.shindig.social.opensocial.service.DataServiceServlet;
> >  import org.apache.shindig.social.core.oauth.AuthenticationServletFilter;
> > +import org.apache.shindig.social.opensocial.service.DataServiceServlet;
> > +import org.apache.shindig.social.opensocial.service.JsonRpcServlet;
> > +
> > +import com.google.common.base.Join;
> > +import com.google.common.collect.Maps;
> >
> >  import org.mortbay.jetty.Server;
> >  import org.mortbay.jetty.handler.ResourceHandler;
> > @@ -51,7 +52,8 @@
> >  public class EndToEndServer {
> >   private static final int JETTY_PORT = 9003;
> >   private static final String GADGET_BASE = "/gadgets/ifr";
> > -  private static final String JSON_BASE = "/social/rest/*";
> > +  private static final String REST_BASE = "/social/rest/*";
> > +  private static final String JSON_RPC_BASE = "/social/rpc/*";
> >   private static final String CONCAT_BASE = "/gadgets/concat";
> >   public static final String SERVER_URL = "http://localhost:" +
> > JETTY_PORT;
> >   public static final String GADGET_BASEURL = SERVER_URL + GADGET_BASE;
> > @@ -112,10 +114,16 @@
> >     context.addServlet(gadgetServletHolder, GADGET_BASE);
> >
> >     // Attach DataServiceServlet, wrapped in a proxy to fake errors
> > -    ServletHolder jsonServletHolder = new ServletHolder(new
> > ForceErrorServlet(
> > +    ServletHolder restServletHolder = new ServletHolder(new
> > ForceErrorServlet(
> >         new DataServiceServlet()));
> > -    context.addServlet(jsonServletHolder, JSON_BASE);
> > -    context.addFilter(AuthenticationServletFilter.class, JSON_BASE, 0);
> > +    context.addServlet(restServletHolder, REST_BASE);
> > +    context.addFilter(AuthenticationServletFilter.class, REST_BASE, 0);
> > +
> > +    // Attach JsonRpcServlet, wrapped in a proxy to fake errors
> > +    ServletHolder rpcServletHolder = new ServletHolder(new
> > ForceErrorServlet(
> > +        new JsonRpcServlet()));
> > +    context.addServlet(rpcServletHolder, JSON_RPC_BASE);
> > +    context.addFilter(AuthenticationServletFilter.class, JSON_RPC_BASE,
> > 0);
> >
> >     // Attach the ConcatProxyServlet - needed for
> >     ServletHolder concatHolder = new ServletHolder(new
> > ConcatProxyServlet());
> >
> > Modified:
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ActivityHandler.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ActivityHandler.java?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ActivityHandler.java
> > (original)
> > +++
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ActivityHandler.java
> > Tue Aug 19 21:14:39 2008
> > @@ -31,7 +31,7 @@
> >
> >  public class ActivityHandler extends DataRequestHandler {
> >
> > -  private ActivityService service;
> > +  private final ActivityService service;
> >
> >   // TODO: The appId should come from the url. The spec needs to be
> fixed!
> >   private static final String ACTIVITY_ID_PATH =
> > "/activities/{userId}+/{groupId}/{activityId}+";
> > @@ -50,7 +50,7 @@
> >    * examples: /activities/john.doe/@self/1
> >    */
> >   protected Future<? extends ResponseItem> handleDelete(RequestItem
> > request) {
> > -    request.parseUrlWithTemplate(ACTIVITY_ID_PATH);
> > +    request.applyUrlTemplate(ACTIVITY_ID_PATH);
> >
> >     Set<UserId> userIds = request.getUsers();
> >     Set<String> activityIds =
> > Sets.newLinkedHashSet(request.getListParameter("activityId"));
> > @@ -77,7 +77,7 @@
> >    * examples: /activities/john.doe/@self - postBody is an activity
> object
> >    */
> >   protected Future<? extends ResponseItem> handlePost(RequestItem
> request)
> > {
> > -    request.parseUrlWithTemplate(GROUP_PATH);
> > +    request.applyUrlTemplate(GROUP_PATH);
> >
> >     Set<UserId> userIds = request.getUsers();
> >     List<String> activityIds = request.getListParameter("activityId");
> > @@ -88,7 +88,8 @@
> >     Preconditions.requireEmpty(activityIds, "Cannot specify activityId in
> > create");
> >
> >     return service.createActivity(userIds.iterator().next(),
> > request.getGroup(),
> > -        request.getAppId(), request.getFields(),
> > request.getPostData(Activity.class),
> > +        request.getAppId(), request.getFields(),
> > +        request.getTypedParameter("activity", Activity.class),
> >         request.getToken());
> >   }
> >
> > @@ -100,7 +101,7 @@
> >    * /activities/john.doe,jane.doe/@friends
> >    */
> >   protected Future<? extends ResponseItem> handleGet(RequestItem request)
> {
> > -    request.parseUrlWithTemplate(ACTIVITY_ID_PATH);
> > +    request.applyUrlTemplate(ACTIVITY_ID_PATH);
> >
> >     Set<UserId> userIds = request.getUsers();
> >     Set<String> optionalActivityIds =
> > Sets.newLinkedHashSet(request.getListParameter("activityId"));
> >
> > Added:
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ApiServlet.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ApiServlet.java?rev=687235&view=auto
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ApiServlet.java
> > (added)
> > +++
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/ApiServlet.java
> > Tue Aug 19 21:14:39 2008
> > @@ -0,0 +1,103 @@
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF) under one
> > + * or more contributor license agreements. See the NOTICE file
> > + * distributed with this work for additional information
> > + * regarding copyright ownership. The ASF licenses this file
> > + * to you under the Apache License, Version 2.0 (the
> > + * "License"); you may not use this file except in compliance
> > + * with the License. You may obtain a copy of the License at
> > + *
> > + *     http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing,
> > + * software distributed under the License is distributed on an
> > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> > + * KIND, either express or implied. See the License for the
> > + * specific language governing permissions and limitations under the
> > License.
> > + */
> > +package org.apache.shindig.social.opensocial.service;
> > +
> > +import org.apache.shindig.common.SecurityToken;
> > +import org.apache.shindig.common.servlet.InjectedServlet;
> > +import org.apache.shindig.common.util.ImmediateFuture;
> > +import org.apache.shindig.social.ResponseError;
> > +import org.apache.shindig.social.ResponseItem;
> > +import org.apache.shindig.social.core.oauth.AuthenticationServletFilter;
> > +import org.apache.shindig.social.core.util.BeanJsonConverter;
> > +
> > +import com.google.inject.Inject;
> > +import com.google.inject.Injector;
> > +import com.google.inject.name.Named;
> > +
> > +import java.util.Map;
> > +import java.util.concurrent.ExecutionException;
> > +import java.util.concurrent.Future;
> > +
> > +import javax.servlet.http.HttpServletRequest;
> > +
> > +/**
> > + * Common base class for API servlets.
> > + */
> > +public class ApiServlet extends InjectedServlet {
> > +
> > +  private Map<String, Class<? extends DataRequestHandler>> handlers;
> > +
> > +  protected BeanJsonConverter jsonConverter;
> > +
> > +  protected BeanConverter xmlConverter;
> > +
> > +  @Inject
> > +  public void setHandlers(HandlerProvider handlers) {
> > +    this.handlers = handlers.get();
> > +  }
> > +
> > +  @Inject
> > +  public void setBeanConverters(
> > +      @Named("shindig.bean.converter.json")BeanConverter jsonConverter,
> > +      @Named("shindig.bean.converter.xml")BeanConverter xmlConverter) {
> > +    // fix this
> > +    this.jsonConverter = (BeanJsonConverter) jsonConverter;
> > +    this.xmlConverter = xmlConverter;
> > +  }
> > +
> > +  // Only for testing use. Do not override the injector.
> > +  public void setInjector(Injector injector) {
> > +    this.injector = injector;
> > +  }
> > +
> > +  protected SecurityToken getSecurityToken(HttpServletRequest
> > servletRequest) {
> > +    return ((AuthenticationServletFilter.SecurityTokenRequest)
> > servletRequest).getToken();
> > +  }
> > +
> > +  /**
> > +   * Delivers a request item to the appropriate DataRequestHandler.
> > +   */
> > +  protected Future<? extends ResponseItem> handleRequestItem(RequestItem
> > requestItem) {
> > +    Class<? extends DataRequestHandler> handlerClass =
> > handlers.get(requestItem.getService());
> > +
> > +    if (handlerClass == null) {
> > +      return ImmediateFuture.newInstance(new
> > ResponseItem<Object>(ResponseError.NOT_IMPLEMENTED,
> > +          "The service " + requestItem.getService() + " is not
> > implemented", null));
> > +    }
> > +
> > +    DataRequestHandler handler = injector.getInstance(handlerClass);
> > +    return handler.handleItem(requestItem);
> > +  }
> > +
> > +  protected ResponseItem getResponseItem(Future<? extends ResponseItem>
> > future) {
> > +    ResponseItem response;
> > +    try {
> > +      // TODO: use timeout methods?
> > +      response = future.get();
> > +    } catch (InterruptedException ie) {
> > +      response = responseItemFromException(ie);
> > +    } catch (ExecutionException ee) {
> > +      response = responseItemFromException(ee.getCause());
> > +    }
> > +    return response;
> > +  }
> > +
> > +  protected ResponseItem<?> responseItemFromException(Throwable t) {
> > +    return new ResponseItem<Void>(ResponseError.INTERNAL_ERROR,
> > t.getMessage(), null);
> > +  }
> > +}
> >
> > Modified:
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/AppDataHandler.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/AppDataHandler.java?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/AppDataHandler.java
> > (original)
> > +++
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/AppDataHandler.java
> > Tue Aug 19 21:14:39 2008
> > @@ -32,7 +32,7 @@
> >
> >  public class AppDataHandler extends DataRequestHandler {
> >
> > -  private AppDataService service;
> > +  private final AppDataService service;
> >
> >   private static final String APP_DATA_PATH =
> > "/people/{userId}+/{groupId}/{appId}";
> >
> > @@ -51,7 +51,7 @@
> >    * overridden.
> >    */
> >   protected Future<? extends ResponseItem> handleDelete(RequestItem
> > request) {
> > -    request.parseUrlWithTemplate(APP_DATA_PATH);
> > +    request.applyUrlTemplate(APP_DATA_PATH);
> >
> >     Set<UserId> userIds = request.getUsers();
> >
> > @@ -84,14 +84,14 @@
> >    * values and set. If there are no fields vars then all of the data
> will
> > be overridden.
> >    */
> >   protected Future<? extends ResponseItem> handlePost(RequestItem
> request)
> > {
> > -    request.parseUrlWithTemplate(APP_DATA_PATH);
> > +    request.applyUrlTemplate(APP_DATA_PATH);
> >
> >     Set<UserId> userIds = request.getUsers();
> >
> >     Preconditions.requireNotEmpty(userIds, "No userId specified");
> >     Preconditions.requireSingular(userIds, "Multiple userIds not
> > supported");
> >
> > -    Map<String, String> values = request.getPostData(HashMap.class);
> > +    Map<String, String> values = request.getTypedParameter("data",
> > HashMap.class);
> >     for (String key : values.keySet()) {
> >       if (!isValidKey(key)) {
> >         return ImmediateFuture.newInstance(new
> > ResponseItem<Object>(ResponseError.BAD_REQUEST,
> > @@ -109,7 +109,7 @@
> >    * examples: /appdata/john.doe/@friends/app?fields=count
> > /appdata/john.doe/@self/app
> >    */
> >   protected Future<? extends ResponseItem> handleGet(RequestItem request)
> {
> > -    request.parseUrlWithTemplate(APP_DATA_PATH);
> > +    request.applyUrlTemplate(APP_DATA_PATH);
> >
> >     Set<UserId> userIds = request.getUsers();
> >
> >
> > Modified:
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataRequestHandler.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataRequestHandler.java?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataRequestHandler.java
> > (original)
> > +++
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataRequestHandler.java
> > Tue Aug 19 21:14:39 2008
> > @@ -21,32 +21,44 @@
> >  import org.apache.shindig.social.ResponseError;
> >  import org.apache.shindig.social.ResponseItem;
> >
> > +import com.google.common.collect.Sets;
> > +
> >  import java.util.Collection;
> > +import java.util.Set;
> >  import java.util.concurrent.Future;
> >
> >  public abstract class DataRequestHandler {
> >
> > +  private static final Set<String> GET_SYNONYMS =
> Sets.newHashSet("get");
> > +  private static final Set<String> CREATE_SYNONYMS =
> > Sets.newHashSet("put", "create");
> > +  private static final Set<String> UPDATE_SYNONYMS =
> > Sets.newHashSet("post", "update");
> > +  private static final Set<String> DELETE_SYNONYMS =
> > Sets.newHashSet("delete", "delete");
> > +
> >   public Future<? extends ResponseItem> handleItem(RequestItem request) {
> > -    String httpMethod = request.getMethod();
> > +    if (request.getOperation() == null) {
> > +      return error(ResponseError.NOT_IMPLEMENTED, "Unserviced operation
> ",
> > null);
> > +    }
> > +    String operation = request.getOperation().toLowerCase();
> >     Future<? extends ResponseItem> responseItem;
> > -
> >     try {
> > -      if ("GET".equals(httpMethod)) {
> > +      if (GET_SYNONYMS.contains(operation)) {
> >         responseItem = handleGet(request);
> > -      } else if ("POST".equals(httpMethod)) {
> > +      } else if (UPDATE_SYNONYMS.contains(operation)) {
> >         responseItem = handlePost(request);
> > -      } else if ("PUT".equals(httpMethod)) {
> > +      } else if (CREATE_SYNONYMS.contains(operation)) {
> >         responseItem = handlePut(request);
> > -      } else if ("DELETE".equals(httpMethod)) {
> > +      } else if (DELETE_SYNONYMS.contains(operation)) {
> >         responseItem = handleDelete(request);
> >       } else {
> > -        return error(ResponseError.NOT_IMPLEMENTED, "Unserviced Http
> > method type", httpMethod);
> > +        return error(ResponseError.NOT_IMPLEMENTED, "Unserviced
> > operation", operation);
> >       }
> > -      return responseItem;
> >     } catch (IllegalArgumentException iae) {
> > -      // Upconvert IllegalArgumentExceptions to errors.
> > +      // Upconvert IllegalArgumentExceptions to BAD_REQUEST.
> >       return error(ResponseError.BAD_REQUEST, iae.getMessage(), null);
> > +    } catch (Throwable t) {
> > +      return error(ResponseError.INTERNAL_ERROR, "Unknown error " +
> > t.getMessage(), null);
> >     }
> > +    return responseItem;
> >   }
> >
> >   protected abstract Future<? extends ResponseItem>
> > handleDelete(RequestItem request);
> >
> > Modified:
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServlet.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServlet.java?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServlet.java
> > (original)
> > +++
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServlet.java
> > Tue Aug 19 21:14:39 2008
> > @@ -18,37 +18,19 @@
> >  package org.apache.shindig.social.opensocial.service;
> >
> >  import org.apache.shindig.common.SecurityToken;
> > -import org.apache.shindig.common.servlet.InjectedServlet;
> > -import org.apache.shindig.common.util.ImmediateFuture;
> >  import org.apache.shindig.social.ResponseError;
> >  import org.apache.shindig.social.ResponseItem;
> > -import org.apache.shindig.social.core.oauth.AuthenticationServletFilter;
> >
> > -import com.google.common.collect.Maps;
> > -import com.google.inject.Inject;
> > -import com.google.inject.Injector;
> > -import com.google.inject.name.Named;
> > -import org.apache.commons.io.IOUtils;
> > -import org.apache.commons.lang.StringUtils;
> > -import org.json.JSONException;
> > -import org.json.JSONObject;
> > +import java.io.IOException;
> > +import java.io.PrintWriter;
> > +import java.util.logging.Logger;
> >
> >  import javax.servlet.ServletException;
> >  import javax.servlet.http.HttpServletRequest;
> >  import javax.servlet.http.HttpServletResponse;
> > -import java.io.IOException;
> > -import java.io.PrintWriter;
> > -import java.util.Iterator;
> > -import java.util.Map;
> > -import java.util.concurrent.ExecutionException;
> > -import java.util.concurrent.Future;
> > -import java.util.logging.Logger;
> >
> > -public class DataServiceServlet extends InjectedServlet {
> > +public class DataServiceServlet extends ApiServlet {
> >
> > -  protected static final String X_HTTP_METHOD_OVERRIDE =
> > "X-HTTP-Method-Override";
> > -  protected static final String SECURITY_TOKEN_PARAM = "st";
> > -  protected static final String REQUEST_PARAMETER = "request";
> >   protected static final String FORMAT_PARAM = "format";
> >   protected static final String ATOM_FORMAT = "atom";
> >
> > @@ -59,29 +41,6 @@
> >   private static final Logger logger = Logger.getLogger(
> >       "org.apache.shindig.social.opensocial.spi");
> >
> > -  private transient Map<String, Class<? extends DataRequestHandler>>
> > handlers;
> > -  private transient BeanConverter jsonConverter;
> > -  private transient BeanConverter xmlConverter;
> > -
> > -  private static final String JSON_BATCH_ROUTE = "jsonBatch";
> > -
> > -  @Inject
> > -  public void setHandlers(HandlerProvider handlers) {
> > -    this.handlers = handlers.get();
> > -  }
> > -
> > -  @Inject
> > -  public void setBeanConverters(@Named("shindig.bean.converter.json")
> > BeanConverter jsonConverter,
> > -    @Named("shindig.bean.converter.xml")  BeanConverter xmlConverter) {
> > -    this.jsonConverter = jsonConverter;
> > -    this.xmlConverter = xmlConverter;
> > -  }
> > -
> > -  // Only for testing use. Do not override the injector.
> > -  public void setInjector(Injector injector) {
> > -    this.injector = injector;
> > -  }
> > -
> >   protected void doGet(HttpServletRequest servletRequest,
> >       HttpServletResponse servletResponse)
> >       throws ServletException, IOException {
> > @@ -117,32 +76,22 @@
> >
> >     BeanConverter converter = getConverterForRequest(servletRequest);
> >
> > -    if (isBatchUrl(servletRequest)) {
> > -      try {
> > -        handleBatchRequest(servletRequest, servletResponse, token,
> > converter);
> > -      } catch (JSONException e) {
> > -        sendError(servletResponse, new
> > ResponseItem<Object>(ResponseError.BAD_REQUEST,
> > -            "The batch request had an invalid format.", null));
> > -      }
> > -    } else {
> > -      handleSingleRequest(servletRequest, servletResponse, token,
> > converter);
> > -    }
> > +    handleSingleRequest(servletRequest, servletResponse, token,
> > converter);
> >   }
> >
> >   private void sendError(HttpServletResponse servletResponse,
> ResponseItem
> > responseItem)
> >       throws IOException {
> >     servletResponse.sendError(responseItem.getError().getHttpErrorCode(),
> > -          responseItem.getErrorMessage());
> > +        responseItem.getErrorMessage());
> >   }
> >
> > -  /** Handler for non-batch requests */
> > +  /**
> > +   * Handler for non-batch requests
> > +   */
> >   private void handleSingleRequest(HttpServletRequest servletRequest,
> >       HttpServletResponse servletResponse, SecurityToken token,
> >       BeanConverter converter) throws IOException {
> > -    String method =
> getHttpMethodFromParameter(servletRequest.getMethod(),
> > -        servletRequest.getParameter(X_HTTP_METHOD_OVERRIDE));
> > -
> > -    RequestItem requestItem = new RequestItem(servletRequest, token,
> > method, converter);
> > +    RestfulRequestItem requestItem = new
> > RestfulRequestItem(servletRequest, token, converter);
> >     ResponseItem responseItem =
> > getResponseItem(handleRequestItem(requestItem));
> >
> >     if (responseItem.getError() == null) {
> > @@ -153,81 +102,6 @@
> >     }
> >   }
> >
> > -  private void handleBatchRequest(HttpServletRequest servletRequest,
> > -      HttpServletResponse servletResponse, SecurityToken token,
> > -      BeanConverter converter) throws IOException, JSONException {
> > -
> > -    byte[] postedBytes =
> > IOUtils.toByteArray(servletRequest.getInputStream());
> > -    JSONObject requests = new JSONObject(new String(postedBytes));
> > -    Map<String, Future<? extends ResponseItem>> responses =
> > Maps.newHashMap();
> > -
> > -    // Gather all Futures.  We do this up front so that
> > -    // the first call to get() comes after all futures are created,
> > -    // which allows for implementations that batch multiple Futures
> > -    // into single requests.
> > -    Iterator keys = requests.keys();
> > -    while (keys.hasNext()) {
> > -      String key = (String) keys.next();
> > -      String request = requests.getString(key);
> > -
> > -      RequestItem requestItem = converter.convertToObject(request,
> > RequestItem.class);
> > -      requestItem.setToken(token);
> > -      requestItem.setConverter(converter);
> > -
> > -      responses.put(key, handleRequestItem(requestItem));
> > -    }
> > -
> > -    // Resolve each Future into a response.
> > -    // TODO: should use shared deadline across each request
> > -    Map<String, ResponseItem> resolvedResponses = Maps.newHashMap();
> > -    for (Map.Entry<String, Future<? extends ResponseItem>> responseEntry
> :
> > responses.entrySet()) {
> > -      ResponseItem response = getResponseItem(responseEntry.getValue());
> > -      resolvedResponses.put(responseEntry.getKey(), response);
> > -    }
> > -
> > -    PrintWriter writer = servletResponse.getWriter();
> > -    writer.write(converter.convertToString(
> > -        Maps.immutableMap("error", false, "responses",
> > resolvedResponses)));
> > -  }
> > -
> > -  private ResponseItem getResponseItem(Future<? extends ResponseItem>
> > future) {
> > -    ResponseItem response;
> > -    try {
> > -      // TODO: use timeout methods?
> > -      response = future.get();
> > -    } catch (InterruptedException ie) {
> > -      response = responseItemFromException(ie);
> > -    } catch (ExecutionException ee) {
> > -      response = responseItemFromException(ee.getCause());
> > -    }
> > -    return response;
> > -  }
> > -
> > -  /**
> > -   * Delivers a request item to the appropriate DataRequestHandler.
> > -   *
> > -   * @return the resulting ResponseItem
> > -   */
> > -  Future<? extends ResponseItem> handleRequestItem(RequestItem
> > requestItem) {
> > -    String route = getRouteFromParameter(requestItem.getUrl());
> > -    Class<? extends DataRequestHandler> handlerClass =
> > handlers.get(route);
> > -
> > -    if (handlerClass == null) {
> > -      return ImmediateFuture.newInstance(new
> > ResponseItem<Object>(ResponseError.BAD_REQUEST,
> > -          "The url path " + route + " is not supported", null));
> > -    }
> > -
> > -    DataRequestHandler handler = injector.getInstance(handlerClass);
> > -    return handler.handleItem(requestItem);
> > -  }
> > -
> > -  private ResponseItem<?> responseItemFromException(Throwable t) {
> > -    return new ResponseItem<Void>(ResponseError.INTERNAL_ERROR,
> > t.getMessage(), null);
> > -  }
> > -
> > -  SecurityToken getSecurityToken(HttpServletRequest servletRequest) {
> > -    return ((AuthenticationServletFilter.SecurityTokenRequest)
> > servletRequest).getToken();
> > -  }
> >
> >   BeanConverter getConverterForRequest(HttpServletRequest servletRequest)
> {
> >     String formatString = servletRequest.getParameter(FORMAT_PARAM);
> > @@ -236,26 +110,4 @@
> >     }
> >     return jsonConverter;
> >   }
> > -
> > -  String getHttpMethodFromParameter(String method, String
> > overrideParameter) {
> > -    if (!StringUtils.isBlank(overrideParameter)) {
> > -      return overrideParameter;
> > -    } else {
> > -      return method;
> > -    }
> > -  }
> > -
> > -  String getRouteFromParameter(String pathInfo) {
> > -    pathInfo = pathInfo.substring(1);
> > -    int indexOfNextPathSeparator = pathInfo.indexOf('/');
> > -    if ( indexOfNextPathSeparator != -1 ) {
> > -      return pathInfo.substring(0, indexOfNextPathSeparator);
> > -    }
> > -    return pathInfo;
> > -  }
> > -
> > -  boolean isBatchUrl(HttpServletRequest servletRequest) {
> > -    String[] parts = servletRequest.getPathInfo().split("/");
> > -    return parts[parts.length - 1].equals(JSON_BATCH_ROUTE);
> > -  }
> >  }
> >
> > Modified:
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServletFetcher.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServletFetcher.java?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServletFetcher.java
> > (original)
> > +++
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/DataServiceServletFetcher.java
> > Tue Aug 19 21:14:39 2008
> > @@ -15,7 +15,6 @@
> >  * KIND, either express or implied. See the License for the
> >  * specific language governing permissions and limitations under the
> > License.
> >  */
> > -
> >  package org.apache.shindig.social.opensocial.service;
> >
> >  import org.apache.shindig.common.SecurityTokenDecoder;
> > @@ -23,15 +22,16 @@
> >
> >  import com.google.common.collect.Maps;
> >
> > -import javax.servlet.http.HttpServletRequest;
> >  import java.util.Map;
> >
> > +import javax.servlet.http.HttpServletRequest;
> > +
> >  /**
> > - * Default implementation for the GadgetDataServlet parameter fetcher.
> Do
> > not
> > - * change unless you have a compelling need to pass more parameters into
> > the
> > - * createResponse method.
> > + * Default implementation for the GadgetDataServlet parameter fetcher.
> Do
> > not change unless you have
> > + * a compelling need to pass more parameters into the createResponse
> > method.
> >  */
> >  public class DataServiceServletFetcher implements ParameterFetcher {
> > +
> >   public Map<String, String> fetch(HttpServletRequest req) {
> >     return Maps.immutableMap(SecurityTokenDecoder.SECURITY_TOKEN_NAME,
> > req.getParameter("st"));
> >   }
> >
> > Added:
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonConversionUtils.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonConversionUtils.java?rev=687235&view=auto
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonConversionUtils.java
> > (added)
> > +++
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonConversionUtils.java
> > Tue Aug 19 21:14:39 2008
> > @@ -0,0 +1,201 @@
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF) under one
> > + * or more contributor license agreements. See the NOTICE file
> > + * distributed with this work for additional information
> > + * regarding copyright ownership. The ASF licenses this file
> > + * to you under the Apache License, Version 2.0 (the
> > + * "License"); you may not use this file except in compliance
> > + * with the License. You may obtain a copy of the License at
> > + *
> > + *     http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing,
> > + * software distributed under the License is distributed on an
> > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> > + * KIND, either express or implied. See the License for the
> > + * specific language governing permissions and limitations under the
> > License.
> > + */
> > +package org.apache.shindig.social.opensocial.service;
> > +
> > +import com.google.common.collect.Maps;
> > +import com.google.common.collect.Sets;
> > +import com.google.common.collect.ImmutableSet;
> > +
> > +import org.json.JSONArray;
> > +import org.json.JSONException;
> > +import org.json.JSONObject;
> > +
> > +import java.util.Iterator;
> > +import java.util.Map;
> > +import java.util.Set;
> > +import java.util.regex.Matcher;
> > +import java.util.regex.Pattern;
> > +
> > +import javax.servlet.http.HttpServletRequest;
> > +
> > +/**
> > + * Utilities for converting a JSON object to and from a URL encoding
> > + */
> > +public class JsonConversionUtils {
> > +
> > +  private static final Pattern ARRAY_MATCH =
> > Pattern.compile("(\\w+)\\((\\d+)\\)");
> > +
> > +  private static final Set<String> RESERVED_PARAMS =
> > ImmutableSet.of("method", "id", "st");
> > +
> > +  public static JSONObject fromRequest(HttpServletRequest request)
> throws
> > JSONException {
> > +    //String methodName = request.getPathInfo().replaceAll("/", "");
> > +
> > +    JSONObject root = new JSONObject();
> > +    Map<String, String[]> params = (Map<String, String[]>)
> > request.getParameterMap();
>
>
> I still don't understand why you have so much custom code in this class.
> This is so specific to json and isn't hidden behind the BeanConverter
> interface which means supporting xml is going to be a nightmare...
>
> We could at least build a cleaned up map here from String to String and
> have
> the converter turn that into an object for us.


Ill move the utility class somewhere more utilitarian like common as it has
some general usefulness. Ill create a QueryParamBeanConverter and inject it.


>
>
>
> >
> > +    root.put("method", params.get("method")[0]);
> > +    if (params.containsKey("id")) {
> > +      root.put("id", params.get("id")[0]);
> > +    }
> > +    JSONObject paramsRoot = new JSONObject();
> > +    for (Map.Entry<String, String[]> entry : params.entrySet()) {
> > +      if (!RESERVED_PARAMS.contains(entry.getKey().toLowerCase())) {
> > +        String[] path = entry.getKey().split("\\.");
> > +        JSONObject holder = buildHolder(paramsRoot, path, 0);
> > +        holder.put(path[path.length - 1],
> > convertToJsonValue(entry.getValue()[0]));
> > +      }
> > +    }
> > +    if (paramsRoot.length() > 0) {
> > +      root.put("params", paramsRoot);
> > +    }
> > +    return root;
> > +  }
> > +
> > +  public static Map<String, String> fromJson(JSONObject obj) throws
> > JSONException {
> > +    Map<String, String> result = Maps.newHashMap();
> > +    collect(obj, "", result);
> > +    return result;
> > +  }
> > +
> > +  private static void collect(Object current, String prefix, Map<String,
> > String> result)
> > +      throws JSONException {
> > +    if (current == null) {
> > +      result.put(prefix, "null");
> > +      return;
> > +    }
> > +
> > +    if (current instanceof JSONObject) {
> > +      JSONObject json = (JSONObject) current;
> > +      Iterator keys = json.keys();
> > +      while (keys.hasNext()) {
> > +        String key = (String) keys.next();
> > +        if (json.isNull(key)) {
> > +          result.put(prefix + "." + key, "null");
> > +        } else {
> > +          collect(json.get(key), prefix + "." + key, result);
> > +        }
> > +      }
> > +    } else if (current instanceof JSONArray) {
> > +      JSONArray jsonArr = (JSONArray) current;
> > +      if (isAllLiterals(jsonArr)) {
> > +        // The array is all simple value types
> > +        String jsonArrayString = jsonArr.toString();
> > +        //Strip [ & ]
> > +        jsonArrayString = jsonArrayString.substring(1,
> > jsonArrayString.length() - 1);
> > +        if (jsonArr.length() == 1) {
> > +          jsonArrayString = "(" + jsonArrayString + ")";
> > +        }
> > +        result.put(prefix, jsonArrayString);
> > +      } else {
> > +        for (int i = 0; i < jsonArr.length(); i++) {
> > +          if (jsonArr.isNull(i)) {
> > +            result.put(prefix + "(" + i + ")", "null");
> > +          } else {
> > +            collect(jsonArr.get(i), prefix + "(" + i + ")", result);
> > +          }
> > +        }
> > +      }
> > +    } else {
> > +      result.put(prefix, current.toString());
> > +    }
> > +  }
> > +
> > +  public static boolean isAllLiterals(JSONArray jsonArr) throws
> > JSONException {
> > +    for (int i = 0; i < jsonArr.length(); i++) {
> > +      if (!jsonArr.isNull(i) &&
> > +          (jsonArr.get(i) instanceof JSONObject ||
> > +              jsonArr.get(i) instanceof JSONArray)) {
> > +        return false;
> > +      }
> > +    }
> > +    return true;
> > +  }
> > +
> > +  static JSONObject parametersToJsonObject(Map<String, String> params)
> > throws JSONException {
> > +    JSONObject root = new JSONObject();
> > +
> > +    for (Map.Entry<String, String> entry : params.entrySet()) {
> > +      String[] path = entry.getKey().split("\\.");
> > +      JSONObject holder = buildHolder(root, path, 0);
> > +      if (path.length > 1) {
> > +        holder.put(path[path.length - 1],
> > convertToJsonValue(entry.getValue()));
> > +      } else {
> > +        holder.put(path[0], convertToJsonValue(entry.getValue()));
> > +      }
> > +    }
> > +
> > +    return root;
> > +  }
> > +
> > +  /**
> > +   * Parse the steps in the path into JSON Objects.
> > +   */
> > +  static JSONObject buildHolder(JSONObject root, String[] steps, int
> > currentStep)
> > +      throws JSONException {
> > +    if (currentStep > steps.length - 2) {
> > +      return root;
> > +    } else {
> > +      Matcher matcher = ARRAY_MATCH.matcher(steps[currentStep]);
> > +      if (matcher.matches()) {
> > +        // Handle as array
> > +        String fieldName = matcher.group(1);
> > +        int index = Integer.parseInt(matcher.group(2));
> > +        JSONArray newArrayStep;
> > +        if (root.has(fieldName)) {
> > +          newArrayStep = root.getJSONArray(fieldName);
> > +        } else {
> > +          newArrayStep = new JSONArray();
> > +          root.put(fieldName, newArrayStep);
> > +        }
> > +        JSONObject newStep = new JSONObject();
> > +        newArrayStep.put(index, newStep);
> > +        return buildHolder(newStep, steps, ++currentStep);
> > +      } else {
> > +        JSONObject newStep;
> > +        if (root.has(steps[currentStep])) {
> > +          newStep = root.getJSONObject(steps[currentStep]);
> > +        } else {
> > +          newStep = new JSONObject();
> > +          root.put(steps[currentStep], newStep);
> > +        }
> > +        return buildHolder(newStep, steps, ++currentStep);
> > +      }
> > +    }
> > +  }
> > +
> > +  static Object convertToJsonValue(String value) throws JSONException {
> > +    if (value == null) {
> > +      return null;
> > +    } else if (value.startsWith("(") && value.endsWith(")")) {
> > +      // explicit form of literal array
> > +      return new JSONArray("[" + value.substring(1, value.length() - 1)
> +
> > "]");
> > +    } else {
> > +      try {
> > +        // inferred parsing of literal array
> > +        // Attempt to parse as an array of literals
> > +        JSONArray parsedArray = new JSONArray("[" + value + "]");
> > +        if (parsedArray.length() == 1) {
> > +          // Not an array
> > +          return parsedArray.get(0);
> > +        }
> > +        return parsedArray;
> > +      } catch (JSONException je) {
> > +        return value;
> > +      }
> > +    }
> > +  }
> > +}
> >
> > Added:
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonRpcServlet.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonRpcServlet.java?rev=687235&view=auto
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonRpcServlet.java
> > (added)
> > +++
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/JsonRpcServlet.java
> > Tue Aug 19 21:14:39 2008
> > @@ -0,0 +1,164 @@
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF) under one
> > + * or more contributor license agreements. See the NOTICE file
> > + * distributed with this work for additional information
> > + * regarding copyright ownership. The ASF licenses this file
> > + * to you under the Apache License, Version 2.0 (the
> > + * "License"); you may not use this file except in compliance
> > + * with the License. You may obtain a copy of the License at
> > + *
> > + *     http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing,
> > + * software distributed under the License is distributed on an
> > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> > + * KIND, either express or implied. See the License for the
> > + * specific language governing permissions and limitations under the
> > License.
> > + */
> > +package org.apache.shindig.social.opensocial.service;
> > +
> > +import org.apache.shindig.common.SecurityToken;
> > +import org.apache.shindig.social.ResponseItem;
> > +import org.apache.shindig.social.ResponseError;
> > +import org.apache.shindig.social.opensocial.spi.DataCollection;
> > +import org.apache.shindig.social.opensocial.spi.RestfulCollection;
> > +
> > +import com.google.common.collect.Maps;
> > +import com.google.common.collect.Lists;
> > +
> > +import org.apache.commons.io.IOUtils;
> > +import org.json.JSONArray;
> > +import org.json.JSONException;
> > +import org.json.JSONObject;
> > +
> > +import java.io.IOException;
> > +import java.util.Map;
> > +import java.util.List;
> > +import java.util.concurrent.Future;
> > +
> > +import javax.servlet.ServletException;
> > +import javax.servlet.http.HttpServletRequest;
> > +import javax.servlet.http.HttpServletResponse;
> > +
> > +/**
> > + * JSON-RPC handler servlet.
> > + */
> > +public class JsonRpcServlet extends ApiServlet {
> > +
> > +  protected void doGet(HttpServletRequest servletRequest,
> > +      HttpServletResponse servletResponse)
> > +      throws ServletException, IOException {
> > +    try {
> > +      JSONObject request =
> > JsonConversionUtils.fromRequest(servletRequest);
> > +      SecurityToken token = getSecurityToken(servletRequest);
> > +      dispatch(request, servletResponse, token);
> > +    } catch (JSONException je) {
> > +      // FIXME
> > +    }
> > +  }
> > +
> > +  protected void doPost(HttpServletRequest servletRequest,
> > +      HttpServletResponse servletResponse)
> > +      throws ServletException, IOException {
> > +    SecurityToken token = getSecurityToken(servletRequest);
> > +    try {
> > +      String content = IOUtils.toString(servletRequest.getReader());
> > +      if ((content.indexOf('[') != -1) && content.indexOf('[') <
> > content.indexOf('{')) {
> > +        //Is a batch
> > +        JSONArray batch = new JSONArray(content);
> > +        dispatchBatch(batch, servletResponse, token);
> > +      } else {
> > +        JSONObject request = new JSONObject(content);
> > +        dispatch(request, servletResponse, token);
> > +      }
> > +    } catch (JSONException je) {
> > +      sendBadRequest(je, servletResponse);
> > +    }
> > +
> > +  }
> > +
> > +  private void dispatchBatch(JSONArray batch, HttpServletResponse
> > servletResponse,
> > +      SecurityToken token) throws JSONException, IOException {
> > +    // Use linked hash map to preserve order
> > +    List<Future<? extends ResponseItem>> responses =
> > Lists.newArrayListWithExpectedSize(batch.length());
> > +
> > +    // Gather all Futures.  We do this up front so that
> > +    // the first call to get() comes after all futures are created,
> > +    // which allows for implementations that batch multiple Futures
> > +    // into single requests.
> > +    for (int i = 0; i < batch.length(); i++) {
> > +      JSONObject batchObj = batch.getJSONObject(i);
> > +      RpcRequestItem requestItem = new RpcRequestItem(batchObj, token,
> > jsonConverter);
> > +      responses.add(handleRequestItem(requestItem));
> > +    }
> > +
> > +    // Resolve each Future into a response.
> > +    // TODO: should use shared deadline across each request
> > +    JSONArray result = new JSONArray();
> > +    for (int i = 0; i < batch.length(); i++) {
> > +      JSONObject batchObj = batch.getJSONObject(i);
> > +      String key = null;
> > +      if (batchObj.has("id")) {
> > +        key = batchObj.getString("id");
> > +      }
> > +      result.put(getJSONResponse(key,
> getResponseItem(responses.get(i))));
> > +    }
> > +    servletResponse.getWriter().write(result.toString());
> > +  }
> > +
> > +  private void dispatch(JSONObject request, HttpServletResponse
> > servletResponse,
> > +      SecurityToken token) throws JSONException, IOException {
> > +    String key = null;
> > +    if (request.has("id")) {
> > +      key = request.getString("id");
> > +    }
> > +    RpcRequestItem requestItem = new RpcRequestItem(request, token,
> > jsonConverter);
> > +
> > +    // Resolve each Future into a response.
> > +    // TODO: should use shared deadline across each request
> > +    ResponseItem response =
> > getResponseItem(handleRequestItem(requestItem));
> > +    JSONObject result = getJSONResponse(key, response);
> > +    servletResponse.getWriter().write(result.toString());
> > +  }
> > +
> > +  private JSONObject getJSONResponse(String key, ResponseItem response)
> > throws JSONException {
> > +    JSONObject result = new JSONObject();
> > +    if (key != null) {
> > +      result.put("id", key);
> > +    }
> > +    if (response.getError() != null) {
> > +      JSONObject error = new JSONObject();
> > +      error.put("code", response.getError().getHttpErrorCode());
> > +      error.put("message", response.getErrorMessage());
> > +      result.put("error", error);
> > +    } else {
> > +      if (response.getResponse() instanceof RestfulCollection) {
> > +        //FIXME this is a little hacky because of the field names in the
> > DataCollection
> > +        JSONObject coll = (JSONObject)
> > jsonConverter.convertToJson(response.getResponse());
> > +        coll.put("list", coll.remove("entry"));
> > +        result.put("data", coll);
> > +      } else if (response.getResponse() instanceof DataCollection) {
> > +        //FIXME this is a little hacky because of the field names in the
> > DataCollection
> > +        JSONObject coll = (JSONObject)
> > jsonConverter.convertToJson(response.getResponse());
> > +        result.put("data", coll.get("entry"));
> > +      } else {
> > +        result.put("data",
> > jsonConverter.convertToJson(response.getResponse()));
> > +      }
> > +    }
> > +    return result;
> > +  }
> > +
> > +  private void sendBadRequest(Throwable t, HttpServletResponse response)
> > throws IOException {
> > +    try {
> > +      JSONObject error = new JSONObject();
> > +      error.put("code", ResponseError.BAD_REQUEST.getHttpErrorCode());
> > +      error.put("message", "Invalid batch - " + t.getMessage());
> > +      response.getWriter().write(error.toString());
> > +    } catch (JSONException je) {
> > +      // This really shouldnt ever happen
> > +      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
> > +          "Error generating error response " + je.getMessage());
> > +    }
> > +  }
> > +
> > +}
> >
> > Modified:
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java?rev=687235&r1=687234&r2=687235&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java
> > (original)
> > +++
> >
> incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/service/PersonHandler.java
> > Tue Aug 19 21:14:39 2008
> > @@ -33,7 +33,7 @@
> >
> >  public class PersonHandler extends DataRequestHandler {
> >
> > -  private PersonService personService;
> > +  private final PersonService personService;
> >
> >   private static final String PEOPLE_PATH =
> > "/people/{userId}+/{groupId}/{personId}+";
> >
> > @@ -60,7 +60,7 @@
> >    * examples: /people/john.doe/@all /people/john.doe/@friends
> > /people/john.doe/@self
> >    */
> >   protected Future<? extends ResponseItem> handleGet(RequestItem request)
> {
> > -    request.parseUrlWithTemplate(PEOPLE_PATH);
> > +    request.applyUrlTemplate(PEOPLE_PATH);
> >
> >     GroupId groupId = request.getGroup();
> >     Set<String> optionalPersonId =
> > Sets.newLinkedHashSet(request.getListParameter("personId"));
> >
> >
> >
>