if (packet.isCommand()) {
if (packet.getCommand() == Command.GETSTATS
&& packet.getType() == StanzaType.result) {
// Send it back to user.
Element iq =
ElementUtils.createIqQuery(session.getDomain(), session.getJID(),
StanzaType.result, packet.getElemId(), XMLNS);
Element query = iq.getChild("query");
Element stats = Command.getData(packet, "statistics", null);
query.addChildren(stats.getChildren());
Packet result = new Packet(iq);
result.setTo(session.getConnectionId(packet.getElemTo()));
results.offer(result);
log.finest("Sending result: " + result.getStringData());
return;
} else {
return;
}
} // end of if (packet.isCommand()
// Maybe it is message to admininstrator:
String id = packet.getElemTo() != null ?
JIDUtils.getNodeID(packet.getElemTo()) : null;
// If ID part of user account contains only host name
// and this is local domain it is message to admin
if (id == null || id.equals("")
|| id.equalsIgnoreCase(session.getDomain())) {
Packet result =
Command.GETSTATS.getPacket(packet.getElemFrom(),
session.getDomain(), StanzaType.get, packet.getElemId());
results.offer(result);
log.finest("Sending result: " + result.getStringData());
return;
}
if (id.equals(session.getUserId())) {
// Yes this is message to 'this' client
Element elem = packet.getElement().clone();
Packet result = new Packet(elem);
result.setTo(session.getConnectionId(packet.getElemTo()));
result.setFrom(packet.getTo());
results.offer(result);
log.finest("Sending result: " + result.getStringData());
} else {
// This is message to some other client so I need to
// set proper 'from' attribute whatever it is set to now.
// Actually processor should not modify request but in this
// case it is absolutely safe and recommended to set 'from'
// attribute
Element el_res = packet.getElement().clone();
// Not needed anymore. Packet filter does it for all stanzas.
// // According to spec we must set proper FROM attribute
// el_res.setAttribute("from", session.getJID());
Packet result = new Packet(el_res);
results.offer(result);