r7184 - in dumbhippo/trunk: openfire/src/plugins/hippo/src/java/com/dumbhippo/jive server/src/com/dumbhippo/server/dm



Author: otaylor
Date: 2008-01-10 17:22:48 -0600 (Thu, 10 Jan 2008)
New Revision: 7184

Added:
   dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupsIQHandler.java
   dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/OldGroupIQHandler.java
Removed:
   dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupIQHandler.java
Modified:
   dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/BlocksIQHandler.java
   dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/HippoPlugin.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PostDMO.java
Log:
Add new data-model IQ's for:
 - Ignoring a block
 - Account question response
 - Inviting a user to a group

Add PostDMO.visitUrl to avoid having to construct mugshot.org URL's in the client
  when clicking on a post.


Modified: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/BlocksIQHandler.java
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/BlocksIQHandler.java	2008-01-10 22:49:14 UTC (rev 7183)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/BlocksIQHandler.java	2008-01-10 23:22:48 UTC (rev 7184)
@@ -9,11 +9,15 @@
 import org.xmpp.packet.IQ;
 
 import com.dumbhippo.dm.DMSession;
+import com.dumbhippo.identity20.Guid;
 import com.dumbhippo.jive.annotations.IQHandler;
 import com.dumbhippo.jive.annotations.IQMethod;
 import com.dumbhippo.persistence.Block;
+import com.dumbhippo.persistence.UserBlockData;
 import com.dumbhippo.server.NotFoundException;
 import com.dumbhippo.server.Stacker;
+import com.dumbhippo.server.blocks.AccountQuestionBlockHandler;
+import com.dumbhippo.server.blocks.AccountQuestionBlockHandler.BadResponseCodeException;
 import com.dumbhippo.server.dm.BlockDMO;
 import com.dumbhippo.server.dm.BlockDMOKey;
 import com.dumbhippo.server.dm.DataService;
@@ -24,6 +28,9 @@
 	static final String BLOCKS_NAMESPACE = "http://mugshot.org/p/blocks";; 
 	
 	@EJB
+	private AccountQuestionBlockHandler accountQuestionBlockHandler;
+	
+	@EJB
 	private Stacker stacker;
 	
 	public BlocksIQHandler() {
@@ -56,4 +63,29 @@
 	public void setStackFilter(UserViewpoint viewpoint, String filter) throws IQException {
 		stacker.setUserStackFilterPrefs(viewpoint.getViewer(), filter);
 	}
+
+	@IQMethod(name="setBlockHushed", type=IQ.Type.set)
+	@IQParams({ "blockId", "hushed" })
+	public void setBlockHushed(UserViewpoint viewpoint, Guid blockId, boolean hushed) throws IQException {
+        UserBlockData userBlockData;
+        try {
+			userBlockData = stacker.lookupUserBlockData(viewpoint, blockId);
+		} catch (NotFoundException e) {
+        	throw IQException.createBadRequest("blockId attribute doesn't refer to a recognized block for this user");
+		}
+        
+        stacker.setBlockHushed(userBlockData, hushed);
+	}
+	
+	@IQMethod(name="accountQuestionResponse", type=IQ.Type.set)
+	@IQParams({ "blockId", "response" })
+	public void accountQuestionResponse(UserViewpoint viewpoint, Guid blockId, String response) throws IQException {
+        try {
+			accountQuestionBlockHandler.handleResponse(viewpoint, blockId, response);
+		} catch (NotFoundException e) {
+			throw IQException.createBadRequest("blockId attribute doesn't point to a question for this user");
+		} catch (BadResponseCodeException e) {
+			throw IQException.createBadRequest("response attribute had an expected value");
+		}
+	}
 }

