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/08/25 19:59:23 UTC

svn commit: r688804 - in /incubator/shindig/trunk: java/social-api/src/main/java/org/apache/shindig/social/core/model/ java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/ java/social-api/src/test/java/org/apache/shindig/social/dat...

Author: doll
Date: Mon Aug 25 10:59:22 2008
New Revision: 688804

URL: http://svn.apache.org/viewvc?rev=688804&view=rev
Log:
0.8.1 change
profileUrl is a proxied field - it is really stored in the urls list with a type of "profile". 



Modified:
    incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/PersonImpl.java
    incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/Person.java
    incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulJsonPeopleTest.java
    incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/model/PersonTest.java
    incubator/shindig/trunk/javascript/sampledata/canonicaldb.json

Modified: incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/PersonImpl.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/PersonImpl.java?rev=688804&r1=688803&r2=688804&view=diff
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/PersonImpl.java (original)
+++ incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/PersonImpl.java Mon Aug 25 10:59:22 2008
@@ -27,6 +27,8 @@
 import org.apache.shindig.social.opensocial.model.Phone;
 import org.apache.shindig.social.opensocial.model.Url;
 
+import com.google.common.collect.Lists;
+
 import java.util.Date;
 import java.util.List;
 
@@ -71,7 +73,6 @@
   private List<Phone> phoneNumbers;
   private String politicalViews;
   private Url profileSong;
-  private String profileUrl;
   private Url profileVideo;
   private List<String> quotes;
   private String relationshipStatus;
@@ -399,14 +400,6 @@
     this.profileSong = profileSong;
   }
 
-  public String getProfileUrl() {
-    return profileUrl;
-  }
-
-  public void setProfileUrl(String profileUrl) {
-    this.profileUrl = profileUrl;
-  }
-
   public Url getProfileVideo() {
     return profileVideo;
   }
@@ -566,4 +559,42 @@
   public void setIsViewer(boolean isViewer) {
     this.isViewer = isViewer;
   }
+
+
+  // Proxied fields
+
+  public String getProfileUrl() {
+    Url url = getUrlWithType(PROFILE_URL_TYPE);
+    return url == null ? null : url.getAddress();
+  }
+
+  public void setProfileUrl(String profileUrl) {
+    Url url = getUrlWithType(PROFILE_URL_TYPE);
+    if (url != null) {
+      url.setAddress(profileUrl);
+    } else {
+      addUrl(new UrlImpl(profileUrl, null, PROFILE_URL_TYPE));
+    }
+  }
+
+  private void addUrl(Url url) {
+    List<Url> urls = getUrls();
+    if (urls == null) {
+      setUrls(Lists.<Url>newArrayList());
+    }
+    getUrls().add(url);
+  }
+
+  private Url getUrlWithType(String type) {
+    List<Url> urls = getUrls();
+    if (urls != null) {
+      for (Url url : urls) {
+        if (type.equalsIgnoreCase(url.getType())) {
+          return url;
+        }
+      }
+    }
+
+    return null;
+  }
 }

Modified: incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/Person.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/Person.java?rev=688804&r1=688803&r2=688804&view=diff
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/Person.java (original)
+++ incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/Person.java Mon Aug 25 10:59:22 2008
@@ -35,6 +35,7 @@
  */
 @ImplementedBy(PersonImpl.class)
 public interface Person {
+  public static final String PROFILE_URL_TYPE = "profile";
 
   /**
    * The fields that represent the person object ion json form.
@@ -790,22 +791,6 @@
   void setProfileSong(Url profileSong);
 
   /**
-   * Get the person's profile URL. This URL must be fully qualified. Relative URLs will not work in
-   * gadgets Container support for this field is OPTIONAL.
-   *
-   * @return the person's profile URL
-   */
-  String getProfileUrl();
-
-  /**
-   * Set the person's profile URL. This URL must be fully qualified. Relative URLs will not work in
-   * gadgets Container support for this field is OPTIONAL.
-   *
-   * @param profileUrl the person's profile URL
-   */
-  void setProfileUrl(String profileUrl);
-
-  /**
    * Get the Person's profile video. Container support for this field is OPTIONAL.
    *
    * @return the Person's profile video
@@ -1086,4 +1071,27 @@
    */
   void setIsViewer(boolean isViewer);
 
+
+  // Proxied fields
+
+  /**
+   * Get the person's profile URL. This URL must be fully qualified. Relative URLs will not work in
+   * gadgets. This field MUST be stored in the urls list with a type of "profile".
+   *
+   * Container support for this field is OPTIONAL.
+   *
+   * @return the person's profile URL
+   */
+  String getProfileUrl();
+
+  /**
+   * Set the person's profile URL. This URL must be fully qualified. Relative URLs will not work in
+   * gadgets. This field MUST be stored in the urls list with a type of "profile".
+   *
+   * Container support for this field is OPTIONAL.
+   *
+   * @param profileUrl the person's profile URL
+   */
+  void setProfileUrl(String profileUrl);
+
 }

Modified: incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulJsonPeopleTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulJsonPeopleTest.java?rev=688804&r1=688803&r2=688804&view=diff
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulJsonPeopleTest.java (original)
+++ incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/RestfulJsonPeopleTest.java Mon Aug 25 10:59:22 2008
@@ -150,7 +150,6 @@
     canonical.setPoliticalViews("open leaning");
     canonical.setProfileSong(new UrlImpl("http://www.example.org/songs/OnlyTheLonely.mp3",
         "Feelin' blue", "road"));
-    canonical.setProfileUrl("http://www.example.org/?id=1");
     canonical.setProfileVideo(new UrlImpl("http://www.example.org/videos/Thriller.flv",
         "Thriller", "video"));
 
@@ -185,8 +184,8 @@
     canonical.setTvShows(Lists.newArrayList("House", "Battlestar Galactica"));
 
     canonical.setUrls(Lists.<Url>newArrayList(
-        new UrlImpl("http://www.example.org/?id=1", "Profile", "text/html"),
-        new UrlImpl("http://www.example.org/pic/?id=1", "Thumbnail", "img/*")));
+        new UrlImpl("http://www.example.org/?id=1", "my profile", "Profile"),
+        new UrlImpl("http://www.example.org/pic/?id=1", "my awesome picture", "Thumbnail")));
   }
 
   /**

Modified: incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/model/PersonTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/model/PersonTest.java?rev=688804&r1=688803&r2=688804&view=diff
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/model/PersonTest.java (original)
+++ incubator/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/model/PersonTest.java Mon Aug 25 10:59:22 2008
@@ -17,6 +17,8 @@
  */
 package org.apache.shindig.social.opensocial.model;
 
+import org.apache.shindig.social.core.model.PersonImpl;
+
 import junit.framework.TestCase;
 
 public class PersonTest extends TestCase {
@@ -34,4 +36,17 @@
     assertEquals(field, Person.Field.fromUrlString(field.toString()));
   }
 
+  public void testGetProfileUrl() throws Exception {
+    Person person = new PersonImpl();
+    assertEquals(null, person.getProfileUrl());
+
+    String address = "hi";
+    person.setProfileUrl(address);
+    assertEquals(address, person.getProfileUrl());
+
+    assertEquals(address, person.getUrls().get(0).getAddress());
+    assertEquals(Person.PROFILE_URL_TYPE, person.getUrls().get(0).getType());
+    assertEquals(null, person.getUrls().get(0).getLinkText());
+  }
+
 }
\ No newline at end of file

Modified: incubator/shindig/trunk/javascript/sampledata/canonicaldb.json
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/sampledata/canonicaldb.json?rev=688804&r1=688803&r2=688804&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/sampledata/canonicaldb.json (original)
+++ incubator/shindig/trunk/javascript/sampledata/canonicaldb.json Mon Aug 25 10:59:22 2008
@@ -175,12 +175,12 @@
 "tvShows" : ["House","Battlestar Galactica"],
 "urls" : [{
 "address" : "http://www.example.org/?id=1",
-"linkText" : "Profile",
-"type" : "text/html"
+"linkText" : "my profile",
+"type" : "Profile"
 },{
 "address" : "http://www.example.org/pic/?id=1",
-"linkText" : "Thumbnail",
-"type" : "img/*"
+"linkText" : "my awesome picture",
+"type" : "Thumbnail"
 }]
 },
 {