Search in sources :

Example 6 with ProtocolVariation

use of org.apache.cxf.ws.rm.ProtocolVariation in project cxf by apache.

the class RMTxStoreTestBase method setupSourceSequence.

private Identifier setupSourceSequence(String s) throws SQLException {
    SourceSequence seq = control.createMock(SourceSequence.class);
    Identifier sid = new Identifier();
    sid.setValue(s);
    Date expiry = null;
    Identifier osid = null;
    Long cmn = ONE;
    boolean lm = false;
    ProtocolVariation pv = ProtocolVariation.RM10WSA200408;
    if ("sequence2".equals(s)) {
        expiry = new Date(System.currentTimeMillis() + 3600 * 1000);
        osid = new Identifier();
        osid.setValue("offeringSequence");
        cmn = TEN;
        lm = true;
        pv = ProtocolVariation.RM11WSA200508;
    }
    EasyMock.expect(seq.getIdentifier()).andReturn(sid);
    EasyMock.expect(seq.getExpires()).andReturn(expiry);
    EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(osid);
    EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
    EasyMock.expect(seq.getCurrentMessageNr()).andReturn(cmn);
    EasyMock.expect(seq.isLastMessage()).andReturn(lm);
    EasyMock.expect(seq.getIdentifier()).andReturn(sid);
    EasyMock.expect(seq.getProtocol()).andReturn(pv);
    control.replay();
    store.createSourceSequence(seq);
    Connection con = getConnection();
    try {
        store.beginTransaction();
        store.updateSourceSequence(con, seq);
        store.commit(con);
    } finally {
        releaseConnection(con);
    }
    control.reset();
    return sid;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Connection(java.sql.Connection) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Date(java.util.Date) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Example 7 with ProtocolVariation

use of org.apache.cxf.ws.rm.ProtocolVariation in project cxf by apache.

the class RMTxStore method getSourceSequence.

public SourceSequence getSourceSequence(Identifier sid) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.info("Getting source sequences for id: " + sid);
    }
    Connection con = verifyConnection();
    PreparedStatement stmt = null;
    SQLException conex = null;
    ResultSet res = null;
    try {
        stmt = getStatement(con, SELECT_SRC_SEQUENCE_STMT_STR);
        stmt.setString(1, sid.getValue());
        res = stmt.executeQuery();
        if (res.next()) {
            long cmn = res.getLong(1);
            boolean lm = res.getBoolean(2);
            long lval = res.getLong(3);
            Date expiry = 0 == lval ? null : new Date(lval);
            String oidValue = res.getString(4);
            Identifier oi = null;
            if (null != oidValue) {
                oi = RMUtils.getWSRMFactory().createIdentifier();
                oi.setValue(oidValue);
            }
            ProtocolVariation pv = decodeProtocolVersion(res.getString(5));
            return new SourceSequence(sid, expiry, oi, cmn, lm, pv);
        }
    } catch (SQLException ex) {
        conex = ex;
        // ignore
        LOG.log(Level.WARNING, new Message("SELECT_SRC_SEQ_FAILED_MSG", LOG).toString(), ex);
    } finally {
        releaseResources(stmt, res);
        updateConnectionState(con, conex);
    }
    return null;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Message(org.apache.cxf.common.i18n.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Date(java.util.Date) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Example 8 with ProtocolVariation

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

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

use of org.apache.cxf.ws.rm.ProtocolVariation in project cxf by apache.

the class RMTxStore method getSourceSequences.

public Collection<SourceSequence> getSourceSequences(String endpointIdentifier) {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.info("Getting source sequences for endpoint: " + endpointIdentifier);
    }
    Connection con = verifyConnection();
    PreparedStatement stmt = null;
    SQLException conex = null;
    Collection<SourceSequence> seqs = new ArrayList<>();
    ResultSet res = null;
    try {
        stmt = getStatement(con, SELECT_SRC_SEQUENCES_STMT_STR);
        stmt.setString(1, endpointIdentifier);
        res = stmt.executeQuery();
        while (res.next()) {
            Identifier sid = new Identifier();
            sid.setValue(res.getString(1));
            long cmn = res.getLong(2);
            boolean lm = res.getBoolean(3);
            long lval = res.getLong(4);
            Date expiry = 0 == lval ? null : new Date(lval);
            String oidValue = res.getString(5);
            Identifier oi = null;
            if (null != oidValue) {
                oi = new Identifier();
                oi.setValue(oidValue);
            }
            ProtocolVariation pv = decodeProtocolVersion(res.getString(6));
            SourceSequence seq = new SourceSequence(sid, expiry, oi, cmn, lm, pv);
            seqs.add(seq);
        }
    } catch (SQLException ex) {
        conex = ex;
        // ignore
        LOG.log(Level.WARNING, new Message("SELECT_SRC_SEQ_FAILED_MSG", LOG).toString(), ex);
    } finally {
        releaseResources(stmt, res);
        updateConnectionState(con, conex);
    }
    return seqs;
}
Also used : Message(org.apache.cxf.common.i18n.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Date(java.util.Date) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ResultSet(java.sql.ResultSet) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Aggregations

ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)11 Connection (java.sql.Connection)6 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)5 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)5 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)4 Message (org.apache.cxf.common.i18n.Message)4 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)4 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 JAXBException (javax.xml.bind.JAXBException)3 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)3 Header (org.apache.cxf.headers.Header)3 Message (org.apache.cxf.message.Message)3 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)3 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)3 RMProperties (org.apache.cxf.ws.rm.RMProperties)3 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)3