Search in sources :

Example 31 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class EncoderDecoder11Impl method buildHeaders.

@Override
protected void buildHeaders(SequenceType seq, Collection<SequenceAcknowledgement> acks, Collection<AckRequestedType> reqs, boolean last, List<Header> headers) throws JAXBException {
    if (null != seq) {
        LOG.log(Level.FINE, "encoding sequence into RM header");
        JAXBElement<SequenceType> element = RMUtils.getWSRMFactory().createSequence(seq);
        headers.add(new SoapHeader(element.getName(), element, getDataBinding(), true));
    }
    if (null != acks) {
        LOG.log(Level.FINE, "encoding sequence acknowledgement(s) into RM header");
        for (SequenceAcknowledgement ack : acks) {
            headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), RMConstants.SEQUENCE_ACK_NAME), ack, getDataBinding()));
        }
    }
    if (null != reqs) {
        LOG.log(Level.FINE, "encoding acknowledgement request(s) into RM header");
        for (AckRequestedType req : reqs) {
            headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), RMConstants.ACK_REQUESTED_NAME), RMUtils.getWSRMFactory().createAckRequested(req), getDataBinding()));
        }
    }
}
Also used : QName(javax.xml.namespace.QName) SoapHeader(org.apache.cxf.binding.soap.SoapHeader) AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType) CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 32 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class RMManager method recoverSourceSequence.

private void recoverSourceSequence(Endpoint endpoint, Conduit conduit, Source s, SourceSequence ss) {
    Collection<RMMessage> ms = store.getMessages(ss.getIdentifier(), true);
    if (null == ms || 0 == ms.size()) {
        store.removeSourceSequence(ss.getIdentifier());
        return;
    }
    LOG.log(Level.FINE, "Number of messages in sequence: {0}", ms.size());
    // only recover the sequence if there are pending messages
    s.addSequence(ss, false);
    // choosing an arbitrary valid source sequence as the current source sequence
    if (s.getAssociatedSequence(null) == null && !ss.isExpired() && !ss.isLastMessage()) {
        s.setCurrent(ss);
    }
    // make sure this is associated with the offering id
    s.setCurrent(ss.getOfferingSequenceIdentifier(), ss);
    for (RMMessage m : ms) {
        Message message = new MessageImpl();
        Exchange exchange = new ExchangeImpl();
        message.setExchange(exchange);
        exchange.setOutMessage(message);
        if (null != conduit) {
            exchange.setConduit(conduit);
            message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
        }
        exchange.put(Endpoint.class, endpoint);
        exchange.put(Service.class, endpoint.getService());
        exchange.put(Binding.class, endpoint.getBinding());
        exchange.put(Bus.class, bus);
        SequenceType st = new SequenceType();
        st.setIdentifier(ss.getIdentifier());
        st.setMessageNumber(m.getMessageNumber());
        RMProperties rmps = new RMProperties();
        rmps.setSequence(st);
        rmps.setCreatedTime(m.getCreatedTime());
        rmps.exposeAs(ss.getProtocol().getWSRMNamespace());
        if (ss.isLastMessage() && ss.getCurrentMessageNr() == m.getMessageNumber()) {
            CloseSequenceType close = new CloseSequenceType();
            close.setIdentifier(ss.getIdentifier());
            rmps.setCloseSequence(close);
        }
        RMContextUtils.storeRMProperties(message, rmps, true);
        if (null == conduit) {
            String to = m.getTo();
            AddressingProperties maps = new AddressingProperties();
            maps.setTo(RMUtils.createReference(to));
            RMContextUtils.storeMAPs(maps, message, true, false);
        }
        try {
            // RMMessage is stored in a serialized way, therefore
            // RMMessage content must be splitted into soap root message
            // and attachments
            PersistenceUtils.decodeRMContent(m, message);
            RMContextUtils.setProtocolVariation(message, ss.getProtocol());
            retransmissionQueue.addUnacknowledged(message);
        } catch (IOException e) {
            LOG.log(Level.SEVERE, "Error reading persisted message data", e);
        }
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) Message(org.apache.cxf.message.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) IOException(java.io.IOException) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 33 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class RMOutInterceptor method handle.

protected void handle(Message msg) throws SequenceFault, RMException {
    AddressingProperties maps = ContextUtils.retrieveMAPs(msg, false, true, false);
    if (null == maps) {
        LogUtils.log(LOG, Level.WARNING, "MAPS_RETRIEVAL_FAILURE_MSG");
        return;
    }
    if (Boolean.TRUE.equals(msg.get(RMMessageConstants.RM_RETRANSMISSION))) {
        return;
    }
    if (isRuntimeFault(msg)) {
        return;
    }
    RMConfiguration config = getManager().getEffectiveConfiguration(msg);
    String wsaNamespace = config.getAddressingNamespace();
    String rmNamespace = config.getRMNamespace();
    ProtocolVariation protocol = ProtocolVariation.findVariant(rmNamespace, wsaNamespace);
    RMContextUtils.setProtocolVariation(msg, protocol);
    Destination destination = getManager().getDestination(msg);
    String action = null;
    if (null != maps.getAction()) {
        action = maps.getAction().getValue();
    }
    // make sure we use the appropriate namespace
    maps.exposeAs(wsaNamespace);
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Action: " + action);
    }
    boolean isApplicationMessage = !RMContextUtils.isRMProtocolMessage(action);
    boolean isPartialResponse = MessageUtils.isPartialResponse(msg);
    RMConstants constants = protocol.getConstants();
    RMProperties rmpsOut = RMContextUtils.retrieveRMProperties(msg, true);
    if (isApplicationMessage && !isPartialResponse) {
        addRetransmissionInterceptor(msg);
    }
    Identifier inSeqId = null;
    if (isApplicationMessage) {
        RMProperties rmpsIn = RMContextUtils.retrieveRMProperties(msg, false);
        if (null != rmpsIn && null != rmpsIn.getSequence()) {
            inSeqId = rmpsIn.getSequence().getIdentifier();
            SourceSequence seq = rmpsIn.getSourceSequence();
            SequenceType sequence = rmpsIn.getSequence();
            if (seq == null || sequence == null) {
                LOG.warning("sequence not set for outbound message, skipped acknowledgement request");
            } else {
                addAckRequest(msg, rmpsIn, seq, sequence);
            }
        }
    }
    // add Acknowledgements (to application messages or explicitly created Acknowledgement messages only)
    boolean isAck = constants.getSequenceAckAction().equals(action);
    boolean isClose = constants.getCloseSequenceAction().equals(action);
    boolean isTerminate = constants.getTerminateSequenceAction().equals(action);
    if (isApplicationMessage || isAck || isClose || isTerminate) {
        AttributedURIType to = maps.getTo();
        assert null != to;
        addAcknowledgements(destination, rmpsOut, inSeqId, to);
        if (isPartialResponse && rmpsOut.getAcks() != null && rmpsOut.getAcks().size() > 0) {
            setAction(maps, constants.getSequenceAckAction());
            msg.remove(Message.EMPTY_PARTIAL_RESPONSE_MESSAGE);
            isAck = true;
        }
    }
    if (isAck || (isTerminate && RM10Constants.NAMESPACE_URI.equals(rmNamespace))) {
        maps.setReplyTo(RMUtils.createNoneReference());
    }
    assertReliability(msg);
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType)

