r7489 - in dumbhippo/trunk/server/src/com/dumbhippo: persistence server/dm server/impl



Author: marinaz
Date: 2008-06-24 12:06:38 -0500 (Tue, 24 Jun 2008)
New Revision: 7489

Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ExternalAccountDMO.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountChangePropagatorBean.java
Log:
Add a username property to the ExternalAccountDMO.


Modified: dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java	2008-06-18 15:16:00 UTC (rev 7488)
+++ dumbhippo/trunk/server/src/com/dumbhippo/persistence/ExternalAccount.java	2008-06-24 17:06:38 UTC (rev 7489)
@@ -257,6 +257,23 @@
 			throw new RuntimeException("Unexpected info source in ExternalAccount::getAccountInfo()");
 		}
 	}
+
+        // This function is used for exporting the username via the data model. Over time we'll figure out what 
+        // makes sense to return for accounts that have other info sources, such as Google Reader, Amazon, Rhapsody,
+        // Netflix, and Facebook. The user info that we require for them right now is different from a username
+        // or e-mail used by users for that service, and can make the most sense to the user in the form of a url,
+        // which they can copy and paste into the browser to verify that it's their account.  
+	@Transient
+	public String getUsername() {
+		switch (accountType.getInfoSource()) {
+		case HANDLE:
+			return getHandle();
+		case EXTRA:
+			return getExtra();
+		default:
+			return null;
+		}
+	}
 	
 	@Transient
 	public boolean isLovedAndEnabled() {

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java	2008-06-18 15:16:00 UTC (rev 7488)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java	2008-06-24 17:06:38 UTC (rev 7489)
@@ -32,6 +32,7 @@
 import com.dumbhippo.server.Stacker;
 import com.dumbhippo.server.blocks.BlockView;
 import com.dumbhippo.server.blocks.EntitySourceBlockView;
+import com.dumbhippo.server.blocks.FacebookBlockView;
 import com.dumbhippo.server.blocks.MusicPersonBlockView;
 import com.dumbhippo.server.blocks.TitleBlockView;
 import com.dumbhippo.server.blocks.TitleDescriptionBlockView;
@@ -212,13 +213,19 @@
 	@DMProperty(defaultInclude=true, defaultChildren="+")
 	public UserDMO getSourceUser() {
 		if (blockView instanceof EntitySourceBlockView) {
+			if (blockView instanceof FacebookBlockView)
+				logger.debug("Will get the user source for a FacebookBlockView!!");
 			/* User sources might be returned even for EntitySourceBlockView's that aren't
 			 * PersonSourceView; for example, PostBlockView, when posted by a user, instead
 			 * of a feed. 
 			 */
 			EntityView entityView = ((EntitySourceBlockView)blockView).getEntitySource();
+			if (blockView instanceof FacebookBlockView)
+				logger.debug("got entityView");			
 			if (entityView instanceof PersonView) {
 				User user = ((PersonView)entityView).getUser();
+				if (blockView instanceof FacebookBlockView)   
+				    logger.debug("user is {}", user);
 				if (user != null)
 					return session.findUnchecked(UserDMO.class, user.getGuid());
 			}

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ExternalAccountDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ExternalAccountDMO.java	2008-06-18 15:16:00 UTC (rev 7488)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ExternalAccountDMO.java	2008-06-24 17:06:38 UTC (rev 7489)
@@ -86,6 +86,11 @@
 	public String getIconUrl() {
 		return "/images3/" + externalAccount.getIconName();
 	}
+
+	@DMProperty(defaultInclude=true)
+	public String getUsername() {
+		return externalAccount.getUsername();
+	}
 	
 	@DMProperty
 	public List<ThumbnailDMO> getThumbnails() {

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountChangePropagatorBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountChangePropagatorBean.java	2008-06-18 15:16:00 UTC (rev 7488)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ExternalAccountChangePropagatorBean.java	2008-06-24 17:06:38 UTC (rev 7489)
@@ -32,7 +32,8 @@
 
 	public void onExternalAccountLovedAndEnabledMaybeChanged(User user, ExternalAccount external) {
 		DataService.currentSessionRW().changed(UserDMO.class, user.getGuid(), "lovedAccounts");
-		DataService.currentSessionRW().changed(ExternalAccountDMO.class, new ExternalAccountKey(external), "link");
+		DataService.currentSessionRW().changed(ExternalAccountDMO.class, new ExternalAccountKey(external), "link");
+                DataService.currentSessionRW().changed(ExternalAccountDMO.class, new ExternalAccountKey(external), "username");
 		notify(user, external);
 	}
 }



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