r7429 - dumbhippo/trunk/server/src/com/dumbhippo/server/blocks



Author: otaylor
Date: 2008-04-16 18:08:19 -0500 (Wed, 16 Apr 2008)
New Revision: 7429

Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java
Log:
Fix account question blocks when viewed from the system viewpoint. Invalidate the description when the answer changes

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java	2008-04-16 23:07:09 UTC (rev 7428)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java	2008-04-16 23:08:19 UTC (rev 7429)
@@ -54,11 +54,8 @@
 	}
 	
 	private String getApplicationUsageAnswer(AccountQuestionBlockView blockView) {
-		Viewpoint viewpoint = blockView.getViewpoint();
-		Boolean applicationUsageEnabled = null;
-		
-		if (viewpoint instanceof UserViewpoint)
-			applicationUsageEnabled = ((UserViewpoint)viewpoint).getViewer().getAccount().isApplicationUsageEnabled();
+		User user = getData1User(blockView.getBlock());
+		Boolean applicationUsageEnabled = user.getAccount().isApplicationUsageEnabled();
 
 		if (applicationUsageEnabled == null)
 			return null;
@@ -69,16 +66,15 @@
 	}
 
 	private String getFacebookApplicationAnswer(AccountQuestionBlockView blockView) {
-		Viewpoint viewpoint = blockView.getViewpoint();
+		User user = getData1User(blockView.getBlock());
 		Boolean applicationEnabled = null;
 		
-		if (viewpoint instanceof UserViewpoint)	
-			try {
-			    applicationEnabled = 
-				    facebookSystem.lookupFacebookAccount(viewpoint, ((UserViewpoint)viewpoint).getViewer()).isApplicationEnabled();
-			} catch (NotFoundException e) {
-				logger.warn("Did not find a FacebookAccount for user {} when checking their applicationEnabled status");
-			}
+		try {
+		    applicationEnabled = 
+			    facebookSystem.lookupFacebookAccount(blockView.getViewpoint(), user).isApplicationEnabled();
+		} catch (NotFoundException e) {
+			logger.warn("Did not find a FacebookAccount for user {} when checking their applicationEnabled status");
+		}
 
 		if (applicationEnabled == null)
 			return null;
@@ -188,7 +184,7 @@
 		// we handle a positive response in FacebookTrackerBean when the person adds the application
 		if (response.equals("no"))
 			try {
-				FacebookAccount facebookAccount = facebookSystem.lookupFacebookAccount(viewpoint, ((UserViewpoint)viewpoint).getViewer());
+				FacebookAccount facebookAccount = facebookSystem.lookupFacebookAccount(viewpoint, viewpoint.getViewer());
 				// only set applicationEnabled to false based on this if it was not previously true
                 if (facebookAccount.isApplicationEnabled() == null)
                 	facebookAccount.setApplicationEnabled(false);
@@ -246,6 +242,7 @@
 		BlockDMOKey dmoKey = new BlockDMOKey(block); 
 		DataService.currentSessionRW().changed(BlockDMO.class, dmoKey, "answer");
 		DataService.currentSessionRW().changed(BlockDMO.class, dmoKey, "buttons");
+		DataService.currentSessionRW().changed(BlockDMO.class, dmoKey, "description");
 		
 		// The call to blockClicked wont restack block since the clicked count 
 		// can only ever be 1, so we need restack the block ourselves to change



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