}
if (RMHelper.isCloseSequence(rmReqProps))
{
Map<QName, RMSerializable> data = (Map<QName, RMSerializable>)rmReqProps.get(RMConstant.PROTOCOL_MESSAGES_MAPPING);
RMCloseSequence payload = (RMCloseSequence)data.get(rmConstants.getCloseSequenceQName());
String seqIdentifier = payload.getIdentifier();
sequence = RMStore.deserialize(dataDir, seqIdentifier, true);
if (sequence == null)
{
throw getUnknownSequenceFault(seqIdentifier);
}
sequence.close();
RMStore.serialize(dataDir, sequence);
protocolMessages.add(rmConstants.getCloseSequenceResponseQName());
protocolMessages.add(rmConstants.getSequenceAcknowledgementQName());
rmResponseContext.put(RMConstant.SEQUENCE_REFERENCE, sequence);
isOneWayOperation = false;
}
if (RMHelper.isSequenceAcknowledgement(rmReqProps))
{
Map<QName, RMSerializable> data = (Map<QName, RMSerializable>)rmReqProps.get(RMConstant.PROTOCOL_MESSAGES_MAPPING);
RMSequenceAcknowledgement payload = (RMSequenceAcknowledgement)data.get(rmConstants.getSequenceAcknowledgementQName());
String seqIdentifier = payload.getIdentifier();
sequence = RMStore.deserialize(dataDir, seqIdentifier, false);
if (sequence == null)
{
throw getUnknownSequenceFault(seqIdentifier);
}
for (RMSequenceAcknowledgement.RMAcknowledgementRange range : payload.getAcknowledgementRanges())
{
for (long i = range.getLower(); i <= range.getUpper(); i++)
{
if (i > sequence.getLastMessageNumber())
{
// invalid acknowledgement - generating fault
RMStore.serialize(dataDir, sequence);
Map<String, Object> detailsMap = new HashMap<String, Object>(2);
detailsMap.put(RMFaultConstant.ACKNOWLEDGEMENT, range);
throw new RMFault(RMFaultCode.INVALID_ACKNOWLEDGEMENT, new HashMap<String, Object>(2));
}
sequence.addReceivedOutboundMessage(i);
}
}
RMStore.serialize(dataDir, sequence);
}
if (RMHelper.isTerminateSequence(rmReqProps))
{
Map<QName, RMSerializable> data = (Map<QName, RMSerializable>)rmReqProps.get(RMConstant.PROTOCOL_MESSAGES_MAPPING);
RMTerminateSequence payload = (RMTerminateSequence)data.get(rmConstants.getTerminateSequenceQName());
String seqIdentifier = payload.getIdentifier();
sequence = RMStore.deserialize(dataDir, seqIdentifier, true);
if (sequence == null)
{
throw getUnknownSequenceFault(seqIdentifier);
}
RMStore.serialize(dataDir, sequence);
if (RMProvider.get().getMessageFactory().newTerminateSequenceResponse() != null)
{
protocolMessages.add(rmConstants.getTerminateSequenceResponseQName());
protocolMessages.add(rmConstants.getSequenceAcknowledgementQName());
rmResponseContext.put(RMConstant.SEQUENCE_REFERENCE, sequence);
isOneWayOperation = false;
}
else
{
return null; // no WS-RM context propagated - WS-RM 1.0
}
}
if (RMHelper.isSequence(rmReqProps))
{
Map<QName, RMSerializable> data = (Map<QName, RMSerializable>)rmReqProps.get(RMConstant.PROTOCOL_MESSAGES_MAPPING);
RMSequence payload = (RMSequence)data.get(rmConstants.getSequenceQName());
String seqIdentifier = payload.getIdentifier();
sequence = RMStore.deserialize(dataDir, seqIdentifier, true);
if (sequence == null)
{
throw getUnknownSequenceFault(seqIdentifier);
}
try
{
sequence.addReceivedInboundMessage(payload.getMessageNumber());
}
finally
{
RMStore.serialize(dataDir, sequence);
}