r7154 - dumbhippo/trunk/server/src/com/dumbhippo/server/dm
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7154 - dumbhippo/trunk/server/src/com/dumbhippo/server/dm
- Date: Tue, 8 Jan 2008 18:08:41 -0600 (CST)
Author: otaylor
Date: 2008-01-08 18:08:41 -0600 (Tue, 08 Jan 2008)
New Revision: 7154
Added:
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPersonBlockDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPhotoThumbnailDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPhotosetBlockDMO.java
Modified:
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/ThumbnailDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailType.java
Log:
FlickrPhotosetBlockDMO FlickrPersonBlockDMO BlockDMO: Flickr blocks
in the data model
FlickrPhotoThumbnailDMO ThumbnailDMO ThumbnailType: Flickr thumbnails
in the data model
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java 2008-01-08 22:57:05 UTC (rev 7153)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java 2008-01-09 00:08:41 UTC (rev 7154)
@@ -71,7 +71,6 @@
public static Class<? extends BlockDMO> getDMOClass(BlockType blockType) {
switch (blockType) {
- case FLICKR_PERSON:
case YOUTUBE_PERSON:
case MYSPACE_PERSON:
case BLOG_ENTRY:
@@ -94,6 +93,12 @@
case FACEBOOK_EVENT:
return FacebookEventBlockDMO.class;
+ case FLICKR_PERSON:
+ return FlickrPersonBlockDMO.class;
+
+ case FLICKR_PHOTOSET:
+ return FlickrPhotosetBlockDMO.class;
+
case GROUP_CHAT:
return GroupChatBlockDMO.class;
@@ -114,7 +119,6 @@
default:
case GROUP_MEMBER:
- case FLICKR_PHOTOSET:
case GROUP_REVISION:
case OBSOLETE_EXTERNAL_ACCOUNT_UPDATE:
case OBSOLETE_EXTERNAL_ACCOUNT_UPDATE_SELF:
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java 2008-01-08 22:57:05 UTC (rev 7153)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java 2008-01-09 00:08:41 UTC (rev 7154)
@@ -92,12 +92,14 @@
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);
model.addDMClass(NetflixMovieBlockDMO.class);
model.addDMClass(ThumbnailsBlockDMO.class);
+ model.addDMClass(FacebookEventBlockDMO.class);
+ model.addDMClass(FlickrPersonBlockDMO.class);
+ model.addDMClass(FlickrPhotosetBlockDMO.class);
model.addDMClass(PicasaPersonBlockDMO.class);
model.addDMClass(PostBlockDMO.class);
@@ -115,6 +117,7 @@
model.addDMClass(NetflixMovieDMO.class);
model.addDMClass(ThumbnailDMO.class);
+ model.addDMClass(FlickrPhotoThumbnailDMO.class);
model.addDMClass(FacebookPhotoThumbnailDMO.class);
model.addDMClass(PicasaAlbumThumbnailDMO.class);
model.addDMClass(YouTubeThumbnailDMO.class);
Added: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPersonBlockDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPersonBlockDMO.java 2008-01-08 22:57:05 UTC (rev 7153)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPersonBlockDMO.java 2008-01-09 00:08:41 UTC (rev 7154)
@@ -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.FlickrPersonBlockView;
+import com.dumbhippo.services.FlickrPhotoView;
+
+ DMO(classId="http://mugshot.org/p/o/flickrPhotosetBlock")
+public abstract class FlickrPersonBlockDMO extends ThumbnailsBlockDMO {
+ protected FlickrPersonBlockDMO(BlockDMOKey key) {
+ super(key);
+ }
+
+ @Override
+ public List<ThumbnailDMO> getThumbnails() {
+ FlickrPersonBlockView photosetView = (FlickrPersonBlockView)blockView;
+
+ Thumbnails thumbnails = photosetView.getThumbnails();
+ User user = photosetView.getPersonSource().getUser();
+
+ List<ThumbnailDMO> result = new ArrayList<ThumbnailDMO>();
+ for (Thumbnail thumbnail : thumbnails.getThumbnails())
+ result.add(session.findUnchecked(FlickrPhotoThumbnailDMO.class, FlickrPhotoThumbnailDMO.getKey(user, (FlickrPhotoView)thumbnail)));
+
+ return result;
+ }
+}
Added: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPhotoThumbnailDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPhotoThumbnailDMO.java 2008-01-08 22:57:05 UTC (rev 7153)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPhotoThumbnailDMO.java 2008-01-09 00:08:41 UTC (rev 7154)
@@ -0,0 +1,84 @@
+package com.dumbhippo.server.dm;
+
+import javax.ejb.EJB;
+
+import com.dumbhippo.dm.annotations.DMO;
+import com.dumbhippo.persistence.ExternalAccount;
+import com.dumbhippo.persistence.ExternalAccountType;
+import com.dumbhippo.persistence.User;
+import com.dumbhippo.server.ExternalAccountSystem;
+import com.dumbhippo.server.IdentitySpider;
+import com.dumbhippo.server.NotFoundException;
+import com.dumbhippo.server.views.SystemViewpoint;
+import com.dumbhippo.services.FlickrPhotoView;
+import com.dumbhippo.services.FlickrPhotosView;
+import com.dumbhippo.services.FlickrPhotosetView;
+import com.dumbhippo.services.FlickrPhotosetsView;
+import com.dumbhippo.services.caches.FlickrPhotosetPhotosCache;
+import com.dumbhippo.services.caches.FlickrUserPhotosCache;
+import com.dumbhippo.services.caches.FlickrUserPhotosetsCache;
+import com.dumbhippo.services.caches.WebServiceCache;
+
+ DMO(classId="http://mugshot.org/p/o/facebookPhotoThumbnail")
+public abstract class FlickrPhotoThumbnailDMO extends ThumbnailDMO {
+ @EJB
+ ExternalAccountSystem externalAccountSystem;
+
+ @EJB
+ IdentitySpider identitySpider;
+
+ @WebServiceCache
+ private FlickrUserPhotosCache flickrUserPhotosCache;
+
+ @WebServiceCache
+ private FlickrUserPhotosetsCache flickrUserPhotosetsCache;
+
+ @WebServiceCache
+ private FlickrPhotosetPhotosCache flickrPhotosetPhotosCache;
+
+ protected FlickrPhotoThumbnailDMO(ThumbnailKey key) {
+ super(key);
+ }
+
+ @Override
+ protected void init() throws NotFoundException {
+ super.init();
+
+ if (thumbnail == null) {
+ // This is horribly inefficient ... in order to find the photo, we load all user photos
+ // and all photos in all photosets of user to find the one with the right ID. We'll normally
+ // be saved by the cached object in ThumbnailKey.
+
+ User user = identitySpider.lookupUser(getKey().getUserId());
+ ExternalAccount externalAccount = externalAccountSystem.lookupExternalAccount(SystemViewpoint.getInstance(), user, ExternalAccountType.FLICKR);
+ if (!externalAccount.isLovedAndEnabled())
+ throw new NotFoundException("Account is not loved and enabled");
+
+ FlickrPhotosView photos = flickrUserPhotosCache.getSync(externalAccount.getHandle());
+
+ String extra = getKey().getExtra();
+ for (FlickrPhotoView photo : photos.getPhotos()) {
+ if (extra.equals(photo.getId())) {
+ thumbnail = photo;
+ return;
+ }
+ }
+
+ FlickrPhotosetsView photosets = flickrUserPhotosetsCache.getSync(externalAccount.getHandle());
+ for (FlickrPhotosetView photoset : photosets.getSets()) {
+ for (FlickrPhotoView photo : flickrPhotosetPhotosCache.getSync(photoset.getId())) {
+ if (extra.equals(photo.getId())) {
+ thumbnail = photo;
+ return;
+ }
+ }
+ }
+
+ throw new NotFoundException("Can't find photo");
+ }
+ }
+
+ public static ThumbnailKey getKey(User user, FlickrPhotoView photo) {
+ return new ThumbnailKey(user.getGuid(), ThumbnailType.FLICKR_PHOTO, photo.getId(), photo);
+ }
+}
Added: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPhotosetBlockDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPhotosetBlockDMO.java 2008-01-08 22:57:05 UTC (rev 7153)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FlickrPhotosetBlockDMO.java 2008-01-09 00:08:41 UTC (rev 7154)
@@ -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.FlickrPhotosetBlockView;
+import com.dumbhippo.services.FlickrPhotoView;
+
+ DMO(classId="http://mugshot.org/p/o/flickrPhotosetBlock")
+public abstract class FlickrPhotosetBlockDMO extends ThumbnailsBlockDMO {
+ protected FlickrPhotosetBlockDMO(BlockDMOKey key) {
+ super(key);
+ }
+
+ @Override
+ public List<ThumbnailDMO> getThumbnails() {
+ FlickrPhotosetBlockView photosetView = (FlickrPhotosetBlockView)blockView;
+
+ Thumbnails thumbnails = photosetView.getThumbnails();
+ User user = photosetView.getPersonSource().getUser();
+
+ List<ThumbnailDMO> result = new ArrayList<ThumbnailDMO>();
+ for (Thumbnail thumbnail : thumbnails.getThumbnails())
+ result.add(session.findUnchecked(FlickrPhotoThumbnailDMO.class, FlickrPhotoThumbnailDMO.getKey(user, (FlickrPhotoView)thumbnail)));
+
+ return result;
+ }
+}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailDMO.java 2008-01-08 22:57:05 UTC (rev 7153)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailDMO.java 2008-01-09 00:08:41 UTC (rev 7154)
@@ -21,6 +21,8 @@
switch (key.getType()) {
case FACEBOOK_PHOTO:
return FacebookPhotoThumbnailDMO.class;
+ case FLICKR_PHOTO:
+ return FlickrPhotoThumbnailDMO.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 22:57:05 UTC (rev 7153)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ThumbnailType.java 2008-01-09 00:08:41 UTC (rev 7154)
@@ -2,6 +2,7 @@
public enum ThumbnailType {
FACEBOOK_PHOTO,
+ FLICKR_PHOTO,
PICASA_ALBUM,
YOUTUBE
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]