r7407 - in dumbhippo/trunk/server/src/com/dumbhippo/server: blocks impl util



Author: marinaz
Date: 2008-04-02 15:38:25 -0500 (Wed, 02 Apr 2008)
New Revision: 7407

Added:
   dumbhippo/trunk/server/src/com/dumbhippo/server/util/NotFoundUncheckedException.java
Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/FacebookBlockHandlerBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java
Log:
Create FacebookEvent blocks if they are missing when we have new FacebookEvents. This can happen if we created the original blocks for a user account that is no longer associated with a given FacebookAccount.

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/FacebookBlockHandlerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/FacebookBlockHandlerBean.java	2008-04-02 17:41:25 UTC (rev 7406)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/FacebookBlockHandlerBean.java	2008-04-02 20:38:25 UTC (rev 7407)
@@ -25,6 +25,7 @@
 import com.dumbhippo.server.FacebookSystem;
 import com.dumbhippo.server.NotFoundException;
 import com.dumbhippo.server.util.EJBUtil;
+import com.dumbhippo.server.util.NotFoundUncheckedException;
 import com.dumbhippo.server.views.PersonView;
 import com.dumbhippo.server.views.Viewpoint;
 import com.dumbhippo.services.caches.CacheFactory;
@@ -160,15 +161,16 @@
 	}
 	
 	public void onFacebookEvent(User user, FacebookEvent event) {
-		
 		// FIXME check ExternalAccountSystem.getExternalAccountExistsLovedAndEnabled or is that already guaranteed?
-		
-		if (event.getEventType().getDisplayToOthers()) {
-			stacker.stack(getKey(user, event, StackInclusion.IN_ALL_STACKS), 
-				          event.getEventTimestampAsLong(), user, false, StackReason.BLOCK_UPDATE);
-		} else {
-			stacker.stack(getKey(user, event, StackInclusion.ONLY_WHEN_VIEWING_SELF), 
-				      event.getEventTimestampAsLong(), user, false, StackReason.BLOCK_UPDATE);
+		StackInclusion stackInclusion = event.getEventType().getDisplayToOthers() ? StackInclusion.IN_ALL_STACKS : StackInclusion.ONLY_WHEN_VIEWING_SELF;
+		BlockKey key = getKey(user, event, stackInclusion);
+		try {
+		    stacker.stack(key, event.getEventTimestampAsLong(), user, false, StackReason.BLOCK_UPDATE);
+		} catch (NotFoundUncheckedException e) {
+			// This can happen if the FacebookAccount was transferred to a new user, and while old 
+			// "recyclable" Facebook Events exist, the Blocks for the new user do not exist
+			onFacebookEventCreated(user, event);
+			stacker.stack(key, event.getEventTimestampAsLong(), user, false, StackReason.BLOCK_UPDATE);
 		}
 	}
 }

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java	2008-04-02 17:41:25 UTC (rev 7406)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java	2008-04-02 20:38:25 UTC (rev 7407)
@@ -96,6 +96,7 @@
 import com.dumbhippo.server.dm.UserClientMatcher;
 import com.dumbhippo.server.dm.UserDMO;
 import com.dumbhippo.server.util.EJBUtil;
+import com.dumbhippo.server.util.NotFoundUncheckedException;
 import com.dumbhippo.server.views.GroupMugshotView;
 import com.dumbhippo.server.views.GroupView;
 import com.dumbhippo.server.views.PersonMugshotView;
@@ -823,7 +824,7 @@
 		try {
 			block = queryBlock(key);
 		} catch (NotFoundException e) {
-			throw new RuntimeException("stack() called on block that doesn't exist; probably means a migration is needed. key=" + key, e);
+			throw new NotFoundUncheckedException("stack() called on block that doesn't exist; probably means a migration is needed. key=" + key, e);
 		}
         stack(block, activity, participant, isGroupParticipation, reason, updateAllUserBlockDatas);
         return block;

Added: dumbhippo/trunk/server/src/com/dumbhippo/server/util/NotFoundUncheckedException.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/util/NotFoundUncheckedException.java	2008-04-02 17:41:25 UTC (rev 7406)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/util/NotFoundUncheckedException.java	2008-04-02 20:38:25 UTC (rev 7407)
@@ -0,0 +1,9 @@
+package com.dumbhippo.server.util;
+
+public class NotFoundUncheckedException extends RuntimeException {
+	private static final long serialVersionUID = 1L;
+	
+	public NotFoundUncheckedException(String message, Exception e) {
+		super(message, e);
+	}
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]