You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by li...@apache.org on 2010/05/27 02:49:27 UTC

svn commit: r948645 - in /shindig/trunk: features/src/main/javascript/features/opensocial-reference/ java/social-api/src/main/java/org/apache/shindig/social/core/model/ java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/

Author: lindner
Date: Thu May 27 00:49:26 2010
New Revision: 948645

URL: http://svn.apache.org/viewvc?rev=948645&view=rev
Log:
SHINDIG-1343 SHINDIG-1344 | Patches from Henry Saputra | Albums Model + Client

Added:
    shindig/trunk/features/src/main/javascript/features/opensocial-reference/album.js
    shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/AlbumImpl.java
    shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/Album.java
Modified:
    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/feature.xml
    shindig/trunk/features/src/main/javascript/features/opensocial-reference/opensocial.js
    shindig/trunk/features/src/main/javascript/features/opensocial-reference/taming.js

Added: 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=948645&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-reference/album.js (added)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-reference/album.js Thu May 27 00:49:26 2010
@@ -0,0 +1,146 @@
+/*
+ * 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.
+ */
+
+/*global opensocial */
+
+/**
+ * @fileoverview Representation of an album.
+ */
+
+/**
+ * @class
+ * Represents collection of media item images, movies, and audio.
+ * Create a <code>Album</code> object using the <a href="opensocial.html#newAlbum">
+ * opensocial.newAlbum()</a> method.
+ *
+ * @name opensocial.Album
+ */
+
+ /**
+ * Base interface for collection of media items.
+ *
+ * @param {Object.<opensocial.Album.Field, Object>=} opt_params
+ *    Any other fields that should be set on the message object.
+ *    All of the defined Fields are supported.
+ * @private
+ * @constructor
+ */
+opensocial.Album = function(opt_params) {
+  this.fields_ = opt_params || {};
+};
+
+/**
+ * @static
+ * @class
+ * All of the fields that an Album can have.
+ *
+ * @name opensocial.Album.Field
+ */
+opensocial.Album.Field = {
+  /**
+   * A description of the album.
+   *
+   * @member opensocial.Album.Field
+   */
+  DESCRIPTION : 'description',
+    
+  /**
+   * A unique identifier for the album.
+   *
+   * @member opensocial.Album.Field
+   */
+  ID : 'id',
+
+  /**
+   * A location corresponding to the album as opensocial.Address.
+   *
+   * @member opensocial.Album.Field
+   */
+  LOCATION : 'location',
+
+  /*
+   * The number of items in the album.
+   *
+   * @member opensocial.Album.Field
+   */
+  MEDIA_ITEM_COUNT : 'mediaITemCount',
+
+  /*
+   * The types of MediaItems in the Album.
+   *
+   * @member opensocial.Album.Field
+   */
+  MEDIA_MIME_TYPE : 'MEDIA_MIME_TYPE',
+
+  /*
+   * The types of MediaItems in the album.
+   *
+   * @member opensocial.Album.Field
+   */
+  MEDIA_TYPE : 'MEDIA_TYPE',
+
+  /*
+   * The string ID of the owner of the album.
+   *
+   * @member opensocial.Album.Field
+   */
+  OWNER_ID : 'ownerId',
+
+  /**
+   * URL to a thumbnail cover of the album as string.
+   *
+   * @member opensocial.Album.Field
+   */
+  THUMBNAIL_URL : 'thumbnailUrl',
+
+  /**
+   * The title of the album.
+   *
+   * @member opensocial.Album.Field
+   */
+  TITLE : 'title'
+};
+
+/**
+ * Gets the album data that's associated with the specified key.
+ *
+ * @param {string} key The key to get data for;
+ *   see the <a href="opensocial.Album.Field.html">Field</a> class
+ * for possible values
+ * @param {Object.<opensocial.DataRequest.DataRequestFields, Object>}
+ *  opt_params Additional
+ *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
+ *    to pass to the request.
+ * @return {string} The data
+ * @member opensocial.Album
+ */
+opensocial.Album.prototype.getField = function(key, opt_params) {
+  return opensocial.Container.getField(this.fields_, key, opt_params);
+};
+
+
+/**
+ * Sets data for this album associated with the given key.
+ *
+ * @param {string} key The key to set data for
+ * @param {string} data The data to set
+ */
+opensocial.Album.prototype.setField = function(key, data) {
+  return this.fields_[key] = data;
+};

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=948645&r1=948644&r2=948645&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 May 27 00:49:26 2010
@@ -313,6 +313,8 @@ opensocial.Container.prototype.newRemove
 opensocial.Container.prototype.newFetchActivitiesRequest = function(idSpec,
     opt_params) {};
 
