Search in sources :

Example 76 with Identifier

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

Example 77 with Identifier

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

the class RMTxStore method createSourceSequence.

public void createSourceSequence(SourceSequence seq) {
    String sequenceIdentifier = seq.getIdentifier().getValue();
    String endpointIdentifier = seq.getEndpointIdentifier();
    String protocolVersion = encodeProtocolVersion(seq.getProtocol());
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Creating source sequence: " + sequenceIdentifier + ", (endpoint: " + endpointIdentifier + ")");
    }
    Connection con = verifyConnection();
    PreparedStatement stmt = null;
    SQLException conex = null;
    try {
        beginTransaction();
        stmt = getStatement(con, CREATE_SRC_SEQUENCE_STMT_STR);
        stmt.setString(1, sequenceIdentifier);
        Date expiry = seq.getExpires();
        stmt.setLong(2, expiry == null ? 0 : expiry.getTime());
        Identifier osid = seq.getOfferingSequenceIdentifier();
        stmt.setString(3, osid == null ? null : osid.getValue());
        stmt.setString(4, endpointIdentifier);
        stmt.setString(5, protocolVersion);
        stmt.execute();
        commit(con);
    } catch (SQLException ex) {
        conex = ex;
        abort(con);
        throw new RMStoreException(ex);
    } finally {
        releaseResources(stmt, null);
        updateConnectionState(con, conex);
    }
}
Also used : RMStoreException(org.apache.cxf.ws.rm.persistence.RMStoreException) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) Date(java.util.Date)

Example 78 with Identifier

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

the class ManagedRMEndpoint method getSourceSeq.

private SourceSequence getSourceSeq(String sid) {
    Source source = endpoint.getSource();
    Identifier identifier = RMUtils.getWSRMFactory().createIdentifier();
    identifier.setValue(sid);
    return source.getSequence(identifier);
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier)

Example 79 with Identifier

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

the class ManagedRMEndpoint method getDestinationSeq.

private DestinationSequence getDestinationSeq(String sid) {
    Destination destination = endpoint.getDestination();
    Identifier identifier = RMUtils.getWSRMFactory().createIdentifier();
    identifier.setValue(sid);
    return destination.getSequence(identifier);
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier)

Example 80 with Identifier

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

the class RMOutInterceptor method handle.

protected void handle(Message msg) throws SequenceFault, RMException {
    AddressingProperties maps = ContextUtils.retrieveMAPs(msg, false, true, false);
    if (null == maps) {
        LogUtils.log(LOG, Level.WARNING, "MAPS_RETRIEVAL_FAILURE_MSG");
        return;
    }
    if (Boolean.TRUE.equals(msg.get(RMMessageConstants.RM_RETRANSMISSION))) {
        return;
    }
    if (isRuntimeFault(msg)) {
        return;
    }
    RMConfiguration config = getManager().getEffectiveConfiguration(msg);
    String wsaNamespace = config.getAddressingNamespace();
    String rmNamespace = config.getRMNamespace();
    ProtocolVariation protocol = ProtocolVariation.findVariant(rmNamespace, wsaNamespace);
    RMContextUtils.setProtocolVariation(msg, protocol);
    Destination destination = getManager().getDestination(msg);
    String action = null;
    if (null != maps.getAction()) {
        action = maps.getAction().getValue();
    }
    // make sure we use the appropriate namespace
    maps.exposeAs(wsaNamespace);
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Action: " + action);
    }
    boolean isApplicationMessage = !RMContextUtils.isRMProtocolMessage(action);
    boolean isPartialResponse = MessageUtils.isPartialResponse(msg);
    RMConstants constants = protocol.getConstants();
    RMProperties rmpsOut = RMContextUtils.retrieveRMProperties(msg, true);
    if (isApplicationMessage && !isPartialResponse) {
        addRetransmissionInterceptor(msg);
    }
    Identifier inSeqId = null;
    if (isApplicationMessage) {
        RMProperties rmpsIn = RMContextUtils.retrieveRMProperties(msg, false);
        if (null != rmpsIn && null != rmpsIn.getSequence()) {
            inSeqId = rmpsIn.getSequence().getIdentifier();
            SourceSequence seq = rmpsIn.getSourceSequence();
            SequenceType sequence = rmpsIn.getSequence();
            if (seq == null || sequence == null) {
                LOG.warning("sequence not set for outbound message, skipped acknowledgement request");
            } else {
                addAckRequest(msg, rmpsIn, seq, sequence);
            }
        }
    }
    // add Acknowledgements (to application messages or explicitly created Acknowledgement messages only)
    boolean isAck = constants.getSequenceAckAction().equals(action);
    boolean isClose = constants.getCloseSequenceAction().equals(action);
    boolean isTerminate = constants.getTerminateSequenceAction().equals(action);
    if (isApplicationMessage || isAck || isClose || isTerminate) {
        AttributedURIType to = maps.getTo();
        assert null != to;
        addAcknowledgements(destination, rmpsOut, inSeqId, to);
        if (isPartialResponse && rmpsOut.getAcks() != null && rmpsOut.getAcks().size() > 0) {
            setAction(maps, constants.getSequenceAckAction());
            msg.remove(Message.EMPTY_PARTIAL_RESPONSE_MESSAGE);
            isAck = true;
        }
    }
    if (isAck || (isTerminate && RM10Constants.NAMESPACE_URI.equals(rmNamespace))) {
        maps.setReplyTo(RMUtils.createNoneReference());
    }
    assertReliability(msg);
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType)

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