Search in sources :

Example 1 with Direction

use of com.reucon.openfire.plugin.archive.model.ArchivedMessage.Direction in project Openfire by igniterealtime.

the class JdbcPersistenceManager method extractMessage.

private ArchivedMessage extractMessage(ResultSet rs) throws SQLException {
    final ArchivedMessage message;
    Date time = millisToDate(rs.getLong("sentDate"));
    Direction direction = getDirection(rs);
    String type = null;
    String subject = null;
    String body = rs.getString("body");
    String bareJid = rs.getString("bareJID");
    JID withJid = null;
    if (Direction.from == direction) {
        withJid = new JID(rs.getString("fromJID"));
    }
    message = new ArchivedMessage(time, direction, null, withJid);
    // message.setId(id);
    // message.setSubject(subject);
    message.setBody(body);
    return message;
}
Also used : JID(org.xmpp.packet.JID) ArchivedMessage(com.reucon.openfire.plugin.archive.model.ArchivedMessage) Direction(com.reucon.openfire.plugin.archive.model.ArchivedMessage.Direction) Date(java.util.Date)

Example 2 with Direction

use of com.reucon.openfire.plugin.archive.model.ArchivedMessage.Direction in project Openfire by igniterealtime.

the class JdbcPersistenceManager method getDirection.

private Direction getDirection(ResultSet rs) throws SQLException {
    Direction direction = null;
    String bareJid = rs.getString("bareJID");
    String fromJid = rs.getString("fromJID");
    String toJid = rs.getString("toJID");
    if (bareJid != null && fromJid != null && toJid != null) {
        if (bareJid.equals(fromJid)) {
            /*
				 * if message from me to withJid then it is to the withJid participant
				 */
            direction = Direction.to;
        } else {
            /*
				 * if message to me from withJid then it is from the withJid participant
				 */
            direction = Direction.from;
        }
    }
    return direction;
}
Also used : Direction(com.reucon.openfire.plugin.archive.model.ArchivedMessage.Direction)

Aggregations

Direction (com.reucon.openfire.plugin.archive.model.ArchivedMessage.Direction)2 ArchivedMessage (com.reucon.openfire.plugin.archive.model.ArchivedMessage)1 Date (java.util.Date)1 JID (org.xmpp.packet.JID)1