Deleted: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupIQHandler.java
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupIQHandler.java	2008-01-10 22:49:14 UTC (rev 7183)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupIQHandler.java	2008-01-10 23:22:48 UTC (rev 7184)
@@ -1,63 +0,0 @@
-package com.dumbhippo.jive;
-
-import org.dom4j.Element;
-import org.jivesoftware.util.Log;
-import org.jivesoftware.openfire.IQHandlerInfo;
-import org.jivesoftware.openfire.auth.UnauthorizedException;
-import org.xmpp.packet.IQ;
-import org.xmpp.packet.JID;
-import org.xmpp.packet.PacketError.Condition;
-
-import com.dumbhippo.identity20.Guid;
-import com.dumbhippo.identity20.Guid.ParseException;
-import com.dumbhippo.server.MessengerGlue;
-import com.dumbhippo.server.NotFoundException;
-import com.dumbhippo.server.util.EJBUtil;
-
-public class GroupIQHandler extends AbstractIQHandler {
-
-	private IQHandlerInfo info;
-	
-	public GroupIQHandler() {
-		super("DumbHippo Group IQ Handler");
-		
-		Log.debug("creating Group handler");
-		info = new IQHandlerInfo("groupSystem", "http://dumbhippo.com/protocol/groupSystem";);
-	}
-
-	@Override
-	public IQ handleIQ(IQ packet) throws UnauthorizedException {
-		
-		Log.debug("handling IQ packet " + packet);
-		JID from = packet.getFrom();
-		IQ reply = IQ.createResultIQ(packet);
-		
-		Element element = packet.getChildElement();
-		String type = element.attributeValue("op");		
-		String groupId = element.attributeValue("groupId");
-		String userId = element.attributeValue("userId");
-		
-		MessengerGlue glue = EJBUtil.defaultLookup(MessengerGlue.class);
-		if (type.equals("addMember")) {
-			try {
-				glue.addGroupMember(Guid.parseTrustedJabberId(from.getNode()), 
-								    new Guid(groupId), new Guid(userId));
-			} catch (NotFoundException e) {
-				Log.error(e);
-				reply.setError(Condition.internal_server_error);
-			} catch (ParseException e) {
-				Log.error(e);
-				reply.setError(Condition.internal_server_error);
-			}
-		} else {
-			reply.setError(Condition.item_not_found);
-		}
-		
-		return reply;
-	}
-
-	@Override
-	public IQHandlerInfo getInfo() {
-		return info;
-	}
-}

Copied: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupsIQHandler.java (from rev 7169, dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupIQHandler.java)
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupIQHandler.java	2008-01-10 03:26:26 UTC (rev 7169)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupsIQHandler.java	2008-01-10 23:22:48 UTC (rev 7184)
@@ -0,0 +1,34 @@
+package com.dumbhippo.jive;
+
+import javax.ejb.EJB;
+
+import org.xmpp.packet.IQ;
+
+import com.dumbhippo.identity20.Guid;
+import com.dumbhippo.jive.annotations.IQHandler;
+import com.dumbhippo.jive.annotations.IQMethod;
+import com.dumbhippo.server.MessengerGlue;
+import com.dumbhippo.server.NotFoundException;
+import com.dumbhippo.server.views.UserViewpoint;
+
+ IQHandler(namespace=GroupsIQHandler.GROUPS_NAMESPACE)
+public class GroupsIQHandler extends AnnotatedIQHandler {
+	static final String GROUPS_NAMESPACE = "http://mugshot.org/p/groups";; 
+	
+	@EJB
+	private MessengerGlue glue;
+	
+	public GroupsIQHandler() {
+		super("Mugshot Groups IQ Handler");
+	}
+	
+	@IQMethod(name="inviteUser", type=IQ.Type.set)
+	@IQParams({ "groupId", "userId" })
+	public void inviteUser(UserViewpoint viewpoint, Guid groupId, Guid userId) throws IQException {
+        try {
+			glue.addGroupMember(viewpoint.getViewer().getGuid(), groupId, userId);
+		} catch (NotFoundException e) {
+			throw IQException.createBadRequest("bad groupId or userId parameter");
+		}
+	}
+}

Modified: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/HippoPlugin.java
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/HippoPlugin.java	2008-01-10 22:49:14 UTC (rev 7183)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/HippoPlugin.java	2008-01-10 23:22:48 UTC (rev 7184)
@@ -90,7 +90,8 @@
 			addIQHandler(new HotnessIQHandler());	
 			addIQHandler(new RecentPostsIQHandler());
 			addIQHandler(new PostControlsIQHandler());
