r7273 - dumbhippo/trunk/server/src/com/dumbhippo/server/impl



Author: otaylor
Date: 2008-01-29 16:03:23 -0600 (Tue, 29 Jan 2008)
New Revision: 7273

Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java
Log:
Fix invalidations when adding AccountClaim and ContactClaim

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java	2008-01-28 20:23:32 UTC (rev 7272)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java	2008-01-29 22:03:23 UTC (rev 7273)
@@ -395,6 +395,31 @@
 		DataService.currentSessionRW().changed(ContactDMO.class, contact.getGuid(), "user");
 	}
 	
+	public void invalidateUserResource(User user, Resource resource) {
+		if (resource instanceof EmailResource) {
+			DataService.currentSessionRW().changed(UserDMO.class, user.getGuid(), "email");
+			DataService.currentSessionRW().changed(UserDMO.class, user.getGuid(), "emails");
+		} else if (resource instanceof AimResource) {
+			DataService.currentSessionRW().changed(UserDMO.class, user.getGuid(), "aim");
+			DataService.currentSessionRW().changed(UserDMO.class, user.getGuid(), "aims");
+		} else if (resource instanceof XmppResource) {
+			DataService.currentSessionRW().changed(UserDMO.class, user.getGuid(), "xmpp");
+			DataService.currentSessionRW().changed(UserDMO.class, user.getGuid(), "xmpps");
+		} else if (resource instanceof FacebookResource) {
+			DataService.currentSessionRW().changed(UserDMO.class, user.getGuid(), "facebook");
+		}
+	}
+	
+	public void invalidateContactResource(Contact contact, Resource resource) {
+		if (resource instanceof EmailResource) {
+			DataService.currentSessionRW().changed(ContactDMO.class, contact.getGuid(), "emails");
+		} else if (resource instanceof AimResource) {
+			DataService.currentSessionRW().changed(ContactDMO.class, contact.getGuid(), "aims");
+		} else if (resource instanceof XmppResource) {
+			DataService.currentSessionRW().changed(UserDMO.class, contact.getGuid(), "xmpps");
+		}
+	}
+	
 	public void addVerifiedOwnershipClaim(User claimedOwner, Resource res) {
 
 		// first be sure it isn't a dup - the db constraints check this too,
@@ -424,14 +449,7 @@
 		// fix up group memberships
 		groupSystem.fixupGroupMemberships(claimedOwner);
 		
-		if (res instanceof EmailResource)
-			DataService.currentSessionRW().changed(UserDMO.class, claimedOwner.getGuid(), "email");
-		else if (res instanceof AimResource)
-			DataService.currentSessionRW().changed(UserDMO.class, claimedOwner.getGuid(), "aim");
-		else if (res instanceof XmppResource)
-			DataService.currentSessionRW().changed(UserDMO.class, claimedOwner.getGuid(), "xmpp");
-		else if (res instanceof FacebookResource)
-			DataService.currentSessionRW().changed(UserDMO.class, claimedOwner.getGuid(), "facebook");
+		invalidateUserResource(claimedOwner, res);
 		
 		// People may have listed the newly claimed resource as a contact
 		Collection<Contact> newContacts = findResourceContacts(res);
@@ -470,16 +488,9 @@
 				res.setAccountClaim(null);
 				claims.remove(claim);
 				em.remove(claim);
+		
+				invalidateUserResource(owner, res);
 				
-				if (res instanceof EmailResource)
-					DataService.currentSessionRW().changed(UserDMO.class, owner.getGuid(), "email");
-				else if (res instanceof AimResource)
-					DataService.currentSessionRW().changed(UserDMO.class, owner.getGuid(), "aim");
-				else if (res instanceof XmppResource)
-					DataService.currentSessionRW().changed(UserDMO.class, owner.getGuid(), "xmpp");
-				else if (res instanceof FacebookResource)
-					DataService.currentSessionRW().changed(UserDMO.class, owner.getGuid(), "facebook");
-				
 				// People may have listed resource as a contact
 				if (!oldContacts.isEmpty()) {
 					LiveState.getInstance().invalidateContacters(owner.getGuid());
@@ -613,6 +624,8 @@
 			
 			invalidateContactUser(contact);
 		}
+		
+		invalidateContactResource(contact, resource);
 	}
 		
 	public void removeContactResource(Contact contact, Resource resource) {
@@ -639,6 +652,8 @@
 			invalidateContactUser(contact);
 		}
 		
+		invalidateContactResource(contact, resource);
+
 		// we could now have a 'bare' Contact with an empty set of resources
 	}
 	



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