public void execute()

in server/core/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java [70:127]


    public void execute(Stanza anyStanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza,
            SessionContext sessionContext, SessionStateHolder sessionStateHolder, StanzaBroker stanzaBroker) {
        XMPPCoreStanza stanza = XMPPCoreStanza.getWrapper(anyStanza);
        if (stanza == null)
            throw new IllegalArgumentException("can only handle core XMPP stanzas (iq, message, presence)");

        // type="error" is common to all stanza, check here some prerequisites
        Attribute typeAttribute = stanza.getAttribute("type");
        XMPPCoreStanza xmppCoreStanza = XMPPCoreStanza.getWrapper(stanza);
        if (xmppCoreStanza != null && typeAttribute != null) {
            String errorDescription = null;
            String type = typeAttribute.getValue();
            if (IQStanzaType.ERROR.value().equals(type)) {
                // assure, result contains zero or one element
                // rfc3920/9.2.3/7.
                if (!stanza.getVerifier().subElementPresent("error")) {
                    errorDescription = "stanza of type error must include an 'error' child";
                }
            } else {
                // assure, non-error result does not contain error
                // rfc3920/9.2.3/7. + rfc3920/9.3.1/3.
                if (stanza.getVerifier().subElementPresent("error")) {
                    errorDescription = "stanza which is not of type error must not include an 'error' child";
                }
            }

            // at this point, we are not allowed to respond with another error
            // we cannot really close the stream
            // we simply ignore it.
            /*
             * ResponseStanzaContainerImpl errorResponseContainer = new
             * ResponseStanzaContainerImpl(
             * ServerErrorResponses.getInstance().getErrorResponse(xmppCoreStanza,
             * StanzaErrorType.MODIFY, StanzaErrorCondition.BAD_REQUEST, errorDescription,
             * sessionContext.getXMLLang(), null) ); return errorResponseContainer;
             */
        }

        Entity to = stanza.getTo();
        if (sessionContext != null && sessionContext.isServerToServer() && to == null) {
            // "to" MUST be present for jabber:server
            stanzaBroker.writeToSession(ServerErrorResponses.getStreamError(StreamErrorCondition.IMPROPER_ADDRESSING,
                    stanza.getXMLLang(), "missing to attribute", null));
            return;
        }

        if (to != null) {
            // TODO ensure, that RFC3920 9.1.1 "If the value of the 'to' attribute is
            // invalid or cannot be contacted..." is enforced
        }

        List<Stanza> responseStanzas = executeCore(stanza, serverRuntimeContext, isOutboundStanza, sessionContext,
                stanzaBroker);
        if (responseStanzas == null) {
            return;
        }
        responseStanzas.forEach(stanzaBroker::writeToSession);
    }