Commit 3c4065d6 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Refactoring changes


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@598 b35dd754-fafc-0310-a699-88a17e54d16e
parent 4ca03095
...@@ -11,23 +11,28 @@ ...@@ -11,23 +11,28 @@
package org.jivesoftware.messenger.handler; package org.jivesoftware.messenger.handler;
import org.jivesoftware.messenger.container.TrackInfo; import org.jivesoftware.messenger.ChannelHandler;
import org.jivesoftware.messenger.IQHandlerInfo;
import org.jivesoftware.messenger.IQRouter;
import org.jivesoftware.messenger.PacketDeliverer;
import org.jivesoftware.messenger.PacketException;
import org.jivesoftware.messenger.Session;
import org.jivesoftware.messenger.SessionManager;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.container.BasicModule; import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.container.TrackInfo;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.*; import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.Packet; import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError; import org.xmpp.packet.PacketError;
import javax.xml.stream.XMLStreamException;
/** /**
* <p>Base class whose main responsibility is to handle IQ packets. Subclasses may only need to * <p>Base class whose main responsibility is to handle IQ packets. Subclasses may only need to
* specify the IQHandlerInfo (i.e. name and namespace of the packets to handle) and actually handle * specify the IQHandlerInfo (i.e. name and namespace of the packets to handle) and actually handle
* the IQ packet.</p> * the IQ packet.</p>
* * <p/>
* Simplifies creation of simple TYPE_IQ message handlers. * Simplifies creation of simple TYPE_IQ message handlers.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
...@@ -52,7 +57,7 @@ public abstract class IQHandler extends BasicModule implements ChannelHandler { ...@@ -52,7 +57,7 @@ public abstract class IQHandler extends BasicModule implements ChannelHandler {
} }
public void process(Packet packet) throws UnauthorizedException, PacketException { public void process(Packet packet) throws UnauthorizedException, PacketException {
IQ iq = (IQ)packet; IQ iq = (IQ) packet;
try { try {
iq = handleIQ(iq); iq = handleIQ(iq);
if (iq != null) { if (iq != null) {
...@@ -71,13 +76,8 @@ public abstract class IQHandler extends BasicModule implements ChannelHandler { ...@@ -71,13 +76,8 @@ public abstract class IQHandler extends BasicModule implements ChannelHandler {
} }
catch (Exception de) { catch (Exception de) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), de); Log.error(LocaleUtils.getLocalizedString("admin.error"), de);
try {
SessionManager.getInstance().getSession(iq.getFrom()).getConnection().close(); SessionManager.getInstance().getSession(iq.getFrom()).getConnection().close();
} }
catch (SessionNotFoundException se) {
// do nothing
}
}
} }
} }
catch (Exception e) { catch (Exception e) {
...@@ -92,13 +92,14 @@ public abstract class IQHandler extends BasicModule implements ChannelHandler { ...@@ -92,13 +92,14 @@ public abstract class IQHandler extends BasicModule implements ChannelHandler {
* @return the response to send back. * @return the response to send back.
* @throws UnauthorizedException If the user that sent the packet is not authorized to request * @throws UnauthorizedException If the user that sent the packet is not authorized to request
* the given operation. * the given operation.
* @throws XMLStreamException If there was trouble reading the stream. * @throws org.xmlpull.v1.XmlPullParserException
* If there was trouble reading the stream.
*/ */
public abstract IQ handleIQ(IQ packet) throws UnauthorizedException, XMLStreamException; public abstract IQ handleIQ(IQ packet) throws UnauthorizedException, XmlPullParserException;
/** /**
* <p>Obtain the handler information to help generically handle IQ packets.</p> * <p>Obtain the handler information to help generically handle IQ packets.</p>
* * <p/>
* <p>IQHandlers that aren't local server iq handlers (e.g. chatbots, transports, etc) * <p>IQHandlers that aren't local server iq handlers (e.g. chatbots, transports, etc)
* return a null.</p> * return a null.</p>
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment