Search in sources :

Example 26 with SequenceAcknowledgement

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

the class RMTxStore method getDestinationSequence.

public DestinationSequence getDestinationSequence(Identifier sid) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.info("Getting destination sequence for id: " + sid);
    }
    Connection con = verifyConnection();
    PreparedStatement stmt = null;
    SQLException conex = null;
    ResultSet res = null;
    try {
        stmt = getStatement(con, SELECT_DEST_SEQUENCE_STMT_STR);
        stmt.setString(1, sid.getValue());
        res = stmt.executeQuery();
        if (res.next()) {
            EndpointReferenceType acksTo = RMUtils.createReference(res.getString(1));
            long lm = res.getLong(2);
            ProtocolVariation pv = decodeProtocolVersion(res.getString(3));
            boolean t = res.getBoolean(4);
            InputStream is = res.getBinaryStream(5);
            SequenceAcknowledgement ack = null;
            if (null != is) {
                ack = PersistenceUtils.getInstance().deserialiseAcknowledgment(is);
            }
            return new DestinationSequence(sid, acksTo, lm, t, ack, pv);
        }
    } catch (SQLException ex) {
        conex = ex;
        LOG.log(Level.WARNING, new Message("SELECT_DEST_SEQ_FAILED_MSG", LOG).toString(), ex);
    } finally {
        releaseResources(stmt, res);
        updateConnectionState(con, conex);
    }
    return null;
}
Also used : DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Message(org.apache.cxf.common.i18n.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) SQLException(java.sql.SQLException) InputStream(java.io.InputStream) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Example 27 with SequenceAcknowledgement

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

the class RMTxStore method getDestinationSequences.

public Collection<DestinationSequence> getDestinationSequences(String endpointIdentifier) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.info("Getting destination sequences for endpoint: " + endpointIdentifier);
    }
    Connection con = verifyConnection();
    PreparedStatement stmt = null;
    SQLException conex = null;
    Collection<DestinationSequence> seqs = new ArrayList<>();
    ResultSet res = null;
    try {
        stmt = getStatement(con, SELECT_DEST_SEQUENCES_STMT_STR);
        stmt.setString(1, endpointIdentifier);
        res = stmt.executeQuery();
        while (res.next()) {
            Identifier sid = new Identifier();
            sid.setValue(res.getString(1));
            EndpointReferenceType acksTo = RMUtils.createReference(res.getString(2));
            long lm = res.getLong(3);
            ProtocolVariation pv = decodeProtocolVersion(res.getString(4));
            boolean t = res.getBoolean(5);
            InputStream is = res.getBinaryStream(6);
            SequenceAcknowledgement ack = null;
            if (null != is) {
                ack = PersistenceUtils.getInstance().deserialiseAcknowledgment(is);
            }
            DestinationSequence seq = new DestinationSequence(sid, acksTo, lm, t, ack, pv);
            seqs.add(seq);
        }
    } catch (SQLException ex) {
        conex = ex;
        LOG.log(Level.WARNING, new Message("SELECT_DEST_SEQ_FAILED_MSG", LOG).toString(), ex);
    } finally {
        releaseResources(stmt, res);
        updateConnectionState(con, conex);
    }
    return seqs;
}
Also used : EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Message(org.apache.cxf.common.i18n.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) SQLException(java.sql.SQLException) InputStream(java.io.InputStream) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ResultSet(java.sql.ResultSet) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Example 28 with SequenceAcknowledgement

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

the class RMSoapInInterceptor method decodeHeaders.

