in server/core/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/MessageHandler.java [62:139]
protected List<Stanza> executeCore(XMPPCoreStanza stanza, ServerRuntimeContext serverRuntimeContext,
boolean isOutboundStanza, SessionContext sessionContext, StanzaBroker stanzaBroker) {
// (try to) read thread id
String threadId = null;
XMLElement threadElement = null;
try {
threadElement = stanza.getSingleInnerElementsNamed("thread");
if (threadElement != null && threadElement.getSingleInnerText() != null) {
try {
threadId = threadElement.getSingleInnerText().getText();
} catch (Exception _) {
threadId = null;
}
}
} catch (XMLSemanticError _) {
threadId = null;
}
// (try to) read subject id
String subject = null;
XMLElement subjectElement = null;
try {
subjectElement = stanza.getSingleInnerElementsNamed("subject");
if (subjectElement != null && subjectElement.getSingleInnerText() != null) {
try {
subject = subjectElement.getSingleInnerText().getText();
} catch (Exception _) {
subject = null;
}
}
} catch (XMLSemanticError _) {
subject = null;
}
// TODO inspect all BODY elements and make sure they conform to the spec
if (isOutboundStanza) {
Entity from = stanza.getFrom();
if (from == null || !from.isResourceSet()) {
// rewrite stanza with new from
String resource = serverRuntimeContext.getResourceRegistry()
.getUniqueResourceForSession(sessionContext);
if (resource == null)
throw new IllegalStateException("could not determine unique resource");
from = new EntityImpl(sessionContext.getInitiatingEntity(), resource);
StanzaBuilder stanzaBuilder = new StanzaBuilder(stanza.getName(), stanza.getNamespaceURI());
for (Attribute attribute : stanza.getAttributes()) {
if ("from".equals(attribute.getName()))
continue;
stanzaBuilder.addAttribute(attribute);
}
stanzaBuilder.addAttribute("from", from.getFullQualifiedName());
for (XMLElement preparedElement : stanza.getInnerElements()) {
stanzaBuilder.addPreparedElement(preparedElement);
}
stanza = XMPPCoreStanza.getWrapper(stanzaBuilder.build());
}
// check if message reception is turned of either globally or locally
if (!serverRuntimeContext.getServerFeatures().isRelayingMessages()
|| (sessionContext != null && sessionContext
.getAttribute(SessionContext.SESSION_ATTRIBUTE_MESSAGE_STANZA_NO_RECEIVE) != null)) {
return Collections.emptyList();
}
try {
stanzaBroker.write(stanza.getTo(), stanza, new ReturnErrorToSenderFailureStrategy(stanzaBroker));
} catch (Exception e) {
// TODO return error stanza
e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates.
}
} else {
stanzaBroker.writeToSession(stanza);
}
return Collections.emptyList();
}