Search in sources :

Example 1 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project midpoint by Evolveum.

the class RSequence method toJAXB.

@Override
public SequenceType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
    SequenceType object = new SequenceType();
    RUtil.revive(object, prismContext);
    RSequence.copyToJAXB(this, object, prismContext, options);
    return object;
}
Also used : SequenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType)

Example 2 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class Destination method acknowledge.

/**
 * Acknowledges receipt of a message. If the message is the last in the
 * sequence, sends an out-of-band SequenceAcknowledgement unless there a
 * response will be sent to the acksTo address onto which the acknowldegment
 * can be piggybacked.
 *
 * @param sequenceType the sequenceType object that includes identifier and
 *            message number (and possibly a lastMessage element) for the
 *            message to be acknowledged)
 * @param replyToAddress the replyTo address of the message that carried
 *            this sequence information
 * @throws SequenceFault if the sequence specified in
 *             <code>sequenceType</code> does not exist
 */
public void acknowledge(Message message) throws SequenceFault, RMException {
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    SequenceType sequenceType = rmps.getSequence();
    if (null == sequenceType) {
        return;
    }
    DestinationSequence seq = getSequence(sequenceType.getIdentifier());
    if (null != seq) {
        if (seq.applyDeliveryAssurance(sequenceType.getMessageNumber(), message)) {
            if (PropertyUtils.isTrue(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY))) {
                return;
            }
            seq.acknowledge(message);
            if (null != rmps.getCloseSequence()) {
                seq.setLastMessageNumber(sequenceType.getMessageNumber());
                ackImmediately(seq, message);
            }
        } else {
            try {
                message.getInterceptorChain().abort();
                if (seq.sendAcknowledgement()) {
                    ackImmediately(seq, message);
                }
                Exchange exchange = message.getExchange();
                Conduit conduit = exchange.getDestination().getBackChannel(message);
                if (conduit != null) {
                    // null if it knows it cannot send anything.
                    if (seq.sendAcknowledgement()) {
                        AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, false);
                        InternalContextUtils.rebaseResponse(null, maps, message);
                    } else {
                        Message response = createMessage(exchange);
                        response.setExchange(exchange);
                        response.remove(Message.CONTENT_TYPE);
                        conduit.prepare(response);
                        conduit.close(response);
                    }
                }
            } catch (IOException e) {
                LOG.log(Level.SEVERE, e.getMessage());
                throw new RMException(e);
            }
        }
    } else {
        ProtocolVariation protocol = RMContextUtils.getProtocolVariation(message);
        RMConstants consts = protocol.getConstants();
        SequenceFaultFactory sff = new SequenceFaultFactory(consts);
        throw sff.createUnknownSequenceFault(sequenceType.getIdentifier());
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) Conduit(org.apache.cxf.transport.Conduit) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) IOException(java.io.IOException)

Example 3 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class Destination method releaseDeliveringStatus.

void releaseDeliveringStatus(Message message) {
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    SequenceType sequenceType = rmps.getSequence();
    if (null != sequenceType) {
        DestinationSequence seq = getSequence(sequenceType.getIdentifier());
        if (null != seq) {
            seq.removeDeliveringMessageNumber(sequenceType.getMessageNumber());
        }
    }
}
Also used : SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType)

Example 4 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class DestinationSequence method acknowledge.

