r7301 - in dumbhippo/trunk: openfire/src/plugins/hippo/src/java/com/dumbhippo/jive server/src/com/dumbhippo/server/impl



Author: otaylor
Date: 2008-02-08 16:31:31 -0600 (Fri, 08 Feb 2008)
New Revision: 7301

Modified:
   dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/ContactsIQHandler.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java
Log:
IdentitySpiderBean: Fix notification when deleting contacts
ContactsIQHandler: Return the newly created contact from createContact[User] IQ's


Modified: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/ContactsIQHandler.java
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/ContactsIQHandler.java	2008-02-08 20:12:24 UTC (rev 7300)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/ContactsIQHandler.java	2008-02-08 22:31:31 UTC (rev 7301)
@@ -2,6 +2,7 @@
 
 import org.xmpp.packet.IQ;
 
+import com.dumbhippo.dm.DMSession;
 import com.dumbhippo.jive.annotations.IQHandler;
 import com.dumbhippo.jive.annotations.IQMethod;
 import com.dumbhippo.persistence.Contact;
@@ -14,6 +15,7 @@
 import com.dumbhippo.server.NotFoundException;
 import com.dumbhippo.server.PermissionDeniedException;
 import com.dumbhippo.server.dm.ContactDMO;
+import com.dumbhippo.server.dm.DataService;
 import com.dumbhippo.server.dm.UserDMO;
 import com.dumbhippo.server.util.EJBUtil;
 import com.dumbhippo.server.views.UserViewpoint;
@@ -154,27 +156,28 @@
 	
 	@IQMethod(name="createContact", type=IQ.Type.set)
 	@IQParams({ "addressType", "address" })
-	public void createContact(UserViewpoint viewpoint, String addressType, String address) throws IQException, RetryException {
+	public ContactDMO createContact(UserViewpoint viewpoint, String addressType, String address) throws IQException, RetryException {
 		IdentitySpider identitySpider = EJBUtil.defaultLookup(IdentitySpider.class);
 		
 		AddressType a = parseAddressType(addressType);
 		Resource resource = getResourceFromAddress(identitySpider, a, address);
 		
 		Contact contact = identitySpider.createContact(viewpoint.getViewer(), resource);
-		// FIXME we aren't allowed to return a value, but it will be hard for the caller to figure out 
-		// what contact was created
 		
+		DMSession session = DataService.currentSessionRW();
+		return session.findUnchecked(ContactDMO.class, contact.getGuid());
 	}
 	
 	@IQMethod(name="createUserContact", type=IQ.Type.set)
 	@IQParams({ "user" })
-	public void createUserContact(UserViewpoint viewpoint, UserDMO userDMO) throws IQException, RetryException {
+	public ContactDMO createUserContact(UserViewpoint viewpoint, UserDMO userDMO) throws IQException, RetryException {
 		IdentitySpider identitySpider = EJBUtil.defaultLookup(IdentitySpider.class);
 		
 		User user = identitySpider.lookupUser(userDMO.getKey());
 		Contact contact = identitySpider.createContact(viewpoint.getViewer(), user.getAccount());
-		// FIXME we aren't allowed to return a value, but it will be hard for the caller to figure out 
-		// what contact was created
+
+		DMSession session = DataService.currentSessionRW();
+		return session.findUnchecked(ContactDMO.class, contact.getGuid());
 	}
 	
 	@IQMethod(name="deleteContact", type=IQ.Type.set)

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java	2008-02-08 20:12:24 UTC (rev 7300)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java	2008-02-08 22:31:31 UTC (rev 7301)
@@ -884,11 +884,16 @@
 		em.remove(contact);
 		logger.debug("contact deleted");
 
-		LiveState liveState = LiveState.getInstance();
-		liveState.invalidateContacts(user.getGuid());
-		for (User removedUser : removedUsers) {
-			invalidateContactStatus(user, removedUser);
-			invalidateContacters(removedUser);
+		DataService.currentSessionRW().removed(ContactDMO.class, contact.getGuid());
+		invalidateContacts(user);
+		
+		if (!removedUsers.isEmpty()) {
+			invalidateUserContacts(user);
+
+			for (User removedUser : removedUsers) {
+				invalidateContactStatus(user, removedUser);
+				invalidateContacters(removedUser);
+			}
 		}
 	}
 	



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