+opensocial.Container.prototype.newFetchAlbumsRequest = function(idSpec, opt_params) {};
+
 opensocial.Container.prototype.newFetchMessageCollectionsRequest = function(idSpec, opt_params) {};
 opensocial.Container.prototype.newFetchMessagesRequest = function(idSpec, msgCollId, opt_params) {};
 
@@ -351,6 +353,23 @@ opensocial.Container.prototype.newActivi
   return new opensocial.Activity(opt_params);
 };
 
+/**
+ * Get a collection of images, movies, and audio.
+ * Used when creating albums on the server.
+ *
+ * @param {Object.<opensocial.MediaItem.Field, Object>=} opt_params
+ *    Any other fields that should be set on the album object;
+ *    all of the defined
+ *    <a href="opensocial.Album.Field.html">Field</a>s
+ *    are supported
+ *
+ * @return {opensocial.Album} the album object
+ * @private
+ */
+opensocial.Container.prototype.newAlbum = function(opt_params) {
+  return new opensocial.Album(opt_params);
+};
+
 
 /**
  * Creates a media item. Represents images, movies, and audio.

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=948645&r1=948644&r2=948645&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 May 27 00:49:26 2010
@@ -523,6 +523,18 @@ 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 {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 || {};
+  return opensocial.Container.get().newFetchAlbumsRequest(idSpec, 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/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-reference/feature.xml?rev=948645&r1=948644&r2=948645&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-reference/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-reference/feature.xml Thu May 27 00:49:26 2010
@@ -24,6 +24,7 @@
     <script src="opensocial.js"/>
     <script src="activity.js"/>
     <script src="address.js"/>
+    <script src="album.js"/>
     <script src="bodytype.js"/>
     <script src="collection.js"/>
     <script src="container.js"/>

Modified: shindig/trunk/features/src/main/javascript/features/opensocial-reference/opensocial.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/opensocial-reference/opensocial.js?rev=948645&r1=948644&r2=948645&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/opensocial-reference/opensocial.js (original)
+++ shindig/trunk/features/src/main/javascript/features/opensocial-reference/opensocial.js Thu May 27 00:49:26 2010
@@ -347,6 +347,25 @@ opensocial.newActivity = function(params
   return opensocial.Container.get().newActivity(params);
 };
 
+/**
+ * Creates an album.
+ * Represents a collection of images, movies, and audio.
+ * Used when creating albums on the server.
+ *
+ * @param {Object.<opensocial.MediaItem.Field, Object>=} opt_params
+ *    Any other fields that should be set on the album object;
+ *    all of the defined
+ *    <a href="opensocial.Album.Field.html">Field</a>s
+ *    are supported
+ *
+ * @return {opensocial.Album} The new
+ *    <a href="opensocial.Album.html">album</a> object
+ * @member opensocial
+ */
+opensocial.newAlbum = function(opt_params) {
+  return opensocial.Container.get().newAlbum(opt_params);
+};
+
 
 /**
  * Creates a media item.

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=948645&r1=948644&r2=948645&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 May 27 00:49:26 2010
@@ -27,6 +27,7 @@ tamings___.push(function(imports) {
   ___.grantRead(opensocial, 'EscapeType');
   ___.grantRead(opensocial.Activity, 'Field');
   ___.grantRead(opensocial.Address, 'Field');
+  ___.grantRead(opensocial.Album, 'Field');
   ___.grantRead(opensocial.BodyType, 'Field');
   ___.grantRead(opensocial.DataRequest, 'ActivityRequestFields');
   ___.grantRead(opensocial.DataRequest, 'DataRequestFields');
@@ -69,6 +70,7 @@ tamings___.push(function(imports) {
       [window, 'JsonRpcRequestItem', Object],
       [opensocial, 'Activity', Object],
       [opensocial, 'Address', Object],
+      [opensocial, 'Album', Object],
       [opensocial, 'BodyType', Object],
       [opensocial, 'Container', Object],
       [opensocial, 'Collection', Object],
@@ -93,6 +95,7 @@ tamings___.push(function(imports) {
     [opensocial.Activity, 'getId'],
     [opensocial.Activity, 'setField'],
     [opensocial.Address, 'getField'],
+    [opensocial.Album, 'getField'],
     [opensocial.BodyType, 'getField'],
     [opensocial.Container, 'getEnvironment'],
     [opensocial.Container, 'requestSendMessage'],
@@ -107,6 +110,7 @@ tamings___.push(function(imports) {
     [opensocial.Container, 'newUpdatePersonAppDataRequest'],
     [opensocial.Container, 'newRemovePersonAppDataRequest'],
     [opensocial.Container, 'newFetchActivitiesRequest'],
+    [opensocial.Container, 'newFetchAlbumsRequest'],
     [opensocial.Container, 'newFetchMessageCollectionsRequest'],
     [opensocial.Container, 'newFetchMessagesRequest'],
     [opensocial.Container, 'newCollection'],
@@ -129,6 +133,7 @@ tamings___.push(function(imports) {
     [opensocial.Collection, 'size'],
     [opensocial.DataRequest, 'add'],
     [opensocial.DataRequest, 'newFetchActivitiesRequest'],
+    [opensocial.DataRequest, 'newFetchAlbumsRequest'],
     [opensocial.DataRequest, 'newFetchPeopleRequest'],
     [opensocial.DataRequest, 'newFetchPersonAppDataRequest'],
     [opensocial.DataRequest, 'newFetchPersonRequest'],

Added: shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/AlbumImpl.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/AlbumImpl.java?rev=948645&view=auto
==============================================================================
--- shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/AlbumImpl.java (added)
+++ shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/AlbumImpl.java Thu May 27 00:49:26 2010
@@ -0,0 +1,114 @@
+/*
+ * 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.core.model;
+
+import org.apache.shindig.social.opensocial.model.Address;
+import org.apache.shindig.social.opensocial.model.Album;
+import org.apache.shindig.social.opensocial.model.MediaItem;
+
+import java.util.List;
+
+/**
+ * Default Implementation of the Album object in the model.
+ */
+public class AlbumImpl implements Album {
+  private String description;
+  private String id;
+  private Address location;
+  private Integer mediaItemCount;
+  private List<String> mediaMimeType;
+  private List<MediaItem.Type> mediaType;
+  private String ownerId;
+  private String thumbnailUrl;
+  private String title;
+
+  public AlbumImpl() {  
+  }
+  
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  public String getId() {
+    return id;
+  }
+
+  public void setId(String id) {
+    this.id = id;
+  }
+
+  public Address getLocation() {
+    return location;
+  }
+
+  public void setLocation(Address location) {
+    this.location = location;
+  }
+
+  public Integer getMediaItemCount() {
+    return mediaItemCount;
+  }
+
+  public void setMediaItemCount(Integer mediaItemCount) {
+    this.mediaItemCount = mediaItemCount;
+  }
+
+  public List<String> getMediaMimeType() {
+    return mediaMimeType;
+  }
+
+  public void setMediaMimeType(List<String> mediaMimeType) {
+    this.mediaMimeType = mediaMimeType;
+  }
+
+  public List<MediaItem.Type> getMediaType() {
+    return mediaType;
+  }
+
+  public void setMediaType(List<MediaItem.Type> mediaType) {
+    this.mediaType = mediaType;
+  }
+
+  public String getOwnerId() {
+    return ownerId;
+  }
+
+  public void setOwnerId(String ownerId) {
+    this.ownerId = ownerId;
+  }
+
+  public String getThumbnailUrl() {
+    return thumbnailUrl;
+  }
+
+  public void setThumbnailUrl(String thumbnailUrl) {
+    this.thumbnailUrl = thumbnailUrl;
+  }
+
+  public String getTitle() {
+    return title;
+  }
+
+  public void setTitle(String title) {
+    this.title = title;
+  }
+}

