Search in sources :

Example 21 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.

the class ServantTest method createTestCloseSequenceMessage.

private static Message createTestCloseSequenceMessage(String sidstr) {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setInMessage(message);
    message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
    AddressingProperties maps = new AddressingProperties();
    String msgId = "urn:uuid:12345-" + Math.random();
    AttributedURIType id = ContextUtils.getAttributedURI(msgId);
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getTerminateSequenceAction()));
    maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));
    maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));
    message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);
    CloseSequenceType cs = new CloseSequenceType();
    org.apache.cxf.ws.rm.v200702.Identifier sid = new org.apache.cxf.ws.rm.v200702.Identifier();
    sid.setValue(sidstr);
    cs.setIdentifier(sid);
    MessageContentsList contents = new MessageContentsList();
    contents.add(cs);
    message.setContent(List.class, contents);
    RMContextUtils.setProtocolVariation(message, ProtocolVariation.RM11WSA200508);
    return message;
}
Also used : Message(org.apache.cxf.message.Message) MessageContentsList(org.apache.cxf.message.MessageContentsList) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Exchange(org.apache.cxf.message.Exchange) Identifier(org.apache.cxf.ws.rm.v200502.Identifier) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 22 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.

the class RMManager method getSequence.

public SourceSequence getSequence(Identifier inSeqId, Message message, AddressingProperties maps) throws RMException {
    Source source = getSource(message);
    SourceSequence seq = source.getCurrent(inSeqId);
    RMConfiguration config = getEffectiveConfiguration(message);
    if (null == seq || seq.isExpired()) {
        // TODO: better error handling
        EndpointReferenceType to = null;
        boolean isServer = RMContextUtils.isServerSide(message);
        EndpointReferenceType acksTo = null;
        RelatesToType relatesTo = null;
        if (isServer) {
            AddressingProperties inMaps = RMContextUtils.retrieveMAPs(message, false, false);
            inMaps.exposeAs(config.getAddressingNamespace());
            acksTo = RMUtils.createReference(inMaps.getTo().getValue());
            to = inMaps.getReplyTo();
            source.getReliableEndpoint().getServant().setUnattachedIdentifier(inSeqId);
            relatesTo = (new org.apache.cxf.ws.addressing.ObjectFactory()).createRelatesToType();
            Destination destination = getDestination(message);
            DestinationSequence inSeq = inSeqId == null ? null : destination.getSequence(inSeqId);
            relatesTo.setValue(inSeq != null ? inSeq.getCorrelationID() : null);
        } else {
            to = RMUtils.createReference(maps.getTo().getValue());
            acksTo = maps.getReplyTo();
            if (RMUtils.getAddressingConstants().getNoneURI().equals(acksTo.getAddress().getValue())) {
                Endpoint ei = message.getExchange().getEndpoint();
                org.apache.cxf.transport.Destination dest = ei == null ? null : ei.getEndpointInfo().getProperty(MAPAggregator.DECOUPLED_DESTINATION, org.apache.cxf.transport.Destination.class);
                if (null == dest) {
                    acksTo = RMUtils.createAnonymousReference();
                } else {
                    acksTo = dest.getAddress();
                }
            }
        }
        if (ContextUtils.isGenericAddress(to)) {
            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("CREATE_SEQ_ANON_TARGET", LOG, to != null && to.getAddress() != null ? to.getAddress().getValue() : null);
            LOG.log(Level.INFO, msg.toString());
            throw new RMException(msg);
        }
        Proxy proxy = source.getReliableEndpoint().getProxy();
        ProtocolVariation protocol = config.getProtocolVariation();
        Exchange exchange = new ExchangeImpl();
        Map<String, Object> context = new HashMap<>(16);
        for (String key : message.getContextualPropertyKeys()) {
            // copy other properties?
            if (key.startsWith("ws-security") || key.startsWith("security.")) {
                context.put(key, message.getContextualProperty(key));
            }
        }
        CreateSequenceResponseType createResponse = proxy.createSequence(acksTo, relatesTo, isServer, protocol, exchange, context);
        if (!isServer) {
            Servant servant = source.getReliableEndpoint().getServant();
            servant.createSequenceResponse(createResponse, protocol);
            // propagate security properties to application endpoint, in case we're using WS-SecureConversation
            Exchange appex = message.getExchange();
            if (appex.get(SecurityConstants.TOKEN) == null) {
                appex.put(SecurityConstants.TOKEN, exchange.get(SecurityConstants.TOKEN));
                appex.put(SecurityConstants.TOKEN_ID, exchange.get(SecurityConstants.TOKEN_ID));
            }
        }
        seq = source.awaitCurrent(inSeqId);
        seq.setTarget(to);
    }
    return seq;
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) Message(org.apache.cxf.message.Message) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Endpoint(org.apache.cxf.endpoint.Endpoint) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType) Exchange(org.apache.cxf.message.Exchange) RelatesToType(org.apache.cxf.ws.addressing.RelatesToType) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 23 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.

