Search in sources :

Example 1 with Expires

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires in project cxf by apache.

the class ServantTest method verifyCreateSequenceExpiresSetAtDestination.

private void verifyCreateSequenceExpiresSetAtDestination(Servant servant, RMManager manager) throws SequenceFault {
    DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType();
    AcksPolicyType ap = RMMANGER_FACTORY.createAcksPolicyType();
    dp.setAcksPolicy(ap);
    dp.setSequenceExpiration(DURATION_SHORT);
    manager.setDestinationPolicy(dp);
    Expires expires = new Expires();
    expires.setValue(DURATION_DEFAULT);
    Message message = createTestCreateSequenceMessage(expires, null);
    CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
    Expires expires2 = csr.getExpires();
    assertNotNull(expires2);
    assertEquals(DURATION_SHORT, expires2.getValue());
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) Message(org.apache.cxf.message.Message) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Expires(org.apache.cxf.ws.rm.v200502.Expires) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)

Example 2 with Expires

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires in project cxf by apache.

the class ServantTest method verifyCreateSequenceDefault.

private void verifyCreateSequenceDefault(Servant servant, RMManager manager) throws SequenceFault {
    DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType();
    AcksPolicyType ap = RMMANGER_FACTORY.createAcksPolicyType();
    dp.setAcksPolicy(ap);
    manager.setDestinationPolicy(dp);
    Expires expires = new Expires();
    expires.setValue(DatatypeFactory.createDuration("P0Y0M0DT0H0M0.0S"));
    Message message = createTestCreateSequenceMessage(expires, null);
    CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
    Expires expires2 = csr.getExpires();
    assertNotNull(expires2);
    assertEquals(DatatypeFactory.PT0S, expires2.getValue());
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) Message(org.apache.cxf.message.Message) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Expires(org.apache.cxf.ws.rm.v200502.Expires) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)

Example 3 with Expires

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires in project cxf by apache.

the class Servant method createSequence.

Object createSequence(Message message) {
    LOG.fine("Creating sequence");
    final ProtocolVariation protocol = RMContextUtils.getProtocolVariation(message);
    AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, false);
    Message outMessage = message.getExchange().getOutMessage();
    if (null != outMessage) {
        RMContextUtils.storeMAPs(maps, outMessage, false, false);
    }
    EncoderDecoder codec = protocol.getCodec();
    CreateSequenceType create = codec.convertReceivedCreateSequence(getParameter(message));
    Destination destination = reliableEndpoint.getDestination();
    CreateSequenceResponseType createResponse = new CreateSequenceResponseType();
    createResponse.setIdentifier(destination.generateSequenceIdentifier());
    DestinationPolicyType dp = reliableEndpoint.getManager().getDestinationPolicy();
    if (dp.getMaxSequences() > 0 && destination.getProcessingSequenceCount() >= dp.getMaxSequences()) {
        throw new RuntimeException("Sequence creation refused");
    }
    Duration supportedDuration = dp.getSequenceExpiration();
    if (null == supportedDuration) {
        supportedDuration = DatatypeFactory.PT0S;
    }
    Expires ex = create.getExpires();
    if (null != ex) {
        Duration effectiveDuration = ex.getValue();
        // PT0S represents 0 second and the shortest duration but in ws-rm, considered the longest
        if (DatatypeFactory.PT0S.equals(effectiveDuration) || (!DatatypeFactory.PT0S.equals(supportedDuration) && supportedDuration.isShorterThan(effectiveDuration))) {
            effectiveDuration = supportedDuration;
        }
        ex = new Expires();
        ex.setValue(effectiveDuration);
        createResponse.setExpires(ex);
    }
    OfferType offer = create.getOffer();
    if (null != offer) {
        AcceptType accept = new AcceptType();
        if (dp.isAcceptOffers()) {
            Source source = reliableEndpoint.getSource();
            LOG.fine("Accepting inbound sequence offer");
            // AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, false);
            accept.setAcksTo(RMUtils.createReference(maps.getTo().getValue()));
            SourceSequence seq = new SourceSequence(offer.getIdentifier(), null, createResponse.getIdentifier(), protocol);
            seq.setExpires(offer.getExpires());
            seq.setTarget(create.getAcksTo());
            source.addSequence(seq);
            source.setCurrent(createResponse.getIdentifier(), seq);
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("Making offered sequence the current sequence for responses to " + createResponse.getIdentifier().getValue());
            }
        } else {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("Refusing inbound sequence offer");
            }
            accept.setAcksTo(RMUtils.createNoneReference());
        }
        createResponse.setAccept(accept);
    }
    DestinationSequence seq = new DestinationSequence(createResponse.getIdentifier(), create.getAcksTo(), destination, protocol);
    seq.setCorrelationID(maps.getMessageID().getValue());
    destination.addSequence(seq);
    LOG.fine("returning " + createResponse);
    return codec.convertToSend(createResponse);
}
Also used : Message(org.apache.cxf.message.Message) Duration(javax.xml.datatype.Duration) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType) AcceptType(org.apache.cxf.ws.rm.v200702.AcceptType) OfferType(org.apache.cxf.ws.rm.v200702.OfferType) CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) Expires(org.apache.cxf.ws.rm.v200702.Expires)

Example 4 with Expires

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires in project cxf by apache.

the class VersionTransformer method convert.

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

Example 5 with Expires

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires in project cxf by apache.

the class VersionTransformer method convert.

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

Aggregations

CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)16 CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)12 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)10 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)9 Expires (org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires)9 Test (org.junit.Test)7 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)5 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)5 Message (org.apache.cxf.message.Message)5 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)5 Expires (org.apache.cxf.ws.rm.v200702.Expires)5 CreateCoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType)5 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)4 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)4 SoapFault (com.arjuna.webservices.SoapFault)4 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)4 SystemException (com.arjuna.wst.SystemException)4 TransactionRolledBackException (com.arjuna.wst.TransactionRolledBackException)4 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)4 WrongStateException (com.arjuna.wst.WrongStateException)4