diff --git a/src/main/java/tigase/archive/QueryCriteria.java b/src/main/java/tigase/archive/QueryCriteria.java index 5790a8e..3ac1ac6 100644 --- a/src/main/java/tigase/archive/QueryCriteria.java +++ b/src/main/java/tigase/archive/QueryCriteria.java @@ -100,4 +100,18 @@ public List getItems() { } return items; } + + @Override + public String toString() { + final StringBuffer sb = new StringBuffer("QueryCriteria{"); + sb.append("QueryImpl='").append(super.toString()).append('\''); + sb.append(", contains=").append(contains); + sb.append(", tags=").append(tags); + sb.append(", collections=").append(collections); + sb.append(", items=").append(items.size()); + sb.append(", useMessageIdInRsm=").append(useMessageIdInRsm); + sb.append(", fasteningCollation=").append(getFasteningCollation()); + sb.append('}'); + return sb.toString(); + } } diff --git a/src/main/java/tigase/archive/db/JDBCMessageArchiveRepository.java b/src/main/java/tigase/archive/db/JDBCMessageArchiveRepository.java index 73e732a..f50ebeb 100644 --- a/src/main/java/tigase/archive/db/JDBCMessageArchiveRepository.java +++ b/src/main/java/tigase/archive/db/JDBCMessageArchiveRepository.java @@ -159,6 +159,7 @@ public String getStableId(BareJID owner, BareJID buddy, String stanzaId) throws @Override public void queryCollections(Q crit, CollectionHandler collectionHandler) throws TigaseDBException { try { + log.log(Level.FINEST, () -> "Querying collections: crit: " + crit); Integer count = getCollectionsCount(crit); if (count == null) { count = 0; @@ -179,6 +180,7 @@ public void queryCollections(Q crit, CollectionHandler itemHandler) throws TigaseDBException, ComponentException { try { + log.log(Level.FINEST, () -> "Querying items, criteria: " + crit); if (!crit.getIds().isEmpty()) { ArrayDeque items = new ArrayDeque<>(); for (String id : crit.getIds()) { @@ -444,6 +446,7 @@ protected int setQueryParams(PreparedStatement stmt, Q crit, FasteningCollation } stmt.setString(i++, sb.toString()); } + log.log(Level.FINEST, () -> "Setting PS parameters: " + stmt + ", crit: " + crit); return i; } @@ -456,6 +459,7 @@ protected Item newItemInstance() { } private void getCollectionsItems(Q crit, CollectionHandler collectionHandler) throws SQLException { + log.log(Level.FINEST, () -> "Getting collections items: " + crit); ResultSet selectRs = null; BareJID owner = crit.getQuestionerJID().getBareJID(); PreparedStatement get_collections_st = data_repo.getPreparedStatement(owner, GET_COLLECTIONS_QUERY); @@ -486,6 +490,7 @@ private void getCollectionsItems(Q crit, CollectionHandler "Getting collections: " + crit); ResultSet countRs = null; Integer count = null; BareJID owner = crit.getQuestionerJID().getBareJID(); @@ -513,6 +518,7 @@ private Integer getColletionPosition(String uid, Q query) { } private MAMRepository.Item getItem(Q crit, String itemId) throws SQLException { + log.log(Level.FINEST, () -> "Getting MAM item: " + crit + ", itemId: " + itemId); ResultSet rs = null; BareJID owner = crit.getQuestionerJID().getBareJID(); PreparedStatement get_message_st = data_repo.getPreparedStatement(owner, GET_MESSAGE_QUERY); @@ -546,6 +552,7 @@ private void getItemsItems(Q crit, Range range, ItemHandler results = new ArrayDeque(); BareJID owner = crit.getQuestionerJID().getBareJID(); + log.log(Level.FINEST, () -> "Getting items items, criteria: " + crit + ", range: " + range); // there is no point to execute query if limit is estimated to be 0 if (Math.min(range.size(), crit.getRsm().getMax()) > 0) { PreparedStatement get_messages_st = data_repo.getPreparedStatement(owner, GET_MESSAGES_QUERY); @@ -598,6 +605,7 @@ private void getItemsItems(Q crit, Range range, ItemHandler "Getting items count, criteria: " + crit); Integer count = null; ResultSet rs = null; BareJID owner = crit.getQuestionerJID().getBareJID(); @@ -618,6 +626,7 @@ private Integer getItemsCount(Q crit) throws SQLException { } private Integer getItemPosition(String uid, Q query) throws SQLException, ComponentException { + log.log(Level.FINEST, () -> "Getting item position, criteria: " + query + ", uid: " + uid); if (uid == null || uid.isEmpty()) { return null; }