-			addIQHandler(new GroupIQHandler());	
+			addIQHandler(new OldGroupIQHandler());	
+			addIQHandler(new GroupsIQHandler());	
 			addIQHandler(new OldBlocksIQHandler());
 			addIQHandler(new BlocksIQHandler());
 			addIQHandler(new AccountQuestionIQHandler());

Copied: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/OldGroupIQHandler.java (from rev 7169, dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupIQHandler.java)
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/GroupIQHandler.java	2008-01-10 03:26:26 UTC (rev 7169)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/OldGroupIQHandler.java	2008-01-10 23:22:48 UTC (rev 7184)
@@ -0,0 +1,63 @@
+package com.dumbhippo.jive;
+
+import org.dom4j.Element;
+import org.jivesoftware.util.Log;
+import org.jivesoftware.openfire.IQHandlerInfo;
+import org.jivesoftware.openfire.auth.UnauthorizedException;
+import org.xmpp.packet.IQ;
+import org.xmpp.packet.JID;
+import org.xmpp.packet.PacketError.Condition;
+
+import com.dumbhippo.identity20.Guid;
+import com.dumbhippo.identity20.Guid.ParseException;
+import com.dumbhippo.server.MessengerGlue;
+import com.dumbhippo.server.NotFoundException;
+import com.dumbhippo.server.util.EJBUtil;
+
+public class OldGroupIQHandler extends AbstractIQHandler {
+
+	private IQHandlerInfo info;
+	
+	public OldGroupIQHandler() {
+		super("DumbHippo Group IQ Handler");
+		
+		Log.debug("creating Group handler");
+		info = new IQHandlerInfo("groupSystem", "http://dumbhippo.com/protocol/groupSystem";);
+	}
+
+	@Override
+	public IQ handleIQ(IQ packet) throws UnauthorizedException {
+		
+		Log.debug("handling IQ packet " + packet);
+		JID from = packet.getFrom();
+		IQ reply = IQ.createResultIQ(packet);
+		
+		Element element = packet.getChildElement();
+		String type = element.attributeValue("op");		
+		String groupId = element.attributeValue("groupId");
+		String userId = element.attributeValue("userId");
+		
+		MessengerGlue glue = EJBUtil.defaultLookup(MessengerGlue.class);
+		if (type.equals("addMember")) {
+			try {
+				glue.addGroupMember(Guid.parseTrustedJabberId(from.getNode()), 
+								    new Guid(groupId), new Guid(userId));
+			} catch (NotFoundException e) {
+				Log.error(e);
+				reply.setError(Condition.internal_server_error);
+			} catch (ParseException e) {
+				Log.error(e);
+				reply.setError(Condition.internal_server_error);
+			}
+		} else {
+			reply.setError(Condition.item_not_found);
+		}
+		
+		return reply;
+	}
+
+	@Override
+	public IQHandlerInfo getInfo() {
+		return info;
+	}
+}

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PostDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PostDMO.java	2008-01-10 22:49:14 UTC (rev 7183)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PostDMO.java	2008-01-10 23:22:48 UTC (rev 7184)
@@ -22,6 +22,7 @@
 import com.dumbhippo.persistence.PostVisibility;
 import com.dumbhippo.persistence.Resource;
 import com.dumbhippo.persistence.User;
+import com.dumbhippo.server.Configuration;
 import com.dumbhippo.server.NotFoundException;
 import com.dumbhippo.server.PostingBoard;
 import com.dumbhippo.server.views.SystemViewpoint;
@@ -31,6 +32,9 @@
 @DMFilter("viewer.canSeePost(this)")
 public abstract class PostDMO extends DMObject<Guid> {
 	@EJB
+	Configuration configuration; 
+
+	@EJB
 	PostingBoard postingBoard; 
 	
 	@Inject
@@ -83,6 +87,12 @@
 		return post.getUrl().toString();
 	}
 	
+	@DMProperty(defaultInclude=true, type=PropertyType.URL)
+	public String getVisitUrl() {
+		// Viewing shares and group feeds is always a Mugshot thing, not a online.gnome.org thing
+		return configuration.getBaseUrlMugshot() + "/visit?post=" + post.getId();
+	}
+	
 	@DMProperty(defaultInclude=true)
 	public long getDate() {
 		return post.getPostDate().getTime();



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