Example 34 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class RMProperties method setSequence.

public void setSequence(SourceSequence seq) {
    sourceSequence = seq;
    messageNumber = seq.getCurrentMessageNr();
    SequenceType s = new SequenceType();
    s.setIdentifier(seq.getIdentifier());
    s.setMessageNumber(messageNumber);
    setSequence(s);
    lastMessage = seq.isLastMessage();
}
Also used : CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType)

Example 35 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class VersionTransformer method convert.

/**
 * Convert 200502 wsrm:SequenceType with 200408 WS-Addressing namespace to internal form.
 *
 * @param exposed (non-<code>null</code>)
 * @return converted
 */
public static SequenceType convert(org.apache.cxf.ws.rm.v200502.SequenceType exposed) {
    SequenceType internal = new SequenceType();
    internal.setIdentifier(convert(exposed.getIdentifier()));
    internal.setMessageNumber(exposed.getMessageNumber());
    addAll(exposed.getAny(), internal.getAny());
    putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
    return internal;
}
Also used : CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType)

Aggregations

SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)33 CloseSequenceType (org.apache.cxf.ws.rm.v200702.CloseSequenceType)12 RMProperties (org.apache.cxf.ws.rm.RMProperties)11 CreateSequenceType (org.apache.cxf.ws.rm.v200702.CreateSequenceType)11 TerminateSequenceType (org.apache.cxf.ws.rm.v200702.TerminateSequenceType)11 Message (org.apache.cxf.message.Message)8 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)7 SequenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType)6 IOException (java.io.IOException)6 Unmarshaller (javax.xml.bind.Unmarshaller)5 AckRequestedType (org.apache.cxf.ws.rm.v200702.AckRequestedType)5 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)4 Endpoint (org.apache.cxf.endpoint.Endpoint)4 Exchange (org.apache.cxf.message.Exchange)4 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)4 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)4 Test (org.junit.Test)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 SystemException (com.evolveum.midpoint.util.exception.SystemException)3 File (java.io.File)3