r6928 - dumbhippo/trunk/server/src/com/dumbhippo/server/dm



Author: hp
Date: 2007-11-19 14:34:46 -0600 (Mon, 19 Nov 2007)
New Revision: 6928

Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ContactDMO.java
Log:
add more fallbacks for contact.name dmo property

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ContactDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ContactDMO.java	2007-11-19 20:10:12 UTC (rev 6927)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/ContactDMO.java	2007-11-19 20:34:46 UTC (rev 6928)
@@ -62,12 +62,36 @@
 		if (nick == null) {
 			UserDMO user = getUser();
 			if (user != null)
-				return user.getName();
-			else
-				return null;
-		} else {
-			return nick;
+				nick = user.getName();
 		}
+		
+		// It should be safe to fall back to a full address of 
+		// some kind, since the contact is only visible to 
+		// the person who added the contact
+		
+		if (nick == null) {
+			Set<String> emails = getEmails();
+			if (!emails.isEmpty())
+				nick = emails.iterator().next();
+		}
+		
+		if (nick == null) {
+			Set<String> xmpps = getXmpps();
+			if (!xmpps.isEmpty())
+				nick = xmpps.iterator().next();
+		}		
+		
+		if (nick == null) {
+			Set<String> aims = getAims();
+			if (!aims.isEmpty())
+				nick = aims.iterator().next();
+		}
+		
+		if (nick == null) {
+			nick = "NO NAME"; // should not happen
+		}
+		
+		return nick;
 	}
 	
 	private UserDMO getUserDMOFromAccount(Account account) {



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