use of org.apache.cxf.ws.rm.v200702.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;
}
use of org.apache.cxf.ws.rm.v200702.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());
}
}
use of org.apache.cxf.ws.rm.v200702.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());
}
}
}
use of org.apache.cxf.ws.rm.v200702.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);
}
use of org.apache.cxf.ws.rm.v200702.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());
}
Aggregations