You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by do...@apache.org on 2008/03/13 17:21:17 UTC
svn commit: r636795 - in /incubator/shindig/trunk/features/opensocial-0.7:
feature.xml jsonactivity.js jsoncontainer.js
Author: doll
Date: Thu Mar 13 09:21:06 2008
New Revision: 636795
URL: http://svn.apache.org/viewvc?rev=636795&view=rev
Log:
Added the javascript changes necessary for supporting fetching and creating of activities.
Added:
incubator/shindig/trunk/features/opensocial-0.7/jsonactivity.js
Modified:
incubator/shindig/trunk/features/opensocial-0.7/feature.xml
incubator/shindig/trunk/features/opensocial-0.7/jsoncontainer.js
Modified: incubator/shindig/trunk/features/opensocial-0.7/feature.xml
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-0.7/feature.xml?rev=636795&r1=636794&r2=636795&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-0.7/feature.xml (original)
+++ incubator/shindig/trunk/features/opensocial-0.7/feature.xml Thu Mar 13 09:21:06 2008
@@ -23,6 +23,7 @@
<dependency>caja</dependency>
<gadget>
<script src="jsonperson.js"></script>
+ <script src="jsonactivity.js"></script>
<script src="jsoncontainer.js"></script>
<script src="batchrequest.js"></script>
<script>
Added: incubator/shindig/trunk/features/opensocial-0.7/jsonactivity.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-0.7/jsonactivity.js?rev=636795&view=auto
==============================================================================
--- incubator/shindig/trunk/features/opensocial-0.7/jsonactivity.js (added)
+++ incubator/shindig/trunk/features/opensocial-0.7/jsonactivity.js Thu Mar 13 09:21:06 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+/**
+ * Base interface for json based person objects.
+ *
+ * @private
+ * @constructor
+ */
+JsonActivity = function(opt_params) {
+ opt_params = opt_params || {};
+
+ JsonActivity.constructArrayObject(opt_params, "mediaItems", JsonMediaItem);
+ opensocial.Activity.call(this, opt_params);
+};
+JsonActivity.inherits(opensocial.Activity);
+
+JsonMediaItem = function(opt_params) {
+ opensocial.Activity.MediaItem.call(this, opt_params['mimeType'],
+ opt_params['url'], opt_params);
+}
+JsonMediaItem.inherits(opensocial.Activity.MediaItem);
+
+// TODO: Pull this method into a common class, it is from jsonperson.js
+JsonActivity.constructArrayObject = function(map, fieldName, className) {
+ var fieldValue = map[fieldName];
+ if (fieldValue) {
+ for (var i = 0; i < fieldValue.length; i++) {
+ fieldValue[i] = new className(fieldValue[i]);
+ }
+ }
+}
Modified: incubator/shindig/trunk/features/opensocial-0.7/jsoncontainer.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-0.7/jsoncontainer.js?rev=636795&r1=636794&r2=636795&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-0.7/jsoncontainer.js (original)
+++ incubator/shindig/trunk/features/opensocial-0.7/jsoncontainer.js Thu Mar 13 09:21:06 2008
@@ -44,6 +44,17 @@
return this.environment_;
};
+JsonContainer.prototype.requestCreateActivity = function(activity,
+ priority, opt_callback) {
+ opt_callback = opt_callback || {};
+
+ var req = opensocial.newDataRequest();
+ req.add(this.newCreateActivityRequest('VIEWER', activity), 'key');
+ req.send(function(response) {
+ opt_callback(response.get('key'));
+ });
+};
+
JsonContainer.prototype.createJson = function(requestObjects) {
var jsonObjects = [];
for (var i = 0; i < requestObjects.length; i++) {
@@ -80,9 +91,10 @@
var response = responses[i];
var rawData = response['response'];
var error = response['error'];
+ var errorMessage = response['errorMessage'];
var processedData = requestObjects[i].request.processResponse(
- requestObjects[i].request, rawData, error);
+ requestObjects[i].request, rawData, error, errorMessage);
globalError = globalError || processedData.hadError();
responseMap[requestObjects[i].key] = processedData;
}
@@ -142,12 +154,18 @@
function(rawJson) {
var activities = [];
for (var i = 0; i < rawJson.length; i++) {
- activities.push(new opensocial.Activity(rawJson[i]));
+ activities.push(new JsonActivity(rawJson[i]));
}
return {'activities' : new opensocial.Collection(activities)};
});
};
+JsonContainer.prototype.newCreateActivityRequest = function(idSpec,
+ activity) {
+ return new RequestItem({'type' : 'CREATE_ACTIVITY', 'idSpec' : idSpec,
+ 'activity' : activity});
+};
+
RequestItem = function(jsonParams, processData) {
this.jsonParams = jsonParams;
this.processData = processData ||
@@ -155,8 +173,9 @@
return rawJson;
};
- this.processResponse = function(originalDataRequest, rawJson, error) {
+ this.processResponse = function(originalDataRequest, rawJson, error,
+ errorMessage) {
return new opensocial.ResponseItem(originalDataRequest,
- this.processData(rawJson), error);
+ this.processData(rawJson), error, errorMessage);
}
};