All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.digipost.api.representations.EbmsContext Maven / Gradle / Ivy

The newest version!
package no.digipost.api.representations;

import no.digipost.org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.Error;
import no.digipost.org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.Messaging;
import no.digipost.org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.SignalMessage;
import no.digipost.org.oasis_open.docs.ebxml_msg.ebms.v3_0.ns.core._200704.UserMessage;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapMessage;
import no.digipost.org.w3.xmldsig.Reference;
import org.w3c.dom.Document;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

public class EbmsContext {

    private static final String PROPERTY_NAME = "no.posten.dpost.ebms.context";
    public final List responseProcessingSteps = new ArrayList();
    public final List requestProcessingSteps = new ArrayList();

    public UserMessage userMessage = null;
    public List receipts = new ArrayList();
    public SignalMessage pullSignal = null;
    public Map incomingReferences = new HashMap();

    public SimpleStandardBusinessDocument sbd = null;
    public Map mpcMap = new HashMap();
    public Messaging incomingMessaging;
    public Optional remoteParty = Optional.empty();
    public Exception referencesValidationException;
    public Error warning;
    public Document domSbd;

    public static EbmsContext from(final MessageContext messageContext) {
        EbmsContext context = (EbmsContext) messageContext.getProperty(PROPERTY_NAME);
        if (context == null) {
            context = new EbmsContext();
            messageContext.setProperty(PROPERTY_NAME, context);
        }
        return context;
    }

    public void addResponseStep(final EbmsProcessingStep strategy) {
        responseProcessingSteps.add(strategy);
    }

    public void addRequestStep(final EbmsProcessingStep strategy) {
        requestProcessingSteps.add(strategy);
    }

    public void processResponse(final EbmsContext ebmsContext, final SoapHeaderElement ebmsMessaging, final SoapMessage soapMessage) {
        for (EbmsProcessingStep r : responseProcessingSteps) {
            r.apply(ebmsContext, ebmsMessaging, soapMessage);
        }

    }

    public void processRequest(final EbmsContext ebmsContext, final SoapHeaderElement ebmsMessaging, final SoapMessage soapMessage) {
        for (EbmsProcessingStep r : requestProcessingSteps) {
            r.apply(ebmsContext, ebmsMessaging, soapMessage);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy