r7434 - in dumbhippo/trunk/server/src/com/dumbhippo/server: . blocks impl listeners



Author: marinaz
Date: 2008-04-18 13:28:48 -0500 (Fri, 18 Apr 2008)
New Revision: 7434

Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/server/FacebookSystem.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookSystemBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/NotifierBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/listeners/AccountStatusListener.java
Log:
Make sure we call AccountQuestionBlockHandlerBean::questionAnswered() each time FacebookAccount applicationEnabled is toggled.

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/FacebookSystem.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/FacebookSystem.java	2008-04-18 17:39:10 UTC (rev 7433)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/FacebookSystem.java	2008-04-18 18:28:48 UTC (rev 7434)
@@ -9,6 +9,7 @@
 import com.dumbhippo.persistence.FacebookAccount;
 import com.dumbhippo.persistence.FacebookEvent;
 import com.dumbhippo.persistence.User;
+import com.dumbhippo.server.views.UserViewpoint;
 import com.dumbhippo.server.views.Viewpoint;
 
 /**
@@ -42,6 +43,8 @@
 	
 	public List<FacebookEvent> getLatestEvents(Viewpoint viewpoint, FacebookAccount facebookAccount, int eventsCount);
 	
+	public void setApplicationEnabled(UserViewpoint viewpoint, FacebookAccount facebookAccount, Boolean applicationEnabled);
+	
 	public String getProfileLink(ExternalAccount externalAccount);
 	
 	public String getEventLink(FacebookEvent facebookEvent);

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java	2008-04-18 17:39:10 UTC (rev 7433)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java	2008-04-18 18:28:48 UTC (rev 7434)
@@ -158,7 +158,7 @@
 		}
 	}
 	
-	public void onFacebookApplicationEnabled(UserViewpoint viewpoint) {
+	public void onFacebookApplicationEnabledToggled(UserViewpoint viewpoint) {
 		try {
 			Block block = stacker.queryBlock(getKey(viewpoint.getViewer(), AccountQuestion.FACEBOOK_APPLICATION));
 			questionAnswered(viewpoint, block);
@@ -166,7 +166,7 @@
 			// No block, nothing to do
 		}		
 	}
-
+	
 	public void onMusicSharingToggled(UserViewpoint viewpoint) {
 		// Don't care
 	}
@@ -187,7 +187,7 @@
 				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);
+                	facebookSystem.setApplicationEnabled(viewpoint, facebookAccount, false);   
 			} catch (NotFoundException e) {
 				logger.warn("Did not find a FacebookAccount for user {} when trying to set their applicationEnabled status to false");
 			}

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java	2008-04-18 17:39:10 UTC (rev 7433)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountSystemBean.java	2008-04-18 18:28:48 UTC (rev 7434)
@@ -366,7 +366,7 @@
 		// We aren't interested in this, just part of a listener iface we're using
 	}
 
-	public void onFacebookApplicationEnabled(UserViewpoint viewpoint) {
+	public void onFacebookApplicationEnabledToggled(UserViewpoint viewpoint) {
 		// We aren't interested in this, just part of a listener iface we're using
 	}
 	

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookSystemBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookSystemBean.java	2008-04-18 17:39:10 UTC (rev 7433)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookSystemBean.java	2008-04-18 18:28:48 UTC (rev 7434)
@@ -32,9 +32,11 @@
 import com.dumbhippo.server.HippoProperty;
 import com.dumbhippo.server.IdentitySpider;
 import com.dumbhippo.server.NotFoundException;
+import com.dumbhippo.server.Notifier;
 import com.dumbhippo.server.Configuration.PropertyNotFoundException;
 import com.dumbhippo.server.util.EJBUtil;
 import com.dumbhippo.server.views.SystemViewpoint;
+import com.dumbhippo.server.views.UserViewpoint;
 import com.dumbhippo.server.views.Viewpoint;
 
 @Stateless
@@ -60,6 +62,9 @@
 	@EJB
 	private IdentitySpider identitySpider;
 	
+	@EJB
+	private Notifier notifier;
+	
 	public List<FacebookAccount> getAllAccounts() {
 		List<?> list = em.createQuery("SELECT fa FROM FacebookAccount fa").getResultList();
 		return TypeUtils.castList(FacebookAccount.class, list);
@@ -165,6 +170,15 @@
 		return list.subList(0, Math.min(eventsCount, list.size()));
 	}
 	
+	public void setApplicationEnabled(UserViewpoint viewpoint, FacebookAccount facebookAccount, Boolean applicationEnabled) {
+		if ((facebookAccount.isApplicationEnabled() != null && !facebookAccount.isApplicationEnabled().equals(applicationEnabled)) ||
+			(facebookAccount.isApplicationEnabled() == null && applicationEnabled != null))	
+		{ 
+	        facebookAccount.setApplicationEnabled(applicationEnabled);
+            notifier.onFacebookApplicationEnabledToggled(viewpoint);
+		}
+	}
+	
 	public String getProfileLink(ExternalAccount externalAccount) {
 		try {
 		    FacebookAccount facebookAccount = lookupFacebookAccount(externalAccount);

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java	2008-04-18 17:39:10 UTC (rev 7433)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java	2008-04-18 18:28:48 UTC (rev 7434)
@@ -228,12 +228,11 @@
 	    if (sessionKey != null)
 		    facebookAccount.setSessionKeyValid(true);	
 	    if (applicationEnabled != null)
-	        facebookAccount.setApplicationEnabled(applicationEnabled);
+	        facebookSystem.setApplicationEnabled(viewpoint, facebookAccount, applicationEnabled);
 	    // if you enabled Mugshot application on Facebook, you must have agreed to the Mugshot
 	    // terms of use there
 	    if (applicationEnabled != null && applicationEnabled) {
 	    	facebookAccount.getExternalAccount().getAccount().setHasAcceptedTerms(true);
-	        notifier.onFacebookApplicationEnabled(viewpoint);
 	    }
 	    
 		// make sure the sentiment is LOVE; there is currently no way to unset it from the user interface,

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/NotifierBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/NotifierBean.java	2008-04-18 17:39:10 UTC (rev 7433)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/NotifierBean.java	2008-04-18 18:28:48 UTC (rev 7434)
@@ -222,9 +222,9 @@
 		}
 	}
 
-	public void onFacebookApplicationEnabled(UserViewpoint viewpoint) {
+	public void onFacebookApplicationEnabledToggled(UserViewpoint viewpoint) {
 		for (AccountStatusListener l : getListeners(AccountStatusListener.class)) {
-			l.onFacebookApplicationEnabled(viewpoint);
+			l.onFacebookApplicationEnabledToggled(viewpoint);
 		}
 	}
 	

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/listeners/AccountStatusListener.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/listeners/AccountStatusListener.java	2008-04-18 17:39:10 UTC (rev 7433)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/listeners/AccountStatusListener.java	2008-04-18 18:28:48 UTC (rev 7434)
@@ -8,5 +8,5 @@
 	public void onAccountAdminDisabledToggled(Account account);
 	public void onMusicSharingToggled(UserViewpoint viewpoint);
 	public void onApplicationUsageToggled(UserViewpoint viewpoint);
-	public void onFacebookApplicationEnabled(UserViewpoint viewpoint);
+	public void onFacebookApplicationEnabledToggled(UserViewpoint viewpoint);
 }



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