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



Author: marinaz
Date: 2008-04-02 16:21:34 -0500 (Wed, 02 Apr 2008)
New Revision: 7408

Removed:
   dumbhippo/trunk/server/src/com/dumbhippo/server/util/NotFoundUncheckedException.java
Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/server/Stacker.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/FacebookBlockHandlerBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java
Log:
Change interfaces to not have to use an unchecked exception.

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/Stacker.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/Stacker.java	2008-04-02 20:38:25 UTC (rev 7407)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/Stacker.java	2008-04-02 21:21:34 UTC (rev 7408)
@@ -41,6 +41,8 @@
 	public void stack(Block block, long activity, User participant, boolean isGroupParticipation, StackReason reason);
 	public void stack(Block block, long activity, StackReason reason);
 
+	public Block stackIfFound(BlockKey key, long activity, User participant, boolean isGroupParticipation, StackReason reason, boolean updateAllUserBlockDatas) throws NotFoundException;
+
 	/**
 	 * Re-requests the desired user/group block datas from the block handler, 
 	 * and toggles the deleted flag on any ubd/gdb that already 

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/FacebookBlockHandlerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/FacebookBlockHandlerBean.java	2008-04-02 20:38:25 UTC (rev 7407)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/FacebookBlockHandlerBean.java	2008-04-02 21:21:34 UTC (rev 7408)
@@ -25,7 +25,6 @@
 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;
@@ -165,8 +164,8 @@
 		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) {
+		    stacker.stackIfFound(key, event.getEventTimestampAsLong(), user, false, StackReason.BLOCK_UPDATE, true);
+		} catch (NotFoundException 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);

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java	2008-04-02 20:38:25 UTC (rev 7407)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java	2008-04-02 21:21:34 UTC (rev 7408)
@@ -96,7 +96,6 @@
 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;
@@ -824,7 +823,7 @@
 		try {
 			block = queryBlock(key);
 		} catch (NotFoundException e) {
-			throw new NotFoundUncheckedException("stack() called on block that doesn't exist; probably means a migration is needed. key=" + key, e);
+			throw new RuntimeException("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;
@@ -838,6 +837,13 @@
 		return stack(key, activity, null, false, reason, true);
 	}
 	
+	public Block stackIfFound(BlockKey key, long activity, User participant, boolean isGroupParticipation, StackReason reason, boolean updateAllUserBlockDatas) throws NotFoundException {
+		// queryBlock() will throw a NotFoundException if the block is not found
+		Block block = queryBlock(key);
+        stack(block, activity, participant, isGroupParticipation, reason, updateAllUserBlockDatas);
+        return block;		
+	}
+	
 	public void blockClicked(BlockKey key, User user, long clickedTime) {
 		UserBlockData ubd;
 		try {

Deleted: dumbhippo/trunk/server/src/com/dumbhippo/server/util/NotFoundUncheckedException.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/util/NotFoundUncheckedException.java	2008-04-02 20:38:25 UTC (rev 7407)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/util/NotFoundUncheckedException.java	2008-04-02 21:21:34 UTC (rev 7408)
@@ -1,9 +0,0 @@
-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]