Commit adaa8196 authored by Guus der Kinderen's avatar Guus der Kinderen

Added debug logging.

parent 8028f7db
...@@ -16,7 +16,8 @@ import org.jivesoftware.database.DbConnectionManager; ...@@ -16,7 +16,8 @@ import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.archive.ConversationManager; import org.jivesoftware.openfire.archive.ConversationManager;
import org.jivesoftware.util.JiveConstants; import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import com.reucon.openfire.plugin.archive.ArchivedMessageConsumer; import com.reucon.openfire.plugin.archive.ArchivedMessageConsumer;
...@@ -31,6 +32,7 @@ import com.reucon.openfire.plugin.archive.xep0059.XmppResultSet; ...@@ -31,6 +32,7 @@ import com.reucon.openfire.plugin.archive.xep0059.XmppResultSet;
* Manages database persistence. * Manages database persistence.
*/ */
public class JdbcPersistenceManager implements PersistenceManager { public class JdbcPersistenceManager implements PersistenceManager {
private static final Logger Log = LoggerFactory.getLogger( JdbcPersistenceManager.class );
public static final int DEFAULT_MAX = 1000; public static final int DEFAULT_MAX = 1000;
public static final String SELECT_MESSAGES_BY_CONVERSATION = "SELECT DISTINCT " + "ofConversation.conversationID, " + "ofConversation.room, " public static final String SELECT_MESSAGES_BY_CONVERSATION = "SELECT DISTINCT " + "ofConversation.conversationID, " + "ofConversation.room, "
...@@ -422,6 +424,9 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -422,6 +424,9 @@ public class JdbcPersistenceManager implements PersistenceManager {
@Override @Override
public Collection<ArchivedMessage> findMessages(Date startDate, public Collection<ArchivedMessage> findMessages(Date startDate,
Date endDate, String ownerJid, String withJid, XmppResultSet xmppResultSet) { Date endDate, String ownerJid, String withJid, XmppResultSet xmppResultSet) {
Log.debug( "Finding messages of owner '{}' with start date '{}', end date '{}' with '{}' and resultset '{}'.", new Object[] { ownerJid, startDate, endDate, withJid, xmppResultSet } );
final boolean isOracleDB = isOracleDB(); final boolean isOracleDB = isOracleDB();
final StringBuilder querySB; final StringBuilder querySB;
......
...@@ -7,6 +7,8 @@ import java.util.Iterator; ...@@ -7,6 +7,8 @@ import java.util.Iterator;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.openfire.auth.UnauthorizedException; import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.disco.ServerFeaturesProvider; import org.jivesoftware.openfire.disco.ServerFeaturesProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
...@@ -21,6 +23,7 @@ import com.reucon.openfire.plugin.archive.xep0059.XmppResultSet; ...@@ -21,6 +23,7 @@ import com.reucon.openfire.plugin.archive.xep0059.XmppResultSet;
public class IQListHandler extends AbstractIQHandler implements public class IQListHandler extends AbstractIQHandler implements
ServerFeaturesProvider { ServerFeaturesProvider {
private static final Logger Log = LoggerFactory.getLogger( IQListHandler.class );
private static final String NAMESPACE = "urn:xmpp:archive"; private static final String NAMESPACE = "urn:xmpp:archive";
private static final String NAMESPACE_MANAGE = "urn:xmpp:archive:manage"; private static final String NAMESPACE_MANAGE = "urn:xmpp:archive:manage";
...@@ -32,9 +35,11 @@ public class IQListHandler extends AbstractIQHandler implements ...@@ -32,9 +35,11 @@ public class IQListHandler extends AbstractIQHandler implements
IQ reply = IQ.createResultIQ(packet); IQ reply = IQ.createResultIQ(packet);
ListRequest listRequest = new ListRequest(packet.getChildElement()); ListRequest listRequest = new ListRequest(packet.getChildElement());
JID from = packet.getFrom(); JID from = packet.getFrom();
Log.debug( "Processing a request to retrieve lists. Requestor: {}", from );
Element listElement = reply.setChildElement("list", NAMESPACE); Element listElement = reply.setChildElement("list", NAMESPACE);
Collection<Conversation> conversations = list(from, listRequest); Collection<Conversation> conversations = list(from, listRequest);
Log.debug( "Retrieved {} conversations for requestor {}", conversations.size(), from );
XmppResultSet resultSet = listRequest.getResultSet(); XmppResultSet resultSet = listRequest.getResultSet();
for (Conversation conversation : conversations) { for (Conversation conversation : conversations) {
...@@ -44,7 +49,7 @@ public class IQListHandler extends AbstractIQHandler implements ...@@ -44,7 +49,7 @@ public class IQListHandler extends AbstractIQHandler implements
if (resultSet != null) { if (resultSet != null) {
listElement.add(resultSet.createResultElement()); listElement.add(resultSet.createResultElement());
} }
Log.debug( "Finished processing a request to retrieve lists. Requestor: {}", from );
return reply; return reply;
} }
......
...@@ -3,6 +3,8 @@ package com.reucon.openfire.plugin.archive.xep0136; ...@@ -3,6 +3,8 @@ package com.reucon.openfire.plugin.archive.xep0136;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.openfire.auth.UnauthorizedException; import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.disco.ServerFeaturesProvider; import org.jivesoftware.openfire.disco.ServerFeaturesProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import com.reucon.openfire.plugin.archive.xep.AbstractIQHandler; import com.reucon.openfire.plugin.archive.xep.AbstractIQHandler;
...@@ -16,7 +18,7 @@ import java.util.List; ...@@ -16,7 +18,7 @@ import java.util.List;
*/ */
public class IQPrefHandler extends AbstractIQHandler implements ServerFeaturesProvider public class IQPrefHandler extends AbstractIQHandler implements ServerFeaturesProvider
{ {
private static final Logger Log = LoggerFactory.getLogger( IQPrefHandler.class );
private static final String NAMESPACE = "urn:xmpp:archive"; private static final String NAMESPACE = "urn:xmpp:archive";
private static final String NAMESPACE_PREF = "urn:xmpp:archive:pref"; private static final String NAMESPACE_PREF = "urn:xmpp:archive:pref";
...@@ -31,7 +33,7 @@ public class IQPrefHandler extends AbstractIQHandler implements ServerFeaturesPr ...@@ -31,7 +33,7 @@ public class IQPrefHandler extends AbstractIQHandler implements ServerFeaturesPr
IQ reply = IQ.createResultIQ(packet); IQ reply = IQ.createResultIQ(packet);
Element prefRequest = packet.getChildElement(); Element prefRequest = packet.getChildElement();
System.err.println("Received pref message from " + packet.getFrom()); Log.debug("Received pref request from {}", packet.getFrom());
if (prefRequest.element("default") != null) if (prefRequest.element("default") != null)
{ {
......
...@@ -7,6 +7,8 @@ import com.reucon.openfire.plugin.archive.xep.AbstractIQHandler; ...@@ -7,6 +7,8 @@ import com.reucon.openfire.plugin.archive.xep.AbstractIQHandler;
import com.reucon.openfire.plugin.archive.xep0059.XmppResultSet; import com.reucon.openfire.plugin.archive.xep0059.XmppResultSet;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.openfire.auth.UnauthorizedException; import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError; import org.xmpp.packet.PacketError;
...@@ -18,6 +20,7 @@ import java.util.List; ...@@ -18,6 +20,7 @@ import java.util.List;
*/ */
public class IQRetrieveHandler extends AbstractIQHandler { public class IQRetrieveHandler extends AbstractIQHandler {
private static final Logger Log = LoggerFactory.getLogger( IQRetrieveHandler.class );
private static final String NAMESPACE = "urn:xmpp:archive"; private static final String NAMESPACE = "urn:xmpp:archive";
public IQRetrieveHandler() { public IQRetrieveHandler() {
...@@ -32,9 +35,12 @@ public class IQRetrieveHandler extends AbstractIQHandler { ...@@ -32,9 +35,12 @@ public class IQRetrieveHandler extends AbstractIQHandler {
int toIndex; // exclusive int toIndex; // exclusive
int max; int max;
Log.debug( "Processing a request to retrieve a conversation. Requestor: "+packet.getFrom()+", with: {}, start: {}", retrieveRequest.getWith(), retrieveRequest.getStart() );
final Conversation conversation = retrieve(packet.getFrom(), final Conversation conversation = retrieve(packet.getFrom(),
retrieveRequest); retrieveRequest);
if (conversation == null) { if (conversation == null) {
Log.debug( "Unable to find conversation." );
return error(packet, PacketError.Condition.item_not_found); return error(packet, PacketError.Condition.item_not_found);
} }
...@@ -46,6 +52,7 @@ public class IQRetrieveHandler extends AbstractIQHandler { ...@@ -46,6 +52,7 @@ public class IQRetrieveHandler extends AbstractIQHandler {
max = conversation.getMessages().size(); max = conversation.getMessages().size();
fromIndex = 0; fromIndex = 0;
toIndex = max > 0 ? max : 0; toIndex = max > 0 ? max : 0;
Log.debug( "Found conversation with {} messages.", max );
final XmppResultSet resultSet = retrieveRequest.getResultSet(); final XmppResultSet resultSet = retrieveRequest.getResultSet();
if (resultSet != null) { if (resultSet != null) {
......
...@@ -33,7 +33,7 @@ import com.reucon.openfire.plugin.archive.xep0059.XmppResultSet; ...@@ -33,7 +33,7 @@ import com.reucon.openfire.plugin.archive.xep0059.XmppResultSet;
abstract class IQQueryHandler extends AbstractIQHandler implements abstract class IQQueryHandler extends AbstractIQHandler implements
ServerFeaturesProvider { ServerFeaturesProvider {
private static final Logger Log = LoggerFactory.getLogger(IQHandler.class); private static final Logger Log = LoggerFactory.getLogger(IQQueryHandler.class);
protected final String NAMESPACE; protected final String NAMESPACE;
private final XMPPDateTimeFormat xmppDateTimeFormat = new XMPPDateTimeFormat(); private final XMPPDateTimeFormat xmppDateTimeFormat = new XMPPDateTimeFormat();
...@@ -88,6 +88,7 @@ abstract class IQQueryHandler extends AbstractIQHandler implements ...@@ -88,6 +88,7 @@ abstract class IQQueryHandler extends AbstractIQHandler implements
MultiUserChatService service = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(archiveJid); MultiUserChatService service = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(archiveJid);
MUCRoom room = service.getChatRoom(archiveJid.getNode()); MUCRoom room = service.getChatRoom(archiveJid.getNode());
if (room == null) { if (room == null) {
Log.debug("Unable to process query as room name '{}' is not recognized.", archiveJid);
return buildErrorResponse(packet); return buildErrorResponse(packet);
} }
boolean pass = false; boolean pass = false;
...@@ -107,26 +108,30 @@ abstract class IQQueryHandler extends AbstractIQHandler implements ...@@ -107,26 +108,30 @@ abstract class IQQueryHandler extends AbstractIQHandler implements
} }
} }
if (!pass) { if (!pass) {
Log.debug("Unable to process query as requestor '{}' is forbidden to retrieve archive for room '{}'.", requestor, archiveJid);
return buildForbiddenResponse(packet); return buildForbiddenResponse(packet);
} }
} else if(!archiveJid.equals(requestor)) { // Not user's own } else if(!archiveJid.equals(requestor)) { // Not user's own
// ... disallow unless admin. // ... disallow unless admin.
if (!XMPPServer.getInstance().getAdmins().contains(requestor)) { if (!XMPPServer.getInstance().getAdmins().contains(requestor)) {
Log.debug("Unable to process query as requestor '{}' is forbidden to retrieve personal archives other than his own. Unable to access archives of '{}'.", requestor, archiveJid);
return buildForbiddenResponse(packet); return buildForbiddenResponse(packet);
} }
} }
sendMidQuery(packet, session); sendMidQuery(packet, session);
Log.debug("Retrieving messages from archive...");
final QueryRequest queryRequest = new QueryRequest(packet.getChildElement(), archiveJid); final QueryRequest queryRequest = new QueryRequest(packet.getChildElement(), archiveJid);
Collection<ArchivedMessage> archivedMessages = retrieveMessages(queryRequest); Collection<ArchivedMessage> archivedMessages = retrieveMessages(queryRequest);
Log.debug("Retrieved {} messages from archive.", archivedMessages.size());
for(ArchivedMessage archivedMessage : archivedMessages) { for(ArchivedMessage archivedMessage : archivedMessages) {
sendMessageResult(session, queryRequest, archivedMessage); sendMessageResult(session, queryRequest, archivedMessage);
} }
sendEndQuery(packet, session, queryRequest); sendEndQuery(packet, session, queryRequest);
Log.debug("Done with request.");
return null; return null;
} }
......
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