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 21:45:28 UTC
svn commit: r688850 - in /incubator/shindig/trunk/java/social-api/src:
main/java/org/apache/shindig/social/core/model/
main/java/org/apache/shindig/social/opensocial/model/
test/java/org/apache/shindig/social/opensocial/model/
Author: doll
Date: Mon Aug 25 12:45:28 2008
New Revision: 688850
URL: http://svn.apache.org/viewvc?rev=688850&view=rev
Log:
0.8.1 change
Added a new photos field and the thumbnailUrl field just pulls from an item of the photos list.
Added:
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/ListFieldImpl.java
incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/ListField.java
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/opensocial/model/PersonTest.java
Added: incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/ListFieldImpl.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/ListFieldImpl.java?rev=688850&view=auto
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/ListFieldImpl.java (added)
+++ incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/core/model/ListFieldImpl.java Mon Aug 25 12:45:28 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.ListField;
+
+public class ListFieldImpl implements ListField {
+ String type;
+ String value;
+
+ public ListFieldImpl(String type, String value) {
+ this.type = type;
+ this.value = value;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
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=688850&r1=688849&r2=688850&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 12:45:28 2008
@@ -21,6 +21,7 @@
import org.apache.shindig.social.opensocial.model.BodyType;
import org.apache.shindig.social.opensocial.model.Email;
import org.apache.shindig.social.opensocial.model.Enum;
+import org.apache.shindig.social.opensocial.model.ListField;
import org.apache.shindig.social.opensocial.model.Name;
import org.apache.shindig.social.opensocial.model.Organization;
import org.apache.shindig.social.opensocial.model.Person;
@@ -71,6 +72,7 @@
private String nickname;
private String pets;
private List<Phone> phoneNumbers;
+ private List<ListField> photos;
private String politicalViews;
private Url profileSong;
private Url profileVideo;
@@ -85,7 +87,6 @@
private List<String> sports;
private String status;
private List<String> tags;
- private String thumbnailUrl;
private Long timeZone;
private List<String> turnOffs;
private List<String> turnOns;
@@ -384,6 +385,14 @@
this.phoneNumbers = phoneNumbers;
}
+ public List<ListField> getPhotos() {
+ return photos;
+ }
+
+ public void setPhotos(List<ListField> photos) {
+ this.photos = photos;
+ }
+
public String getPoliticalViews() {
return politicalViews;
}
@@ -496,14 +505,6 @@
this.tags = tags;
}
- public String getThumbnailUrl() {
- return thumbnailUrl;
- }
-
- public void setThumbnailUrl(String thumbnailUrl) {
- this.thumbnailUrl = thumbnailUrl;
- }
-
public Long getTimeZone() {
return timeZone;
}
@@ -577,6 +578,21 @@
}
}
+ public String getThumbnailUrl() {
+ ListField photo = getPhotoWithType(THUMBNAIL_PHOTO_TYPE);
+ return photo == null ? null : photo.getValue();
+ }
+
+ public void setThumbnailUrl(String thumbnailUrl) {
+ ListField photo = getPhotoWithType(THUMBNAIL_PHOTO_TYPE);
+ if (photo != null) {
+ photo.setValue(thumbnailUrl);
+ } else {
+ addPhoto(new ListFieldImpl(THUMBNAIL_PHOTO_TYPE, thumbnailUrl));
+ }
+ }
+
+ // TODO: Generify these once they extend a common subclass
private void addUrl(Url url) {
List<Url> urls = getUrls();
if (urls == null) {
@@ -597,4 +613,25 @@
return null;
}
+
+ private void addPhoto(ListField field) {
+ List<ListField> fields = getPhotos();
+ if (fields == null) {
+ setPhotos(Lists.<ListField>newArrayList());
+ }
+ getPhotos().add(field);
+ }
+
+ private ListField getPhotoWithType(String type) {
+ List<ListField> fields = getPhotos();
+ if (fields != null) {
+ for (ListField field : fields) {
+ if (type.equalsIgnoreCase(field.getType())) {
+ return field;
+ }
+ }
+ }
+
+ return null;
+ }
}
Added: incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/ListField.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/ListField.java?rev=688850&view=auto
==============================================================================
--- incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/ListField.java (added)
+++ incubator/shindig/trunk/java/social-api/src/main/java/org/apache/shindig/social/opensocial/model/ListField.java Mon Aug 25 12:45:28 2008
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+public interface ListField {
+ String getType();
+
+ void setType(String type);
+
+ String getValue();
+
+ void setValue(String value);
+}
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=688850&r1=688849&r2=688850&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 12:45:28 2008
@@ -36,6 +36,7 @@
@ImplementedBy(PersonImpl.class)
public interface Person {
public static final String PROFILE_URL_TYPE = "profile";
+ public static final String THUMBNAIL_PHOTO_TYPE = "thumbnail";
/**
* The fields that represent the person object ion json form.
@@ -111,6 +112,7 @@
PETS("pets"),
/** the json field for phoneNumbers. */
PHONE_NUMBERS("phoneNumbers"),
+ PHOTOS("photos"),
/** the json field for politicalViews. */
POLITICAL_VIEWS("politicalViews"),
/** the json field for profileSong. */
@@ -758,6 +760,10 @@
*/
void setPhoneNumbers(List<Phone> phoneNumbers);
+ List<ListField> getPhotos();
+
+ void setPhotos(List<ListField> photos);
+
/**
* Get the Person's political views, specified as a string. Container support for this field is
* OPTIONAL.
@@ -959,22 +965,6 @@
void setTags(List<String> tags);
/**
- * Get the person's photo thumbnail URL, specified as a string. This URL must be fully qualified.
- * Relative URLs will not work in gadgets. Container support for this field is OPTIONAL.
- *
- * @return the person's photo thumbnail URL
- */
- String getThumbnailUrl();
-
- /**
- * Set the person's photo thumbnail URL, specified as a string. This URL must be fully qualified.
- * Relative URLs will not work in gadgets. Container support for this field is OPTIONAL.
- *
- * @param thumbnailUrl the person's photo thumbnail URL
- */
- void setThumbnailUrl(String thumbnailUrl);
-
- /**
* Get the Person's time zone, specified as the difference in minutes between Greenwich Mean Time
* (GMT) and the user's local time. Container support for this field is OPTIONAL.
*
@@ -1094,4 +1084,26 @@
*/
void setProfileUrl(String profileUrl);
+ /**
+ * Get the person's photo thumbnail URL, specified as a string. This URL must be fully qualified.
+ * Relative URLs will not work in gadgets.
+ * This field MUST be stored in the photos list with a type of "thumbnail".
+ *
+ * Container support for this field is OPTIONAL.
+ *
+ * @return the person's photo thumbnail URL
+ */
+ String getThumbnailUrl();
+
+ /**
+ * Set the person's photo thumbnail URL, specified as a string. This URL must be fully qualified.
+ * Relative URLs will not work in gadgets.
+ * This field MUST be stored in the photos list with a type of "thumbnail".
+ *
+ * Container support for this field is OPTIONAL.
+ *
+ * @param thumbnailUrl the person's photo thumbnail URL
+ */
+ void setThumbnailUrl(String thumbnailUrl);
+
}
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=688850&r1=688849&r2=688850&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 12:45:28 2008
@@ -47,6 +47,32 @@
assertEquals(address, person.getUrls().get(0).getAddress());
assertEquals(Person.PROFILE_URL_TYPE, person.getUrls().get(0).getType());
assertEquals(null, person.getUrls().get(0).getLinkText());
+
+ address = "something new";
+ person.setProfileUrl(address);
+ assertEquals(address, person.getProfileUrl());
+
+ assertEquals(1, person.getUrls().size());
+ assertEquals(address, person.getUrls().get(0).getAddress());
+ }
+
+ public void testGetThumbnailUrl() throws Exception {
+ Person person = new PersonImpl();
+ assertEquals(null, person.getThumbnailUrl());
+
+ String url = "hi";
+ person.setThumbnailUrl(url);
+ assertEquals(url, person.getThumbnailUrl());
+
+ assertEquals(url, person.getPhotos().get(0).getValue());
+ assertEquals(Person.THUMBNAIL_PHOTO_TYPE, person.getPhotos().get(0).getType());
+
+ url = "something new";
+ person.setThumbnailUrl(url);
+ assertEquals(url, person.getThumbnailUrl());
+
+ assertEquals(1, person.getPhotos().size());
+ assertEquals(url, person.getPhotos().get(0).getValue());
}
}
\ No newline at end of file