Added: shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/Album.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/Album.java?rev=948645&view=auto
==============================================================================
--- shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/Album.java (added)
+++ shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/Album.java Thu May 27 00:49:26 2010
@@ -0,0 +1,205 @@
+/*
+ * 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.model;
+
+import org.apache.shindig.protocol.model.Exportablebean;
+import org.apache.shindig.social.core.model.AlbumImpl;
+
+import com.google.inject.ImplementedBy;
+
+import java.util.List;
+
+/**
+ * <p>
+ * The Album API describes the collection of MediaItems of images, movies, and audio.
+ * </p> 
+ * <p>
+ * Please see <a href="http://www.opensocial.org/Technical-Resources/opensocial-spec-v09/OpenSocial-Specification.html#opensocial.Album.Field">
+ * http://www.opensocial.org/Technical-Resources/opensocial-spec-v09/OpenSocial-Specification.html#opensocial.Album.Field</a>
+ * for details about the supported fields.
+ * </p>
+ */
+@ImplementedBy(AlbumImpl.class)
+@Exportablebean
+public interface Album {
+
+  /**
+   * The fields that represent the Album object in json form.
+   */
+  public static enum Field {
+    DESCRIPTION("description"),
+    ID("id"),
+    LOCATION("location"),
+    MEDIA_ITEM_COUNT("mediaItemCount"),
+    MEDIA_MIME_TYPE("mediaMimeType"),
+    MEDIA_TYPE("mediaType"),
+    OWNER_ID("ownerId"),
+    THUMBNAIL_URL("thumbnailUrl"),
+    TITLE("title");
+
+    /**
+     * The json field that the instance represents.
+     */
+    private final String jsonString;
+
+    /**
+     * create a field base on the a json element.
+     *
+     * @param jsonString the name of the element
+     */
+    private Field(String jsonString) {
+      this.jsonString = jsonString;
+    }
+
+    /**
+     * emit the field as a json element.
+     *
+     * @return the field name
+     */
+    @Override
+    public String toString() {
+      return this.jsonString;
+    }
+  }
+
+  /**
+   * Get a string specifying the description of this album.
+   *
+   * @return a string specifying the description of this album.
+   */
+  String getDescription();
+
+  /**
+   * Set the description of this album.
+   *
+   * @param description a string specifying the description of this album.
+   */
+  void setDescription(String description);
+
+  /**
+   * Get a string ID specifying the unique identifier of this album.
+   *
+   * @return a string ID specifying the unique identifier of this album.
+   */
+  String getId();
+
+  /**
+   * Set a string ID specifying a unique identifier of this album.
+   *
+   * @param id a string ID specifying the unique identifier of this album.
+   */
+  void setId(String id);
+
+  /**
+   * Get address location of this album.
+   * 
+   * @return an Address specifying the location of this album.
+   */
+  Address getLocation();
+
+  /**
+   * Set the address location of this album.
+   *
+   * @param location an Address specifying the location of this album.
+   */
+  void setLocation(Address location);
+
+  /**
+   * Get the number of items in the album.
+   *
+   * @return an integer specifying the number of items in the album
+   */
+  Integer getMediaItemCount();
+
+  /**
+   * Set the number of items in the album.
+   *
+   * @param mediaItemCount an integer specifying the number of items in the album.
+   */
+  void setMediaItemCount(Integer mediaItemCount);
+
+  /**
+   * Get the identifying mime-types of the items in the album.
+   *
+   * @return a List of strings specifying the mime-types of the items in the album.
+   */
+  List<String> getMediaMimeType();
+
+  /**
+   * Set the identifying mime-types of the items in the album.
+   *
+   * @param mediaMimeType a List of strings specifying the mime-types of the items in the album.
+   */
+  void setMediaMimeType(List<String> mediaMimeType);
+
+  /**
+   * Get the list of media item types for the items in the album.
+   *
+   * @return a List of MediaItem.Type specifying the media item types for items in the album.
+   */
+  List<MediaItem.Type> getMediaType();
+
+  /**
+   * Set the list of media item types for the items in the album.
+   *
+   * @param mediaType List of MediaItem.Type specifying media item types for items in the album.
+   */
+  void setMediaType(List<MediaItem.Type> mediaType);
+
+  /**
+   * Get the ID of the owner of the album.
+   *
+   * @return a string identifying the ID of the owner of the album.
+   */
+  String getOwnerId();
+
+  /**
+   * Set the string ID of the owner of the album.
+   *
+   * @param ownerId a string ID that identify the owner of the album.
+   */
+  void setOwnerId(String ownerId);
+
+  /**
+   * Get the URL to the thumbnail cover image for the album.
+   *
+   * @return a string specifying the URL for thumbnail cover image of the album.
+   */
+  String getThumbnailUrl();
+
+  /**
+   * Set the URL of the thumbnail cover image for the album.
+   *
+   * @param thumbnailUrl a string specifying the URL for thumbnail cover image of the album.
+   */
+  void setThumbnailUrl(String thumbnailUrl);
+
+  /**
+   * Get the title of the album.
+   *
+   * @return a string specifying the tile of the album.
+   */
+  String getTitle();
+
+  /**
+   * Set the title of the album.
+   *
+   * @param title a string specifying the title of the album.
+   */
+  void setTitle(String title);
+}