String identifier = terminateSequence.getIdentifier().getStringValue();
sequenceStore.delete(identifier);
}
public SequenceAcknowledgementDocument assertValid(SequenceDocument doc) {
SequenceType sequence = doc.getSequence();
String identifier = sequence.getIdentifier().getStringValue();
Sequence s = sequenceStore.retrieve(identifier);
if( s == null ) {
throw new SoapFault(
"The value of wsrm:Identifier is not a known Sequence identifier",
"Sender",
"wsrm:UnknownSequence",
sequence.getIdentifier().xmlText());
}
// Is the message number out of range?
BigInteger value = sequence.getMessageNumber();
if( value.compareTo(BigInteger.ZERO) <= 0 || value.compareTo(MAX_INTEGER)>0 ) {
// We must terminate the sequence now.
sequenceStore.delete(identifier);
throw new SoapFault(
"The maximum value for wsrm:MessageNumber has been exceeded",
"Sender",
"wsrm:MessageNumberRollover",
sequence.getIdentifier().xmlText());
}
int intValue = value.intValue();
// If we received the last message, then check to see if the message being
// processed exceeds it's sequence.
if( s.lastMessageNumber>0 && intValue > s.lastMessageNumber) {
throw new SoapFault(
"The value for wsrm:MessageNumber exceeds the value of the MessageNumber accompanying a LastMessage element in this Sequence.",
"Sender",
"wsrm:LastMessageNumberExceeded",
sequence.getIdentifier().xmlText());
}
// Is this message comming out of order??
if( intValue!=s.lastMessageAcked+1) {
// This implementation is really simple and just drops out of order
// messages.
SequenceAcknowledgementDocument resultDoc = SequenceAcknowledgementDocument.Factory.newInstance();
SequenceAcknowledgement acknowledgement = resultDoc.addNewSequenceAcknowledgement();
acknowledgement.setIdentifier(sequence.getIdentifier());
if( s.lastMessageAcked> 0 ) {
AcknowledgementRange range = acknowledgement.addNewAcknowledgementRange();
range.setLower(BigInteger.ONE);
range.setUpper(new BigInteger(""+s.lastMessageAcked));
}