r7150 - in dumbhippo/trunk/server/src/com/dumbhippo: persistence server/dm
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7150 - in dumbhippo/trunk/server/src/com/dumbhippo: persistence server/dm
- Date: Tue, 8 Jan 2008 15:47:04 -0600 (CST)
Author: otaylor
Date: 2008-01-08 15:47:04 -0600 (Tue, 08 Jan 2008)
New Revision: 7150
Added:
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FacebookEventBlockDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FacebookPhotoThumbnailDMO.java
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/persistence/FacebookPhotoDataStatus.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PicasaAlbumThumbnailDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailType.java
Log:
FacebookPhotoThumbnailDMO ThumbnailDMO ThumbnailType: Add a FacebookPhoto
thumbnail type for the data model.
FacebookEventBlockDMO BlockDMO: Export FACEBOOK_EVENT blocks via the
data model.
FacebookPhotoDataStatus: Add a comment explaining a hole in how we
match up photos.
Modified: dumbhippo/trunk/server/src/com/dumbhippo/persistence/FacebookPhotoDataStatus.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/persistence/FacebookPhotoDataStatus.java 2008-01-08 20:49:31 UTC (rev 7149)
+++ dumbhippo/trunk/server/src/com/dumbhippo/persistence/FacebookPhotoDataStatus.java 2008-01-08 21:47:04 UTC (rev 7150)
@@ -26,6 +26,20 @@
private String photoId;
// deprecated
private Integer photoIdSalt;
+
+ // We store the facebook "photo ID" to try and uniquely identify a photo over time.
+ // However this isn't perfect: facebook photo ID's are only unique among photos
+ // uploaded by a particular user. So we could have the situation where our user
+ // is tagged in two photos with the same photo ID uploaded by different facebook
+ // users. If that happens, we'll throw a constaint violation when trying to save
+ // the photos to CachedFacebookPhotoData.java. Luckily, this situation seems
+ // to occur very infrequently.
+ //
+ // The way to fix this is to store not just the facebook photo ID
+ // but the facebook photo ID and the ID of the facebook user that uploaded the
+ // photo. (A transitional measure after adding the uploading user ID is to consider a
+ // FacebookPhotoDataStatus with no uploading user ID as matching any photo
+ // with the same photo ID.)
private String facebookPhotoId;
protected FacebookPhotoDataStatus() {}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java 2008-01-08 20:49:31 UTC (rev 7149)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java 2008-01-08 21:47:04 UTC (rev 7150)
@@ -91,6 +91,9 @@
case AMAZON_WISH_LIST_ITEM:
return AmazonWishListItemBlockDMO.class;
+ case FACEBOOK_EVENT:
+ return FacebookEventBlockDMO.class;
+
case GROUP_CHAT:
return GroupChatBlockDMO.class;
@@ -111,7 +114,6 @@
default:
case GROUP_MEMBER:
- case FACEBOOK_EVENT:
case FLICKR_PHOTOSET:
case GROUP_REVISION:
case OBSOLETE_EXTERNAL_ACCOUNT_UPDATE:
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java 2008-01-08 20:49:31 UTC (rev 7149)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java 2008-01-08 21:47:04 UTC (rev 7150)
@@ -92,6 +92,7 @@
model.addDMClass(AccountQuestionBlockDMO.class);
model.addDMClass(AmazonWishListItemBlockDMO.class);
model.addDMClass(AmazonReviewBlockDMO.class);
+ model.addDMClass(FacebookEventBlockDMO.class);
model.addDMClass(GroupChatBlockDMO.class);
model.addDMClass(MusicChatBlockDMO.class);
model.addDMClass(MusicPersonBlockDMO.class);
@@ -114,6 +115,7 @@
model.addDMClass(NetflixMovieDMO.class);
model.addDMClass(ThumbnailDMO.class);
+ model.addDMClass(FacebookPhotoThumbnailDMO.class);
model.addDMClass(PicasaAlbumThumbnailDMO.class);
model.addDMClass(YouTubeThumbnailDMO.class);
Added: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FacebookEventBlockDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FacebookEventBlockDMO.java 2008-01-08 20:49:31 UTC (rev 7149)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FacebookEventBlockDMO.java 2008-01-08 21:47:04 UTC (rev 7150)
@@ -0,0 +1,32 @@
+package com.dumbhippo.server.dm;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.dumbhippo.Thumbnail;
+import com.dumbhippo.Thumbnails;
+import com.dumbhippo.dm.annotations.DMO;
+import com.dumbhippo.persistence.User;
+import com.dumbhippo.server.blocks.FacebookBlockView;
+import com.dumbhippo.services.FacebookPhotoDataView;
+
+ DMO(classId="http://mugshot.org/p/o/facebookEventBlock")
+public abstract class FacebookEventBlockDMO extends ThumbnailsBlockDMO {
+ protected FacebookEventBlockDMO(BlockDMOKey key) {
+ super(key);
+ }
+
+ @Override
+ public List<ThumbnailDMO> getThumbnails() {
+ FacebookBlockView facebookView = (FacebookBlockView)blockView;
+
+ Thumbnails thumbnails = facebookView.getThumbnails();
+ User user = facebookView.getPersonSource().getUser();
+
+ List<ThumbnailDMO> result = new ArrayList<ThumbnailDMO>();
+ for (Thumbnail thumbnail : thumbnails.getThumbnails())
+ result.add(session.findUnchecked(FacebookPhotoThumbnailDMO.class, FacebookPhotoThumbnailDMO.getKey(user, (FacebookPhotoDataView)thumbnail)));
+
+ return result;
+ }
+}
Added: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FacebookPhotoThumbnailDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FacebookPhotoThumbnailDMO.java 2008-01-08 20:49:31 UTC (rev 7149)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FacebookPhotoThumbnailDMO.java 2008-01-08 21:47:04 UTC (rev 7150)
@@ -0,0 +1,55 @@
+package com.dumbhippo.server.dm;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.dumbhippo.dm.annotations.DMO;
+import com.dumbhippo.persistence.User;
+import com.dumbhippo.server.NotFoundException;
+import com.dumbhippo.services.FacebookPhotoDataView;
+import com.dumbhippo.services.caches.FacebookPhotoDataCache;
+import com.dumbhippo.services.caches.WebServiceCache;
+
+ DMO(classId="http://mugshot.org/p/o/facebookPhotoThumbnail")
+public abstract class FacebookPhotoThumbnailDMO extends ThumbnailDMO {
+ @WebServiceCache
+ private FacebookPhotoDataCache facebookPhotoDataCache;
+
+ protected FacebookPhotoThumbnailDMO(ThumbnailKey key) {
+ super(key);
+ }
+
+ private static Pattern FACEBOOK_URL_PATTERN = Pattern.compile("http://www.facebook.com/photo.php?pid=([0-9]+)&id=([0-9]+])");
+
+ private static String extractExtra(String url) {
+ Matcher m = FACEBOOK_URL_PATTERN.matcher(url);
+ if (m.matches())
+ return m.group(2) + "-" + m.group(1);
+ else
+ throw new RuntimeException("Cannot extract key from Facebook URL '" + url + "'");
+ }
+
+ @Override
+ protected void init() throws NotFoundException {
+ super.init();
+
+ if (thumbnail == null) {
+ List<? extends FacebookPhotoDataView> photos = facebookPhotoDataCache.getSync(getKey().getUserId().toString());
+
+ String extra = getKey().getExtra();
+ for (FacebookPhotoDataView photo : photos) {
+ if (extra.equals(extractExtra(photo.getLink()))) {
+ thumbnail = photo;
+ return;
+ }
+ }
+
+ throw new NotFoundException("Can't find photo");
+ }
+ }
+
+ public static ThumbnailKey getKey(User user, FacebookPhotoDataView photo) {
+ return new ThumbnailKey(user.getGuid(), ThumbnailType.FACEBOOK_PHOTO, extractExtra(photo.getLink()), photo);
+ }
+}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PicasaAlbumThumbnailDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PicasaAlbumThumbnailDMO.java 2008-01-08 20:49:31 UTC (rev 7149)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PicasaAlbumThumbnailDMO.java 2008-01-08 21:47:04 UTC (rev 7150)
@@ -18,7 +18,7 @@
import com.dumbhippo.services.caches.PicasaAlbumsCache;
import com.dumbhippo.services.caches.WebServiceCache;
- DMO(classId="http://mugshot.org/p/o/youTubeThumbnail")
+ DMO(classId="http://mugshot.org/p/o/picasaAlbumThumbnail")
public abstract class PicasaAlbumThumbnailDMO extends ThumbnailDMO {
@EJB
private ExternalAccountSystem externalAccountSystem;
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailDMO.java 2008-01-08 20:49:31 UTC (rev 7149)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailDMO.java 2008-01-08 21:47:04 UTC (rev 7150)
@@ -19,6 +19,8 @@
@MetaConstruct
public static Class<? extends ThumbnailDMO> getDMOClass(ThumbnailKey key) {
switch (key.getType()) {
+ case FACEBOOK_PHOTO:
+ return FacebookPhotoThumbnailDMO.class;
case PICASA_ALBUM:
return PicasaAlbumThumbnailDMO.class;
case YOUTUBE:
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailType.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailType.java 2008-01-08 20:49:31 UTC (rev 7149)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailType.java 2008-01-08 21:47:04 UTC (rev 7150)
@@ -1,6 +1,7 @@
package com.dumbhippo.server.dm;
public enum ThumbnailType {
+ FACEBOOK_PHOTO,
PICASA_ALBUM,
YOUTUBE
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]