r7367 - in dumbhippo/trunk: openfire/src/plugins/hippo/src/java/com/dumbhippo/jive openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/rooms server/src/com/dumbhippo/dm/schema



Author: otaylor
Date: 2008-03-18 12:51:07 -0500 (Tue, 18 Mar 2008)
New Revision: 7367

Modified:
   dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/MultiQueryIQMethod.java
   dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/rooms/Room.java
   dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassHolder.java
   dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassInfo.java
Log:
DMClassInfo DMClassHolder MultiQueryIQMethod: Handle creation of objects parametized
 with <K,T extends DMObject<T>> in a simpler, more Java 6 compatible fashion
Room.java: Return an appropriate response to IQ handlers (and don't throw a random
 sun-internal exception)


Modified: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/MultiQueryIQMethod.java
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/MultiQueryIQMethod.java	2008-03-17 20:16:26 UTC (rev 7366)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/MultiQueryIQMethod.java	2008-03-18 17:51:07 UTC (rev 7367)
@@ -71,20 +71,13 @@
 		
 		visitor.finish();
 	}
-	
-	// This "casts" two classes K and T to be related, note we need a K and a T in order to construct
-	// MultiQueryIQMethod without a warning about a bare type
+
 	@SuppressWarnings("unchecked")
-	private static <K, T extends DMObject<K>> MultiQueryIQMethod<K,T> newMultiQueryIQMethodHack(DMClassHolder<?,? extends DMObject<?>> classHolder,
+	public static MultiQueryIQMethod<?,?> getForClassInfo(DMClassInfo<?,?> classInfo,
 			AnnotatedIQHandler handler, Method method, IQMethod annotation) {
-		return new MultiQueryIQMethod<K,T>((DMClassHolder<K,T>)classHolder, handler, method, annotation);
-	}
-	
-	public static <K, T extends DMObject<K>> MultiQueryIQMethod<K,T> getForClassInfo(DMClassInfo<?,?> classInfo,
-			AnnotatedIQHandler handler, Method method, IQMethod annotation) {
 		DMClassHolder<?,?> classHolder = DataService.getModel().getClassHolder(classInfo.getObjectClass());
 		
-		return newMultiQueryIQMethodHack(classHolder, handler, method, annotation);
+		return new MultiQueryIQMethod(classHolder, handler, method, annotation);
 	}
 	
 	public static MultiQueryIQMethod<?,? extends DMObject<?>> getForMethod(AnnotatedIQHandler handler, Method method, IQMethod annotation) {

Modified: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/rooms/Room.java
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/rooms/Room.java	2008-03-17 20:16:26 UTC (rev 7366)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/rooms/Room.java	2008-03-18 17:51:07 UTC (rev 7367)
@@ -11,13 +11,13 @@
 import org.dom4j.Element;
 import org.jivesoftware.openfire.XMPPServer;
 import org.jivesoftware.util.Log;
+import org.xmpp.packet.IQ;
 import org.xmpp.packet.JID;
 import org.xmpp.packet.Message;
 import org.xmpp.packet.Packet;
+import org.xmpp.packet.PacketError;
 import org.xmpp.packet.Presence;
 
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
-
 import com.dumbhippo.Site;
 import com.dumbhippo.dm.DMObject;
 import com.dumbhippo.dm.ReadOnlySession;
@@ -698,8 +698,13 @@
 				processPresenceUnavailable(presence);
 		} else if (packet instanceof Message) {
 			processMessagePacket((Message)packet);
-		} else
-			throw new NotImplementedException();
+		} else if (packet instanceof IQ) {
+			IQ reply = IQ.createResultIQ((IQ) packet);
+			reply.setError(new PacketError(PacketError.Condition.bad_request, 
+					   PacketError.Type.modify, 
+					   "Room does not support IQs"));
+			XMPPServer.getInstance().getPacketRouter().route(reply);		
+		}
 	}
 	
 	/**

Modified: dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassHolder.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassHolder.java	2008-03-17 20:16:26 UTC (rev 7366)
+++ dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassHolder.java	2008-03-18 17:51:07 UTC (rev 7367)
@@ -853,16 +853,9 @@
 		}
 	}
 
-	// This "casts" two classes K and T to be related, note we need a K and a T in order to construct
-	// DMClassHolder without a warning about a bare type
 	@SuppressWarnings("unchecked")
-	private static <K, T extends DMObject<K>> DMClassHolder<K,T> newClassHolderHack(DataModel model, DMClassInfo<?,?> classInfo) {
-		return new DMClassHolder<K,T>(model, (DMClassInfo<K,T>) classInfo);
-	}
-	
-	
 	public static DMClassHolder<?, ? extends DMObject<?>> createForClass(DataModel model, Class<?> clazz) {
-		return newClassHolderHack(model, DMClassInfo.getForClass(clazz));
+		return new DMClassHolder(model, DMClassInfo.getForClass(clazz));
 	}
 	
 	private class PropertyGroup {

Modified: dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassInfo.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassInfo.java	2008-03-17 20:16:26 UTC (rev 7366)
+++ dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassInfo.java	2008-03-18 17:51:07 UTC (rev 7367)
@@ -23,26 +23,20 @@
 		return objectClass;
 	}
 
-	// This "casts" two classes K and T to be related, note we need a K and a T in order to construct
-	// DMClassInfo without a warning about a bare type
 	@SuppressWarnings("unchecked")
-	private static <K, T extends DMObject<K>> DMClassInfo<K,T> newClassInfoHack(Class<?> kClass, Class<?> tClass) {
-		return new DMClassInfo<K,T>((Class<K>)kClass, (Class<T>)tClass);
-	}
-	
 	public static DMClassInfo<?, ? extends DMObject<?>> getForClass(Class<?> tClass) {
 		if (!DMObject.class.isAssignableFrom(tClass))
 			return null;
 		
 		Constructor<?> constructor = findKeyConstructor(tClass);
 		Class<?> keyClass = constructor.getParameterTypes()[0]; 
-		return newClassInfoHack(keyClass, tClass);
+		return new DMClassInfo(keyClass, tClass);
 	}
 	
 	private static <ConstructedType> Constructor<ConstructedType> findKeyConstructor(Class<ConstructedType> clazz) {
 		Constructor<ConstructedType> keyConstructor = null;
 		
-		for (Constructor<ConstructedType> c : clazz.getDeclaredConstructors()) {
+		for (Constructor<?> c : clazz.getDeclaredConstructors()) {
 			Class<?>[] parameterTypes = c.getParameterTypes();
 			if (parameterTypes.length != 1)
 				continue;
@@ -59,7 +53,10 @@
 										   keyConstructor.toGenericString() + ", " +
 										   c.toGenericString());
 			
-			keyConstructor = c;
+			@SuppressWarnings("unchecked")
+			Constructor<ConstructedType> castConstructor = (Constructor<ConstructedType>)c; 
+			
+			keyConstructor = castConstructor;
 		}
 
 		if (keyConstructor == null)



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