Log.error(ex.getMessage(), ex);
}
}
public void getChatTranscript(IQ iq, String sessionID) {
final IQ reply = IQ.createResultIQ(iq);
String transcriptXML = null;
try {
Element transcript = reply.setChildElement("transcript",
"http://jivesoftware.com/protocol/workgroup");
transcript.addAttribute("sessionID", sessionID);
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(GET_TRANSCRIPT);
pstmt.setString(1, sessionID);
rs = pstmt.executeQuery();
if (rs.next()) {
transcriptXML = DbConnectionManager.getLargeTextField(rs, 1);
}
}
catch (SQLException sqle) {
Log.error(sqle.getMessage(), sqle);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
if (transcriptXML != null) {
Document element = DocumentHelper.parseText(transcriptXML);
// Add the Messages and Presences contained in the retrieved transcript element
for (Iterator<Element> it = element.getRootElement().elementIterator(); it.hasNext();) {
Element packet = it.next();
transcript.add(packet.createCopy());
}
}
workgroup.send(reply);
}
catch (Exception ex) {
Log.error(
"There was an error retrieving the following transcript. SessionID = " +
sessionID + " Transcript=" + transcriptXML, ex);
reply.setChildElement(iq.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
}
}