protected Message createXmppMessage(String to, MessageDispatch messageDispatch) throws IOException, JMSException {
org.apache.activemq.command.Message message = messageDispatch.getMessage();
Message answer = new Message();
String from = (String)message.getProperty("XMPPFrom");
if ( from == null ) {
from = to;
int idx = from.indexOf('/');
if (idx > 0) {
from = from.substring(0, idx) + "/broker";
}
answer.setType("groupchat");
} else {
answer.setType("chat");
}
LOG.debug("Sending message from " + from + " and to " + to);
answer.setFrom(from);
answer.setTo(to);
// answer.setType(message.getType());
if (message instanceof ActiveMQTextMessage) {
ActiveMQTextMessage activeMQTextMessage = (ActiveMQTextMessage)message;
Body body = new Body();
String text = activeMQTextMessage.getText();
LOG.info("Setting the body text to be: " + text);
body.setValue(text);
answer.getAny().add(body);
} else {
// TODO support other message types
LOG.warn("Could not convert the message to a complete Jabber message: " + message);
}
return answer;