the class RMOutInterceptor method addAckRequest.

/**
 * Add AcknowledgementRequested to message if needed. The AckRequest mode set either in the message
 * properties or in the source policy is used to determine whether AcknowledgementRequested is always
 * added, never added, or added only when we're waiting for the acknowledgement to a previously-sent
 * message.
 *
 * @param msg
 * @param rmpsIn
 * @param seq
 * @param sequence
 */
protected void addAckRequest(Message msg, RMProperties rmpsIn, SourceSequence seq, SequenceType sequence) {
    AckRequestModeType mode = (AckRequestModeType) msg.get(RMMessageConstants.ACK_REQUEST_MODE);
    if (mode == null) {
        mode = AckRequestModeType.PENDING;
        SourcePolicyType policy = getManager().getSourcePolicy();
        if (policy.isSetAckRequestMode()) {
            mode = policy.getAckRequestMode();
        }
    }
    if (AckRequestModeType.ALWAYS == mode || (mode == AckRequestModeType.PENDING && seq.needAcknowledge(rmpsIn.getMessageNumber()))) {
        Collection<AckRequestedType> reqs = rmpsIn.getAcksRequested();
        if (reqs == null) {
            reqs = new ArrayList<>();
        }
        Identifier identifier = new Identifier();
        identifier.setValue(sequence.getIdentifier().getValue());
        AckRequestedType ackRequest = new AckRequestedType();
        ackRequest.setIdentifier(identifier);
        reqs.add(ackRequest);
        rmpsIn.setAcksRequested(reqs);
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) AckRequestModeType(org.apache.cxf.ws.rm.manager.AckRequestModeType) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType)

Example 24 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.

the class Servant method clearUnattachedIdentifier.

Identifier clearUnattachedIdentifier() {
    Identifier ret = unattachedIdentifier;
    unattachedIdentifier = null;
    return ret;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier)

Example 25 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.

the class VersionTransformer method convert.

/**
 * Convert 200502 wsrm:Identifier with 200408 WS-Addressing namespace to internal form.
 *
 * @param exposed (may be <code>null</code>)
 * @return converted (<code>null</code> if exposed is <code>null</code>)
 */
public static Identifier convert(org.apache.cxf.ws.rm.v200502.Identifier exposed) {
    if (exposed == null) {
        return null;
    }
    Identifier internal = new Identifier();
    internal.setValue(exposed.getValue());
    putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
    return internal;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 Test (org.junit.Test)40 Message (org.apache.cxf.message.Message)14 ArrayList (java.util.ArrayList)13 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)13 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)13 SourceSequence (org.apache.cxf.ws.rm.SourceSequence)11 Connection (java.sql.Connection)10 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)10 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)9 SQLException (java.sql.SQLException)8 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)8 Date (java.util.Date)7 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)7 Method (java.lang.reflect.Method)6 Endpoint (org.apache.cxf.endpoint.Endpoint)6 Exchange (org.apache.cxf.message.Exchange)6 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)6 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)6 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)6