public void decodeHeaders(SoapMessage message, List<Header> headers, RMProperties rmps) {
    try {
        Collection<SequenceAcknowledgement> acks = new ArrayList<>();
        Collection<AckRequestedType> requested = new ArrayList<>();
        String rmUri = null;
        EncoderDecoder codec = null;
        Iterator<Header> iter = headers.iterator();
        while (iter.hasNext()) {
            Object node = iter.next().getObject();
            if (node instanceof Element) {
                Element elem = (Element) node;
                if (Node.ELEMENT_NODE != elem.getNodeType()) {
                    continue;
                }
                String ns = elem.getNamespaceURI();
                if (rmUri == null && (RM10Constants.NAMESPACE_URI.equals(ns) || RM11Constants.NAMESPACE_URI.equals(ns))) {
                    LOG.log(Level.FINE, "set RM namespace {0}", ns);
                    rmUri = ns;
                    rmps.exposeAs(rmUri);
                }
                if (rmUri != null && rmUri.equals(ns)) {
                    if (codec == null) {
                        String wsauri = null;
                        AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, false, false);
                        if (maps == null) {
                            RMConfiguration config = getManager(message).getEffectiveConfiguration(message);
                            wsauri = config.getAddressingNamespace();
                        } else {
                            wsauri = maps.getNamespaceURI();
                        }
                        ProtocolVariation protocol = ProtocolVariation.findVariant(rmUri, wsauri);
                        if (protocol == null) {
                            LOG.log(Level.WARNING, "NAMESPACE_ERROR_MSG", wsauri);
                            break;
                        }
                        codec = protocol.getCodec();
                    }
                    String localName = elem.getLocalName();
                    LOG.log(Level.FINE, "decoding RM header {0}", localName);
                    if (RMConstants.SEQUENCE_NAME.equals(localName)) {
                        rmps.setSequence(codec.decodeSequenceType(elem));
                        rmps.setCloseSequence(codec.decodeSequenceTypeCloseSequence(elem));
                    } else if (RMConstants.SEQUENCE_ACK_NAME.equals(localName)) {
                        acks.add(codec.decodeSequenceAcknowledgement(elem));
                    } else if (RMConstants.ACK_REQUESTED_NAME.equals(localName)) {
                        requested.add(codec.decodeAckRequestedType(elem));
                    }
                }
            }
        }
        if (!acks.isEmpty()) {
            rmps.setAcks(acks);
        }
        if (!requested.isEmpty()) {
            rmps.setAcksRequested(requested);
        }
    } catch (JAXBException ex) {
        LOG.log(Level.WARNING, "SOAP_HEADER_DECODE_FAILURE_MSG", ex);
    }
}
Also used : EncoderDecoder(org.apache.cxf.ws.rm.EncoderDecoder) Element(org.w3c.dom.Element) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) RMConfiguration(org.apache.cxf.ws.rm.RMConfiguration) Header(org.apache.cxf.headers.Header) AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Example 29 with SequenceAcknowledgement

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

the class SoapFaultFactory method setDetail.

void setDetail(SoapFault fault, Object detail, EncoderDecoder codec) throws Exception {
    String name = fault.getSubCode().getLocalPart();
    Element element = null;
    if (RMConstants.INVALID_ACKNOWLEDGMENT_FAULT_CODE.equals(name)) {
        element = codec.encodeSequenceAcknowledgement((SequenceAcknowledgement) detail);
    } else if (!RMConstants.CREATE_SEQUENCE_REFUSED_FAULT_CODE.equals(name) && !RMConstants.WSRM_REQUIRED_FAULT_CODE.equals(name)) {
        element = codec.encodeIdentifier((Identifier) detail);
    }
    fault.setDetail(element);
}
Also used : Element(org.w3c.dom.Element) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 30 with SequenceAcknowledgement

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

the class DestinationSequenceTest method testConstructors.

@Test
public void testConstructors() {
    Identifier otherId = factory.createIdentifier();
    otherId.setValue("otherSeq");
    DestinationSequence seq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
    assertEquals(id, seq.getIdentifier());
    assertEquals(0, seq.getLastMessageNumber());
    assertSame(ref, seq.getAcksTo());
    assertNotNull(seq.getAcknowledgment());
    assertNotNull(seq.getMonitor());
    SequenceAcknowledgement ack = new SequenceAcknowledgement();
    seq = new DestinationSequence(id, ref, 10, ack, ProtocolVariation.RM10WSA200408);
    assertEquals(id, seq.getIdentifier());
    assertEquals(10, seq.getLastMessageNumber());
    assertSame(ref, seq.getAcksTo());
    assertSame(ack, seq.getAcknowledgment());
    assertNotNull(seq.getMonitor());
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) Test(org.junit.Test)

Aggregations

SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)33 Test (org.junit.Test)11 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)10 ArrayList (java.util.ArrayList)6 AckRequestedType (org.apache.cxf.ws.rm.v200702.AckRequestedType)6 AcknowledgementRange (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange)5 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)5 Element (org.w3c.dom.Element)5 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)4 CloseSequenceType (org.apache.cxf.ws.rm.v200702.CloseSequenceType)4 CreateSequenceType (org.apache.cxf.ws.rm.v200702.CreateSequenceType)4 TerminateSequenceType (org.apache.cxf.ws.rm.v200702.TerminateSequenceType)4 InputStream (java.io.InputStream)3 Connection (java.sql.Connection)3 JAXBElement (javax.xml.bind.JAXBElement)3 QName (javax.xml.namespace.QName)3 SoapHeader (org.apache.cxf.binding.soap.SoapHeader)3 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)3 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)3 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)3