public void acknowledge(Message message) throws SequenceFault {
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    SequenceType st = rmps.getSequence();
    long messageNumber = st.getMessageNumber().longValue();
    LOG.fine("Acknowledging message: " + messageNumber);
    if (0 != lastMessageNumber && messageNumber > lastMessageNumber) {
        RMConstants consts = getProtocol().getConstants();
        SequenceFaultFactory sff = new SequenceFaultFactory(consts);
        throw sff.createSequenceTerminatedFault(st.getIdentifier(), false);
    }
    monitor.acknowledgeMessage();
    boolean updated = false;
    synchronized (this) {
        boolean done = false;
        int i = 0;
        for (; i < acknowledgement.getAcknowledgementRange().size(); i++) {
            AcknowledgementRange r = acknowledgement.getAcknowledgementRange().get(i);
            if (r.getLower().compareTo(messageNumber) <= 0 && r.getUpper().compareTo(messageNumber) >= 0) {
                done = true;
                break;
            }
            long diff = r.getLower() - messageNumber;
            if (diff == 1) {
                r.setLower(messageNumber);
                updated = true;
                done = true;
            } else if (diff > 0) {
                break;
            } else if (messageNumber - r.getUpper().longValue() == 1) {
                r.setUpper(messageNumber);
                updated = true;
                done = true;
                break;
            }
        }
        if (!done) {
            // need new acknowledgement range
            AcknowledgementRange range = new AcknowledgementRange();
            range.setLower(messageNumber);
            range.setUpper(messageNumber);
            updated = true;
            acknowledgement.getAcknowledgementRange().add(i, range);
            if (acknowledgement.getAcknowledgementRange().size() > 1) {
                // acknowledge out-of-order at first opportunity
                scheduleImmediateAcknowledgement();
            }
        }
        mergeRanges();
    }
    if (updated) {
        RMStore store = destination.getManager().getStore();
        if (null != store && !MessageUtils.getContextualBoolean(message, Message.ROBUST_ONEWAY)) {
            try {
                RMMessage msg = new RMMessage();
                CachedOutputStream cos = (CachedOutputStream) message.get(RMMessageConstants.SAVED_CONTENT);
                msg.setMessageNumber(st.getMessageNumber());
                msg.setCreatedTime(rmps.getCreatedTime());
                // in case no attachments are available, cos can be saved directly
                if (message.getAttachments() == null) {
                    msg.setContent(cos);
                    msg.setContentType((String) message.get(Message.CONTENT_TYPE));
                } else {
                    InputStream is = cos.getInputStream();
                    PersistenceUtils.encodeRMContent(msg, message, is);
                }
                store.persistIncoming(this, msg);
            } catch (IOException e) {
                throw new Fault(e);
            }
        }
    }
    deliveringMessageNumbers.add(messageNumber);
    RMEndpoint reliableEndpoint = destination.getReliableEndpoint();
    RMConfiguration cfg = reliableEndpoint.getConfiguration();
    if (null == rmps.getCloseSequence()) {
        scheduleAcknowledgement(cfg.getAcknowledgementIntervalTime());
    }
    long inactivityTimeout = cfg.getInactivityTimeoutTime();
    scheduleSequenceTermination(inactivityTimeout);
}
Also used : RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) InputStream(java.io.InputStream) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) Fault(org.apache.cxf.interceptor.Fault) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) IOException(java.io.IOException) CachedOutputStream(org.apache.cxf.io.CachedOutputStream) AcknowledgementRange(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange)

Example 5 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class EncoderDecoder10AImpl method decodeSequenceType.

public SequenceType decodeSequenceType(Element elem) throws JAXBException {
    Unmarshaller unmarshaller = getContext().createUnmarshaller();
    JAXBElement<org.apache.cxf.ws.rm.v200502wsa15.SequenceType> jaxbElement = unmarshaller.unmarshal(elem, org.apache.cxf.ws.rm.v200502wsa15.SequenceType.class);
    return VersionTransformer.convert(jaxbElement.getValue());
}
Also used : CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)33 CloseSequenceType (org.apache.cxf.ws.rm.v200702.CloseSequenceType)12 RMProperties (org.apache.cxf.ws.rm.RMProperties)11 CreateSequenceType (org.apache.cxf.ws.rm.v200702.CreateSequenceType)11 TerminateSequenceType (org.apache.cxf.ws.rm.v200702.TerminateSequenceType)11 SequenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType)9 Message (org.apache.cxf.message.Message)8 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 IOException (java.io.IOException)6 Unmarshaller (javax.xml.bind.Unmarshaller)5 AckRequestedType (org.apache.cxf.ws.rm.v200702.AckRequestedType)5 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)4 Endpoint (org.apache.cxf.endpoint.Endpoint)4 Exchange (org.apache.cxf.message.Exchange)4 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)4 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)4 Test (org.junit.Test)4 Test (org.testng.annotations.Test)4 SystemException (com.evolveum.midpoint.util.exception.SystemException)3