Commit 48d7b15f authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Fixed error loading room history using MS-SQL. JM-299


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1471 b35dd754-fafc-0310-a699-88a17e54d16e
parent 689952d1
...@@ -199,12 +199,16 @@ public class MUCPersistenceManager { ...@@ -199,12 +199,16 @@ public class MUCPersistenceManager {
pstmt.setLong(2, room.getID()); pstmt.setLong(2, room.getID());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) { while (rs.next()) {
String senderJID = rs.getString(1);
String nickname = rs.getString(2);
Date sentDate = new Date(Long.parseLong(rs.getString(3).trim())); Date sentDate = new Date(Long.parseLong(rs.getString(3).trim()));
String subject = rs.getString(4);
String body = rs.getString(5);
// Recreate the history only for the rooms that have the conversation logging // Recreate the history only for the rooms that have the conversation logging
// enabled // enabled
if (room.isLogEnabled()) { if (room.isLogEnabled()) {
room.getRoomHistory().addOldMessage(rs.getString(1), rs.getString(2), sentDate, room.getRoomHistory().addOldMessage(senderJID, nickname, sentDate, subject,
rs.getString(4), rs.getString(5)); body);
} }
} }
rs.close(); rs.close();
...@@ -466,13 +470,17 @@ public class MUCPersistenceManager { ...@@ -466,13 +470,17 @@ public class MUCPersistenceManager {
if (room == null) { if (room == null) {
continue; continue;
} }
String senderJID = rs.getString(2);
String nickname = rs.getString(3);
Date sentDate = new Date(Long.parseLong(rs.getString(4).trim())); Date sentDate = new Date(Long.parseLong(rs.getString(4).trim()));
String subject = rs.getString(5);
String body = rs.getString(6);
try { try {
// Recreate the history only for the rooms that have the conversation logging // Recreate the history only for the rooms that have the conversation logging
// enabled // enabled
if (room.isLogEnabled()) { if (room.isLogEnabled()) {
room.getRoomHistory().addOldMessage(rs.getString(2), rs.getString(3), room.getRoomHistory().addOldMessage(senderJID, nickname, sentDate, subject,
sentDate, rs.getString(5), rs.getString(6)); body);
} }
} }
catch (Exception e) { catch (Exception e) {
...@@ -497,9 +505,10 @@ public class MUCPersistenceManager { ...@@ -497,9 +505,10 @@ public class MUCPersistenceManager {
pstmt = con.prepareStatement(LOAD_ALL_AFFILIATIONS); pstmt = con.prepareStatement(LOAD_ALL_AFFILIATIONS);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) { while (rs.next()) {
long roomID = rs.getLong(1);
String jid = rs.getString(2); String jid = rs.getString(2);
MUCRole.Affiliation affiliation = MUCRole.Affiliation.valueOf(rs.getInt(3)); MUCRole.Affiliation affiliation = MUCRole.Affiliation.valueOf(rs.getInt(3));
room = (MUCRoomImpl) rooms.get(rs.getLong(1)); room = (MUCRoomImpl) rooms.get(roomID);
// Skip to the next position if the room does not exist // Skip to the next position if the room does not exist
if (room == null) { if (room == null) {
continue; continue;
......
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