Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(
Sandesha2Constants.MessageParts.SEQUENCE);
Iterator ackRequestedIter = rmMsgCtx.getMessageParts(
Sandesha2Constants.MessageParts.ACK_REQUEST);
CloseSequence closeSequence = (CloseSequence) rmMsgCtx.getMessagePart(
Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
CloseSequenceResponse closeSequenceResponse = (CloseSequenceResponse) rmMsgCtx.getMessagePart(
Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE);
MakeConnection makeConnection = (MakeConnection) rmMsgCtx.getMessagePart(
Sandesha2Constants.MessageParts.MAKE_CONNECTION);
// Setting message type.
if (createSequence != null) {
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ);
} else if (createSequenceResponse != null) {
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ_RESPONSE);
sequenceID = createSequenceResponse.getIdentifier().getIdentifier();
} else if (terminateSequence != null) {
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ);
sequenceID = terminateSequence.getIdentifier().getIdentifier();
} else if (terminateSequenceResponse != null) {
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE);
sequenceID = terminateSequenceResponse.getIdentifier().getIdentifier();
} else if (rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE) != null) {
Sequence seq = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
LastMessage lastMessage = seq.getLastMessage();
SOAPEnvelope envelope = rmMsgCtx.getSOAPEnvelope();
if (lastMessage!=null && envelope.getBody().getFirstOMChild()==null) {
//the message is an empty body last message
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.LAST_MESSAGE);
}else
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
sequenceID = sequence.getIdentifier().getIdentifier();
} else if (sequenceAcknowledgementsIter.hasNext()) {
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK);
SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) sequenceAcknowledgementsIter.next();
//if there is only on sequenceAck, sequenceId will be set. Otherwise it will not be.
if (!sequenceAcknowledgementsIter.hasNext())
sequenceID = sequenceAcknowledgement.getIdentifier().getIdentifier();
} else if (ackRequestedIter.hasNext()) {
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK_REQUEST);
AckRequested ackRequest = (AckRequested) ackRequestedIter.next();
//if there is only on sequenceAck, sequenceId will be set. Otherwise it will not be.
if (!ackRequestedIter.hasNext())
sequenceID = ackRequest.getIdentifier().getIdentifier();
} else if (closeSequence != null) {
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE);
sequenceID = closeSequence.getIdentifier().getIdentifier();
} else if (closeSequenceResponse != null) {
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE_RESPONSE);
sequenceID = closeSequenceResponse.getIdentifier().getIdentifier();
} else if (makeConnection != null){
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.MAKE_CONNECTION_MSG);