Search in sources :

Example 71 with Identifier

use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.

the class SoapFaultFactoryTest method createSoap12FaultWithIdentifierDetail.

@Test
public void createSoap12FaultWithIdentifierDetail() {
    SoapBinding sb = control.createMock(SoapBinding.class);
    EasyMock.expect(sb.getSoapVersion()).andReturn(Soap12.getInstance());
    Identifier id = new Identifier();
    id.setValue("sid");
    setupSequenceFault(true, RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME, id);
    control.replay();
    SoapFaultFactory factory = new SoapFaultFactory(sb);
    SoapFault fault = (SoapFault) factory.createFault(sf, createInboundMessage());
    assertEquals("reason", fault.getReason());
    assertEquals(Soap12.getInstance().getSender(), fault.getFaultCode());
    assertEquals(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME, fault.getSubCode());
    Element elem = fault.getDetail();
    assertEquals(RM10Constants.NAMESPACE_URI, elem.getNamespaceURI());
    assertEquals("Identifier", elem.getLocalName());
    control.verify();
}
Also used : SoapFault(org.apache.cxf.binding.soap.SoapFault) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Element(org.w3c.dom.Element) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) Test(org.junit.Test)

Example 72 with Identifier

use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.

the class RetransmissionQueueImplTest method setUpSequence.

private SourceSequence setUpSequence(String sid, Long[] messageNumbers, boolean[] isAcked) {
    SourceSequence sequence = createMock(SourceSequence.class);
    Identifier id = createMock(Identifier.class);
    sequence.getIdentifier();
    EasyMock.expectLastCall().andReturn(id).anyTimes();
    id.getValue();
    EasyMock.expectLastCall().andReturn(sid).anyTimes();
    identifiers.add(id);
    Source source = createMock(Source.class);
    sequence.getSource();
    EasyMock.expectLastCall().andReturn(source).anyTimes();
    source.getReliableEndpoint();
    EasyMock.expectLastCall().andReturn(endpoint).anyTimes();
    boolean includesAcked = false;
    for (int i = 0; isAcked != null && i < isAcked.length; i++) {
        sequence.isAcknowledged(messageNumbers[i]);
        EasyMock.expectLastCall().andReturn(isAcked[i]);
        if (isAcked[i]) {
            includesAcked = true;
        }
    }
    if (includesAcked) {
        RMStore store = createMock(RMStore.class);
        manager.getStore();
        EasyMock.expectLastCall().andReturn(store);
    }
    return sequence;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Source(org.apache.cxf.ws.rm.Source) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint)

Example 73 with Identifier

use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.

the class RMInInterceptor method processAcknowledgments.

void processAcknowledgments(RMEndpoint rme, RMProperties rmps, ProtocolVariation protocol) throws SequenceFault, RMException {
    Collection<SequenceAcknowledgement> acks = rmps.getAcks();
    Source source = rme.getSource();
    if (null != acks) {
        for (SequenceAcknowledgement ack : acks) {
            Identifier id = ack.getIdentifier();
            SourceSequence ss = source.getSequence(id);
            if (null != ss) {
                ss.setAcknowledged(ack);
            } else {
                RMConstants consts = protocol.getConstants();
                SequenceFaultFactory sff = new SequenceFaultFactory(consts);
                throw sff.createUnknownSequenceFault(id);
            }
        }
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 74 with Identifier

use of org.geotoolkit.sml.xml.v100.Identifier 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 75 with Identifier

use of org.geotoolkit.sml.xml.v100.Identifier 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)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 Test (org.junit.Test)43 ArrayList (java.util.ArrayList)13 Message (org.apache.cxf.message.Message)11 SourceSequence (org.apache.cxf.ws.rm.SourceSequence)11 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)11 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)11 Connection (java.sql.Connection)9 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)8 SQLException (java.sql.SQLException)7 Date (java.util.Date)7 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)7 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)7 InputStream (java.io.InputStream)6 Method (java.lang.reflect.Method)6 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)6 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)6 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)6 JAXBElement (javax.xml.bind.JAXBElement)5 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)5