r7078 - in dumbhippo/trunk: openfire/src/plugins/hippo/src/java/com/dumbhippo/jive server/src/com/dumbhippo/server server/src/com/dumbhippo/server/impl
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7078 - in dumbhippo/trunk: openfire/src/plugins/hippo/src/java/com/dumbhippo/jive server/src/com/dumbhippo/server server/src/com/dumbhippo/server/impl
- Date: Tue, 18 Dec 2007 15:15:35 -0600 (CST)
Author: hp
Date: 2007-12-18 15:15:34 -0600 (Tue, 18 Dec 2007)
New Revision: 7078
Modified:
dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/ContactsIQHandler.java
dumbhippo/trunk/server/src/com/dumbhippo/server/IdentitySpider.java
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java
Log:
add setContactName IQ
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 2007-12-18 20:43:37 UTC (rev 7077)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/ContactsIQHandler.java 2007-12-18 21:15:34 UTC (rev 7078)
@@ -2,8 +2,6 @@
import org.xmpp.packet.IQ;
-import com.dumbhippo.dm.DMSession;
-import com.dumbhippo.dm.DataModel;
import com.dumbhippo.jive.annotations.IQHandler;
import com.dumbhippo.jive.annotations.IQMethod;
import com.dumbhippo.persistence.Contact;
@@ -13,8 +11,8 @@
import com.dumbhippo.persistence.ValidationException;
import com.dumbhippo.server.IdentitySpider;
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;
@@ -185,4 +183,20 @@
identitySpider.deleteContact(viewpoint.getViewer(), contact);
}
+
+ @IQMethod(name="setContactName", type=IQ.Type.set)
+ @IQParams({ "contact", "name" })
+ public void setContactName(UserViewpoint viewpoint, ContactDMO contactDMO, String name) throws IQException, RetryException {
+ IdentitySpider identitySpider = EJBUtil.defaultLookup(IdentitySpider.class);
+
+ Contact contact = identitySpider.lookupContact(contactDMO.getKey());
+ if (contact == null)
+ throw IQException.createBadRequest("Unknown contact " + contactDMO.getKey());
+
+ try {
+ identitySpider.setContactName(viewpoint, contact, name);
+ } catch (PermissionDeniedException e) {
+ throw IQException.createBadRequest("Permission denied to change contact");
+ }
+ }
}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/IdentitySpider.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/IdentitySpider.java 2007-12-18 20:43:37 UTC (rev 7077)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/IdentitySpider.java 2007-12-18 21:15:34 UTC (rev 7078)
@@ -266,6 +266,8 @@
public void setContactStatus(UserViewpoint viewpoint, Contact contact, ContactStatus status);
+ public void setContactName(UserViewpoint viewpoint, Contact contact, String name) throws PermissionDeniedException;
+
/**
* Get all Contact objects associated with a given user. "Get my address book entries."
* Not all Contact in the list will have an associated User
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java 2007-12-18 20:43:37 UTC (rev 7077)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/IdentitySpiderBean.java 2007-12-18 21:15:34 UTC (rev 7078)
@@ -63,6 +63,7 @@
import com.dumbhippo.server.IdentitySpiderRemote;
import com.dumbhippo.server.NotFoundException;
import com.dumbhippo.server.Notifier;
+import com.dumbhippo.server.PermissionDeniedException;
import com.dumbhippo.server.RevisionControl;
import com.dumbhippo.server.dm.ContactDMO;
import com.dumbhippo.server.dm.DataService;
@@ -741,6 +742,15 @@
}
}
+ public void setContactName(UserViewpoint viewpoint, Contact contact, String name) throws PermissionDeniedException {
+ if (!contact.getAccount().getOwner().equals(viewpoint.getViewer())) {
+ throw new PermissionDeniedException("Can't change someone else's contact's name");
+ }
+ name = name.trim();
+ contact.setNickname(name);
+ DataService.currentSessionRW().changed(ContactDMO.class, contact.getGuid(), "name");
+ }
+
// get all contacts, even if they have no user
public Set<Guid> computeContacts(Guid userId) {
User user = em.find(User.class, userId.toString());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]