Search in sources :

Example 6 with CreateSequenceResponseType

use of org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType 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 7 with CreateSequenceResponseType

use of org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType in project cxf by apache.

the class Servant method invoke.

public Object invoke(Exchange exchange, Object o) {
    LOG.fine("Invoking on RM Endpoint");
    final ProtocolVariation protocol = RMContextUtils.getProtocolVariation(exchange.getInMessage());
    OperationInfo oi = exchange.getBindingOperationInfo().getOperationInfo();
    if (null == oi) {
        LOG.fine("No operation info.");
        return null;
    }
    if (RM10Constants.INSTANCE.getCreateSequenceOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getCreateSequenceOperationName().equals(oi.getName()) || RM10Constants.INSTANCE.getCreateSequenceOnewayOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getCreateSequenceOnewayOperationName().equals(oi.getName())) {
        try {
            return Collections.singletonList(createSequence(exchange.getInMessage()));
        } catch (RuntimeException ex) {
            LOG.log(Level.WARNING, "Sequence creation rejected", ex);
            SequenceFault sf = new SequenceFaultFactory(protocol.getConstants()).createCreateSequenceRefusedFault();
            Endpoint e = exchange.getEndpoint();
            Binding b = null == e ? null : e.getBinding();
            if (null != b) {
                RMManager m = reliableEndpoint.getManager();
                LOG.fine("Manager: " + m);
                BindingFaultFactory bff = m.getBindingFaultFactory(b);
                Fault f = bff.createFault(sf, exchange.getInMessage());
                // log with warning instead sever, as this may happen for some delayed messages
                LogUtils.log(LOG, Level.WARNING, "SEQ_FAULT_MSG", bff.toString(f));
                throw f;
            }
            throw new Fault(sf);
        }
    } else if (RM10Constants.INSTANCE.getCreateSequenceResponseOnewayOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getCreateSequenceResponseOnewayOperationName().equals(oi.getName())) {
        EncoderDecoder codec = protocol.getCodec();
        CreateSequenceResponseType createResponse = codec.convertReceivedCreateSequenceResponse(getParameter(exchange.getInMessage()));
        createSequenceResponse(createResponse, protocol);
    } else if (RM10Constants.INSTANCE.getTerminateSequenceOperationName().equals(oi.getName()) || RM11Constants.INSTANCE.getTerminateSequenceOperationName().equals(oi.getName())) {
        Object tsr = terminateSequence(exchange.getInMessage());
        if (tsr != null) {
            return Collections.singletonList(tsr);
        }
    } else if (RM11Constants.INSTANCE.getCloseSequenceOperationName().equals(oi.getName())) {
        return Collections.singletonList(closeSequence(exchange.getInMessage()));
    }
    return null;
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Binding(org.apache.cxf.binding.Binding) Fault(org.apache.cxf.interceptor.Fault) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType) Endpoint(org.apache.cxf.endpoint.Endpoint)

Example 8 with CreateSequenceResponseType

use of org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType in project cxf by apache.

the class VersionTransformer method convert.

/**
 * Convert 200502 wsrm:CreateSequenceResponseType with 200508 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 CreateSequenceResponseType convert(org.apache.cxf.ws.rm.v200502wsa15.CreateSequenceResponseType exposed) {
    if (exposed == null) {
        return null;
    }
    CreateSequenceResponseType internal = new CreateSequenceResponseType();
    internal.setAccept(convert(exposed.getAccept()));
    internal.setExpires(convert(exposed.getExpires()));
    internal.setIdentifier(convert(exposed.getIdentifier()));
    addAll(exposed.getAny(), internal.getAny());
    putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
    return internal;
}
Also used : CreateSequenceResponseType(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType)

Example 9 with CreateSequenceResponseType

use of org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType in project cxf by apache.

the class RMInInterceptorTest method testHandleCreateSequenceOnClient.

@Test
public void testHandleCreateSequenceOnClient() throws SequenceFault, RMException {
    interceptor = new RMInInterceptor();
    Message message = setupInboundMessage(RM10Constants.CREATE_SEQUENCE_ACTION, false);
    rme.receivedControlMessage();
    EasyMock.expectLastCall();
    Servant servant = control.createMock(Servant.class);
    EasyMock.expect(rme.getServant()).andReturn(servant);
    CreateSequenceResponseType csr = control.createMock(CreateSequenceResponseType.class);
    EasyMock.expect(servant.createSequence(message)).andReturn(csr);
    Proxy proxy = control.createMock(Proxy.class);
    EasyMock.expect(rme.getProxy()).andReturn(proxy);
    proxy.createSequenceResponse(csr, ProtocolVariation.RM10WSA200408);
    EasyMock.expectLastCall();
    control.replay();
    interceptor.handle(message);
}
Also used : Message(org.apache.cxf.message.Message) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType) Test(org.junit.Test)

Example 10 with CreateSequenceResponseType

use of org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType in project cxf by apache.

the class ServantTest method verifyCreateSequenceExpiresSetAtBoth.

private void verifyCreateSequenceExpiresSetAtBoth(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_VERY_SHORT);
    Message message = createTestCreateSequenceMessage(expires, null);
    CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
    Expires expires2 = csr.getExpires();
    assertNotNull(expires2);
    assertEquals(DURATION_VERY_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)

Aggregations

Message (org.apache.cxf.message.Message)8 CreateSequenceResponseType (org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType)7 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)5 AcksPolicyType (org.apache.cxf.ws.rm.manager.AcksPolicyType)4 CreateSequenceResponseType (org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)4 Expires (org.apache.cxf.ws.rm.v200502.Expires)4 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)3 Endpoint (org.apache.cxf.endpoint.Endpoint)2 Exchange (org.apache.cxf.message.Exchange)2 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)2 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)2 Test (org.junit.Test)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Duration (javax.xml.datatype.Duration)1 Binding (org.apache.cxf.binding.Binding)1 Fault (org.apache.cxf.interceptor.Fault)1 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)1