You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by hs...@apache.org on 2010/09/23 22:22:38 UTC
svn commit: r1000605 - in /shindig/trunk/features: ./
src/main/javascript/features/opensocial-base/
src/main/javascript/features/opensocial-jsonrpc/
src/main/javascript/features/opensocial-reference/
src/test/javascript/features/ src/test/javascript/fe...
Author: hsaputra
Date: Thu Sep 23 20:22:38 2010
New Revision: 1000605
URL: http://svn.apache.org/viewvc?rev=1000605&view=rev
Log:
SHINDIG-1429 | Patch from Jakub Bialek | Incomplite album and mediaitem support in JS
Codreview: http://codereview.appspot.com/2265043/
Modified albums.post and mediaItems.post to albums.create and mediaItems.create agreement with Jakub.
Thank you so much for the patch.
Added:
shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonalbum.js
shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonmediaitem.js
shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonalbumtest.js
shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonmediaitemtest.js
Modified:
shindig/trunk/features/pom.xml
shindig/trunk/features/src/main/javascript/features/opensocial-base/feature.xml
shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonactivity.js
shindig/trunk/features/src/main/javascript/features/opensocial-jsonrpc/jsonrpccontainer.js
shindig/trunk/features/src/main/javascript/features/opensocial-reference/album.js
shindig/trunk/features/src/main/javascript/features/opensocial-reference/container.js
shindig/trunk/features/src/main/javascript/features/opensocial-reference/datarequest.js
shindig/trunk/features/src/main/javascript/features/opensocial-reference/mediaitem.js
shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js
shindig/trunk/features/src/test/javascript/features/alltests.js
shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonactivitytest.js
Modified: shindig/trunk/features/pom.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/pom.xml?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/pom.xml (original)
+++ shindig/trunk/features/pom.xml Thu Sep 23 20:22:38 2010
@@ -131,6 +131,7 @@
<source>opensocial-reference/opensocial.js</source>
<source>opensocial-reference/activity.js</source>
<source>opensocial-reference/address.js</source>
+ <source>opensocial-reference/album.js</source>
<source>opensocial-reference/bodytype.js</source>
<source>opensocial-reference/collection.js</source>
<source>opensocial-reference/container.js</source>
@@ -151,6 +152,8 @@
<source>opensocial-reference/url.js</source>
<source>opensocial-base/fieldtranslations.js</source>
<source>opensocial-base/jsonactivity.js</source>
+ <source>opensocial-base/jsonalbum.js</source>
+ <source>opensocial-base/jsonmediaitem.js</source>
<source>opensocial-base/jsonperson.js</source>
<source>opensocial-jsonrpc/jsonrpccontainer.js</source>
<source>osapi/osapi.js</source>
Modified: shindig/trunk/features/src/main/javascript/features/opensocial-base/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-base/feature.xml?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-base/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-base/feature.xml Thu Sep 23 20:22:38 2010
@@ -22,6 +22,8 @@
<dependency>opensocial-reference</dependency>
<gadget>
<script src="fieldtranslations.js"></script>
+ <script src="jsonmediaitem.js"></script>
+ <script src="jsonalbum.js"></script>
<script src="jsonactivity.js"></script>
<script src="jsonperson.js"></script>
<script src="jsonmessagecollection.js"></script>
Modified: shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonactivity.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonactivity.js?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonactivity.js (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonactivity.js Thu Sep 23 20:22:38 2010
@@ -47,19 +47,6 @@ JsonActivity.prototype.toJsonObject = fu
return jsonObject;
};
-
-// TODO: Split into separate class
-var JsonMediaItem = function(opt_params) {
- opensocial.MediaItem.call(this, opt_params['mimeType'],
- opt_params['url'], opt_params);
-};
-JsonMediaItem.inherits(opensocial.MediaItem);
-
-JsonMediaItem.prototype.toJsonObject = function() {
- return JsonActivity.copyFields(this.fields_);
-};
-
-
// TODO: Pull this method into a common class, it is from jsonperson.js
JsonActivity.constructArrayObject = function(map, fieldName, className) {
var fieldValue = map[fieldName];
Added: shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonalbum.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonalbum.js?rev=1000605&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonalbum.js (added)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonalbum.js Thu Sep 23 20:22:38 2010
@@ -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.
+ */
+
+var JsonAlbum = function(opt_params) {
+ opt_params = opt_params || {};
+
+ JsonAlbum.constructObject(opt_params, "location", opensocial.Address);
+
+ opensocial.Album.call(this, opt_params);
+};
+JsonAlbum.inherits(opensocial.Album);
+
+JsonAlbum.prototype.toJsonObject = function() {
+ return JsonAlbum.copyFields(this.fields_);
+};
+
+// Converts the fieldName into an instance of the specified object
+JsonAlbum.constructObject = function(map, fieldName, className) {
+ var fieldValue = map[fieldName];
+ if (fieldValue) {
+ map[fieldName] = new className(fieldValue);
+ }
+};
+
+//TODO: Pull into common class as well
+JsonAlbum.copyFields = function(oldObject) {
+ var newObject = {};
+ for (var field in oldObject) {
+ newObject[field] = oldObject[field];
+ }
+ return newObject;
+};
Added: shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonmediaitem.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonmediaitem.js?rev=1000605&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonmediaitem.js (added)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-base/jsonmediaitem.js Thu Sep 23 20:22:38 2010
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+var JsonMediaItem = function(opt_params) {
+ opt_params = opt_params || {};
+
+ opensocial.MediaItem.call(this, opt_params["mimeType"], opt_params["url"], opt_params);
+};
+
+JsonMediaItem.inherits(opensocial.MediaItem);
+
+JsonMediaItem.prototype.toJsonObject = function() {
+ return JsonMediaItem.copyFields(this.fields_);
+};
+
+//TODO: Pull into common class as well
+JsonMediaItem.copyFields = function(oldObject) {
+ var newObject = {};
+ for (var field in oldObject) {
+ newObject[field] = oldObject[field];
+ }
+ return newObject;
+};
Modified: shindig/trunk/features/src/main/javascript/features/opensocial-jsonrpc/jsonrpccontainer.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-jsonrpc/jsonrpccontainer.js?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-jsonrpc/jsonrpccontainer.js (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-jsonrpc/jsonrpccontainer.js Thu Sep 23 20:22:38 2010
@@ -421,7 +421,11 @@ var JsonRpcRequestItem = function(rpc, o
JsonRpcContainer.prototype.newActivity = function(opt_params) {
return new JsonActivity(opt_params, true);
};
-
+
+ JsonRpcContainer.prototype.newAlbum = function(opt_params) {
+ return new JsonAlbum(opt_params);
+ };
+
JsonRpcContainer.prototype.newMediaItem = function(mimeType, url, opt_params) {
opt_params = opt_params || {};
opt_params['mimeType'] = mimeType;
@@ -502,3 +506,65 @@ JsonRpcContainer.prototype.newFetchMessa
return new opensocial.Collection(messages);
});
};
+
+JsonRpcContainer.prototype.newCreateAlbumRequest = function(idSpec, album) {
+ var rpc = { method : "albums.create" };
+ rpc.params = this.translateIdSpec(idSpec);
+ rpc.params.appId = "@app";
+ rpc.params.album = album.toJsonObject();
+
+ return new JsonRpcRequestItem(rpc);
+};
+
+JsonRpcContainer.prototype.newDeleteAlbumRequest = function(idSpec, albumId) {
+ var rpc = { method : "albums.delete" };
+ rpc.params = this.translateIdSpec(idSpec);
+ rpc.params.appId = "@app";
+ rpc.params.albumId = albumId;
+
+ return new JsonRpcRequestItem(rpc);
+};
+
+JsonRpcContainer.prototype.newFetchAlbumsRequest = function(idSpec, opt_params) {
+ var rpc = { method : "albums.get" };
+ rpc.params = this.translateIdSpec(idSpec);
+ rpc.params.appId = "@app";
+
+ return new JsonRpcRequestItem(rpc, function(rawJson) {
+ rawJson = rawJson['list'];
+ var albums = [];
+ for ( var i = 0; i < rawJson.length; i++) {
+ albums.push(new JsonAlbum(rawJson[i]));
+ }
+
+ return new opensocial.Collection(albums);
+ });
+};
+
+JsonRpcContainer.prototype.newCreateMediaItemRequest = function(idSpec, albumId, mediaItem) {
+ var rpc = { method : "mediaItems.create" };
+ rpc.params = this.translateIdSpec(idSpec);
+ rpc.params.appId = "@app";
+ rpc.params.albumId = albumId;
+ rpc.params.mediaItem = mediaItem.toJsonObject();
+
+ return new JsonRpcRequestItem(rpc);
+};
+
+JsonRpcContainer.prototype.newFetchMediaItemsRequest = function(idSpec, albumId, opt_params) {
+ var rpc = { method : "mediaItems.get" };
+ rpc.params = this.translateIdSpec(idSpec);
+ rpc.params.appId = "@app";
+ rpc.params.albumId = albumId;
+
+ return new JsonRpcRequestItem(rpc, function(rawJson) {
+ rawJson = rawJson['list'];
+ var mediaItems = [];
+ for ( var i = 0; i < rawJson.length; i++) {
+ mediaItems.push(new JsonMediaItem(rawJson[i]));
+ }
+
+ return new opensocial.Collection(mediaItems);
+ });
+
+};
Modified: shindig/trunk/features/src/main/javascript/features/opensocial-reference/album.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-reference/album.js?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-reference/album.js (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-reference/album.js Thu Sep 23 20:22:38 2010
@@ -74,28 +74,31 @@ opensocial.Album.Field = {
*/
LOCATION: 'location',
- /*
+ /**
* The number of items in the album.
*
* @member opensocial.Album.Field
*/
- MEDIA_ITEM_COUNT: 'mediaITemCount',
+ MEDIA_ITEM_COUNT : 'mediaItemCount',
+
- /*
+ /**
* The types of MediaItems in the Album.
*
* @member opensocial.Album.Field
*/
- MEDIA_MIME_TYPE: 'MEDIA_MIME_TYPE',
+ MEDIA_MIME_TYPE : 'mediaMimeType',
+
- /*
+ /**
* The types of MediaItems in the album.
*
* @member opensocial.Album.Field
*/
- MEDIA_TYPE: 'MEDIA_TYPE',
+ MEDIA_TYPE : 'mediaType',
+
- /*
+ /**
* The string ID of the owner of the album.
*
* @member opensocial.Album.Field
Modified: shindig/trunk/features/src/main/javascript/features/opensocial-reference/container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-reference/container.js?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-reference/container.js (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-reference/container.js Thu Sep 23 20:22:38 2010
@@ -339,10 +339,10 @@ opensocial.Container.prototype.newRemove
* @param {opensocial.IdSpec} idSpec An IdSpec used to specify which people/groups
* to own the album.
* @param {string} albumId The ID of album to update.
- * @param {Object.<opensocial.Album.Field, Object>=} opt_params The album fields to update.
+ * @param {Object.<opensocial.Album.Field, Object>=} fields The album fields to update.
* @return {Object} A request object.
*/
-opensocial.Container.prototype.newUpdateAlbumRequest = function(idSpec, albumId, opt_params) {};
+opensocial.Container.prototype.newUpdateAlbumRequest = function(idSpec, albumId, fields) {};
/**
* Updates the fields for a media item specified in the params.
@@ -352,11 +352,11 @@ opensocial.Container.prototype.newUpdate
* own the album/media item.
* @param {string} albumId The ID of the album containing the media item to update.
* @param {string} mediaItemId ID of media item to update.
- * @param {Object.<opensocial.MediaItem.Field, Object>=} opt_params The media item fields to update.
+ * @param {Object.<opensocial.MediaItem.Field, Object>=} fields The media item fields to update.
* @return {Object} A request object.
*/
opensocial.Container.prototype.newUpdateMediaItemRequest = function(idSpec, albumId,
- mediaItemId, opt_params) {};
+ mediaItemId, fields) {};
/**
* Used to request an activity stream from the server.
@@ -375,6 +375,19 @@ opensocial.Container.prototype.newFetchA
opensocial.Container.prototype.newFetchAlbumsRequest = function(idSpec, opt_params) {};
+/**
+ * Creates an item to request media items from the container.
+ *
+ * @param {opensocial.IdSpec}
+ * idSpec An IdSpec used to specify which media items to fetch.
+ * @param {string}
+ * albumId The id of the album to fetch MediaItems from.
+ * @param {Object.
+ * <Object, Object>=} opt_params Additional parameters to pass to the request.
+ * @return {Object} A request object
+ */
+opensocial.Container.prototype.newFetchMediaItemsRequest = function(idSpec, opt_params) {};
+
opensocial.Container.prototype.newFetchMessageCollectionsRequest = function(idSpec, opt_params) {};
opensocial.Container.prototype.newFetchMessagesRequest = function(idSpec, msgCollId, opt_params) {};
Modified: shindig/trunk/features/src/main/javascript/features/opensocial-reference/datarequest.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-reference/datarequest.js?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-reference/datarequest.js (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-reference/datarequest.js Thu Sep 23 20:22:38 2010
@@ -441,6 +441,30 @@ opensocial.DataRequest.AlbumRequestField
/**
* @static
* @class
+ * @name opensocial.DataRequest.MediaItemRequestFields
+ * @enum {string}
+ */
+opensocial.DataRequest.MediaItemRequestFields = {
+ /**
+ * When paginating, the index of the first item to fetch.
+ * Specified as a <code>Number</code>.
+ *
+ * @member opensocial.DataRequest.MediaItemRequestFields
+ */
+ FIRST : 'first',
+
+ /**
+ * The maximum number of items to fetch; defaults to 20.
+ * Specified as a <code>Number</code>.
+ *
+ * @member opensocial.DataRequest.MediaItemRequestFields
+ */
+ MAX : 'max'
+};
+
+/**
+ * @static
+ * @class
* @name opensocial.DataRequest.DataRequestFields
* @enum {string}
*/
@@ -618,16 +642,44 @@ opensocial.DataRequest.prototype.newFetc
/**
* Creates an item to request albums from the container.
*
- * @param {opensocial.IdSpec} idSpec An IdSpec used to specify which albms to fetch.
+ * @param {opensocial.IdSpec} idSpec An IdSpec used to specify which albums to fetch.
* @param {Object.<Object, Object>=} opt_params Additional parameters to pass to the request.
* @return {Object} A request object.
*/
opensocial.DataRequest.prototype.newFetchAlbumsRequest = function(idSpec, opt_params) {
opt_params = opt_params || {};
+
+ var fields = opensocial.DataRequest.AlbumRequestFields;
+
+ this.addDefaultParam(opt_params, fields.FIRST, 0);
+ this.addDefaultParam(opt_params, fields.MAX, 20);
+
return opensocial.Container.get().newFetchAlbumsRequest(idSpec, opt_params);
};
/**
+ * Creates an item to request media items from the container.
+ *
+ * @param {opensocial.IdSpec}
+ * idSpec An IdSpec used to specify which media items to fetch.
+ * @param {string}
+ * albumId The id of the album to fetch media items from.
+ * @param {Object.
+ * <Object, Object>=} opt_params Additional parameters to pass to the request.
+ * @return {Object} A request object
+ */
+opensocial.DataRequest.prototype.newFetchMediaItemsRequest = function(idSpec, albumId, opt_params) {
+ opt_params = opt_params || {};
+
+ var fields = opensocial.DataRequest.MediaItemRequestFields;
+
+ this.addDefaultParam(opt_params, fields.FIRST, 0);
+ this.addDefaultParam(opt_params, fields.MAX, 20);
+
+ return opensocial.Container.get().newFetchMediaItemsRequest(idSpec, albumId, opt_params);
+};
+
+/**
* Creates an item to request messages from the container.
*/
opensocial.DataRequest.prototype.newFetchMessageCollectionsRequest = function(idSpec, opt_params) {
Modified: shindig/trunk/features/src/main/javascript/features/opensocial-reference/mediaitem.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-reference/mediaitem.js?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-reference/mediaitem.js (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-reference/mediaitem.js Thu Sep 23 20:22:38 2010
@@ -93,19 +93,129 @@ opensocial.MediaItem.Type = {
* @name opensocial.MediaItem.Field
*/
opensocial.MediaItem.Field = {
+
/**
- * The type of media, specified as a
- * <a href="opensocial.MediaItem.Type.html">
- * <code>MediaItem.Type</code></a> object.
+ * The album to which the media item belongs, specified as a String.
+ * @member opensocial.MediaItem.Field
+ */
+ ALBUM_ID : 'albumId',
+
+ /**
+ * The creation time associated with the media item - assigned by container in UTC, specified as a String.
+ * @member opensocial.MediaItem.Field
+ */
+ CREATED : 'created',
+
+ /**
+ * The description of the media item, specified as a String.
+ *
* @member opensocial.MediaItem.Field
*/
- TYPE: 'type',
+ DESCRIPTION : 'description',
+
+ /**
+ * An integer specified for audio/video clips - playtime length in seconds, set to -1/not defined if unknown.
+ * @member opensocial.MediaItem.Field
+ */
+ DURATION : 'duration',
+
+ /**
+ * A long specified the number of bytes (set to -1/undefined if unknown).
+ * @member opensocial.MediaItem.Field
+ */
+ FILE_SIZE : 'fileSize',
+
+ /**
+ * An id associated with the media item, specified as a String.
+ * @member opensocial.MediaItem.Field
+ */
+ ID : 'id',
+
+ /**
+ * A language associated with the media item in ISO 639-3 format, specified as a String.
+ * @member opensocial.MediaItem.Field
+ */
+ LANGUAGE : 'language',
/**
+ * An update time associated with the media item - assigned by container in UTC, specified as a String.
+ * @member opensocial.MediaItem.Field
+ */
+ LAST_UPDATED : 'lastUpdated',
+
+ /**
+ * A location corresponding to the media item, specified as a <a href="opensocial.MediaItem.html"> object.
+ * @member opensocial.MediaItem.Field
+ */
+ LOCATION : 'location',
+
+ /**
* The MIME type of media, specified as a String.
* @member opensocial.MediaItem.Field
*/
MIME_TYPE: 'mimeType',
+
+ /**
+ * A number of comments on the photo, specified as a integer.
+ * @member opensocial.MediaItem.Field
+ */
+ NUM_COMMENTS : 'numComments',
+
+ /**
+ * A number of views for the media item, specified as a integer.
+ * @member opensocial.MediaItem.Field
+ */
+ NUM_VIEWS : 'numViews',
+
+ /**
+ * A number of votes received for voting, specified as a integer.
+ * @member opensocial.MediaItem.Field
+ */
+ NUM_VOTES : 'numVotes',
+
+ /**
+ * An average rating of the media item on a scale of 0-10, specified as a integer.
+ * @member opensocial.MediaItem.Field
+ */
+ RATING : 'rating',
+
+ /**
+ * A string specified for streaming/live content - time when the content is available.
+ * @member opensocial.MediaItem.Field
+ */
+ START_TIME : 'startTime',
+
+ /**
+ * An array of string (IDs) of people tagged in the media item, specified as an array of Strings.
+ * @member opensocial.MediaItem.Field
+ */
+ TAGGED_PEOPLE : 'taggedPeople',
+
+ /**
+ * Tags associated with this media item, specified as an array of Strings.
+ * @member opensocial.MediaItem.Field
+ */
+ TAGS : 'tags',
+
+ /**
+ * URL to a thumbnail image of the media item, specified as a String.
+ * @member opensocial.MediaItem.Field
+ */
+ THUMBNAIL_URL : 'thumbnailUrl',
+
+ /**
+ * A string describing the media item, specified as a String.
+ * @member opensocial.MediaItem.Field
+ */
+ TITLE : 'title',
+
+ /**
+ * The type of media, specified as a
+ * <a href="opensocial.MediaItem.Type.html">
+ * <code>MediaItem.Type</code></a> object.
+ * @member opensocial.MediaItem.Field
+ */
+ TYPE : 'type',
/**
* A string specifying the URL where the media can be found.
Modified: shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js Thu Sep 23 20:22:38 2010
@@ -96,6 +96,7 @@ tamings___.push(function(imports) {
[opensocial.Activity, 'setField'],
[opensocial.Address, 'getField'],
[opensocial.Album, 'getField'],
+ [opensocial.Album, 'setField'],
[opensocial.BodyType, 'getField'],
[opensocial.Container, 'getEnvironment'],
[opensocial.Container, 'requestSendMessage'],
@@ -116,11 +117,13 @@ tamings___.push(function(imports) {
[opensocial.Container, 'newUpdateMediaItemRequest'],
[opensocial.Container, 'newFetchActivitiesRequest'],
[opensocial.Container, 'newFetchAlbumsRequest'],
+ [opensocial.Container, 'newFetchMediaItemsRequest'],
[opensocial.Container, 'newFetchMessageCollectionsRequest'],
[opensocial.Container, 'newFetchMessagesRequest'],
[opensocial.Container, 'newCollection'],
[opensocial.Container, 'newPerson'],
[opensocial.Container, 'newActivity'],
+ [opensocial.Container, 'newAlbum'],
[opensocial.Container, 'newMediaItem'],
[opensocial.Container, 'newMessage'],
[opensocial.Container, 'newIdSpec'],
@@ -142,6 +145,7 @@ tamings___.push(function(imports) {
[opensocial.DataRequest, 'newDeleteAlbumRequest'],
[opensocial.DataRequest, 'newFetchActivitiesRequest'],
[opensocial.DataRequest, 'newFetchAlbumsRequest'],
+ [opensocial.DataRequest, 'newFetchMediaItemsRequest'],
[opensocial.DataRequest, 'newFetchPeopleRequest'],
[opensocial.DataRequest, 'newFetchPersonAppDataRequest'],
[opensocial.DataRequest, 'newUpdateAlbumRequest'],
@@ -188,6 +192,7 @@ tamings___.push(function(imports) {
[opensocial, 'getEnvironment'],
[opensocial, 'hasPermission'],
[opensocial, 'newActivity'],
+ [opensocial, 'newAlbum'],
[opensocial, 'newDataRequest'],
[opensocial, 'newIdSpec'],
[opensocial, 'newMediaItem'],
Modified: shindig/trunk/features/src/test/javascript/features/alltests.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/alltests.js?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/alltests.js (original)
+++ shindig/trunk/features/src/test/javascript/features/alltests.js Thu Sep 23 20:22:38 2010
@@ -46,6 +46,7 @@ if (!this.JsUtil) {
eval(JsUtil.prototype.include(srcDir + '/xhrwrapper/xhrwrapper.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/opensocial.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/activity.js'));
+ eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/album.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/address.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/bodytype.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/collection.js'));
@@ -66,6 +67,8 @@ if (!this.JsUtil) {
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/responseitem.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-reference/url.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-base/jsonactivity.js'));
+ eval(JsUtil.prototype.include(srcDir + '/opensocial-base/jsonalbum.js'));
+ eval(JsUtil.prototype.include(srcDir + '/opensocial-base/jsonmediaitem.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-base/jsonperson.js'));
eval(JsUtil.prototype.include(srcDir + '/opensocial-jsonrpc/jsonrpccontainer.js'));
eval(JsUtil.prototype.include(srcDir + '/osapi/osapi.js'));
@@ -80,6 +83,8 @@ if (!this.JsUtil) {
eval(JsUtil.prototype.include(testSrcDir + "/core/prefstest.js"));
eval(JsUtil.prototype.include(testSrcDir + "/core.io/iotest.js"));
eval(JsUtil.prototype.include(testSrcDir + "/opensocial-base/jsonactivitytest.js"));
+ eval(JsUtil.prototype.include(testSrcDir + "/opensocial-base/jsonalbumtest.js"));
+ eval(JsUtil.prototype.include(testSrcDir + "/opensocial-base/jsonmediaitemtest.js"));
eval(JsUtil.prototype.include(testSrcDir + "/opensocial-reference/activitytest.js"));
eval(JsUtil.prototype.include(testSrcDir + "/opensocial-templates/compiler_test.js"));
eval(JsUtil.prototype.include(testSrcDir + "/opensocial-templates/container_test.js"));
Modified: shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonactivitytest.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonactivitytest.js?rev=1000605&r1=1000604&r2=1000605&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonactivitytest.js (original)
+++ shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonactivitytest.js Thu Sep 23 20:22:38 2010
@@ -68,14 +68,4 @@ JsonActivityTest.prototype.testJsonActiv
this.assertEquals('black', mediaItems[0].getField(mediaItemFields.MIME_TYPE));
this.assertEquals('white', mediaItems[0].getField(mediaItemFields.URL));
this.assertEquals('orange', mediaItems[0].getField(mediaItemFields.TYPE));
-};
-
-JsonActivityTest.prototype.testJsonMediaItemConstructor = function() {
- var mediaItem = new JsonMediaItem({'mimeType' : 'black', 'url' : 'white',
- 'type' : 'orange'});
-
- var fields = opensocial.MediaItem.Field;
- this.assertEquals('black', mediaItem.getField(fields.MIME_TYPE));
- this.assertEquals('white', mediaItem.getField(fields.URL));
- this.assertEquals('orange', mediaItem.getField(fields.TYPE));
};
\ No newline at end of file
Added: shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonalbumtest.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonalbumtest.js?rev=1000605&view=auto
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonalbumtest.js (added)
+++ shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonalbumtest.js Thu Sep 23 20:22:38 2010
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+var gadgets = gadgets || {};
+
+function JsonAlbumTest(name) {
+ TestCase.call(this, name);
+};
+JsonAlbumTest.inherits(TestCase);
+
+JsonAlbumTest.prototype.setUp = function() {
+ // Prepare for mocks
+ this.oldGetField = opensocial.Container.getField;
+ opensocial.Container.getField = function(fields, key, opt_params) {
+ return fields[key];
+ };
+};
+
+JsonAlbumTest.prototype.tearDown = function() {
+ // Remove mocks
+ opensocial.Container.getField = this.oldGetField;
+};
+
+JsonAlbumTest.prototype.testJsonAlbumConstructor = function() {
+ var album = new JsonAlbum( {
+ 'id' : 1,
+ 'ownerId' : 2,
+ 'title' : 'test-title',
+ 'description' : 'test-description',
+ 'location' : {'locality' : 'test-locality', 'country' : 'test-country'},
+ 'mediaItemCount' : 3,
+ 'mediaMimeType' : [ 'jpg' ],
+ 'mediaType' : 'image',
+ 'thumbnailUrl' : 'test-thumbnailUrl'
+ });
+
+ var fields = opensocial.Album.Field;
+ this.assertEquals(1, album.getField(fields.ID));
+ this.assertEquals(2, album.getField(fields.OWNER_ID));
+ this.assertEquals(3, album.getField(fields.MEDIA_ITEM_COUNT));
+ this.assertEquals('test-title', album.getField(fields.TITLE));
+ this.assertEquals('test-description', album.getField(fields.DESCRIPTION));
+
+ var location = album.getField(fields.LOCATION);
+ this.assertTrue(location instanceof opensocial.Address);
+ this.assertEquals('test-locality', location.getField(opensocial.Address.Field.LOCALITY));
+ this.assertEquals('test-country', location.getField(opensocial.Address.Field.COUNTRY));
+
+ var mimeTypes = album.getField(fields.MEDIA_MIME_TYPE);
+ this.assertTrue(mimeTypes instanceof Array);
+ this.assertEquals('jpg', mimeTypes[0]);
+
+ this.assertEquals(opensocial.MediaItem.Type.IMAGE, album.getField(fields.MEDIA_TYPE));
+ this.assertEquals('test-thumbnailUrl', album.getField(fields.THUMBNAIL_URL));
+};
\ No newline at end of file
Added: shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonmediaitemtest.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonmediaitemtest.js?rev=1000605&view=auto
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonmediaitemtest.js (added)
+++ shindig/trunk/features/src/test/javascript/features/opensocial-base/jsonmediaitemtest.js Thu Sep 23 20:22:38 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+var gadgets = gadgets || {};
+
+function JsonMediaItemTest(name) {
+ TestCase.call(this, name);
+};
+JsonMediaItemTest.inherits(TestCase);
+
+JsonMediaItemTest.prototype.setUp = function() {
+ // Prepare for mocks
+ this.oldGetField = opensocial.Container.getField;
+ opensocial.Container.getField = function(fields, key, opt_params) {
+ return fields[key];
+ };
+};
+
+JsonMediaItemTest.prototype.tearDown = function() {
+ // Remove mocks
+ opensocial.Container.getField = this.oldGetField;
+};
+
+JsonMediaItemTest.prototype.testJsonMediaItemConstructor = function() {
+ var mediaItem = new JsonMediaItem({'mimeType' : 'black', 'url' : 'white',
+ 'type' : 'orange'});
+
+ var fields = opensocial.MediaItem.Field;
+ this.assertEquals('black', mediaItem.getField(fields.MIME_TYPE));
+ this.assertEquals('white', mediaItem.getField(fields.URL));
+ this.assertEquals('orange', mediaItem.getField(fields.TYPE));
+};
\ No newline at end of file