storageManager = storageManger;
}
public boolean processMessage(RMMessageContext rmMessageContext) throws AxisFault {
RMHeaders rmHeaders = rmMessageContext.getRMHeaders();
AddressingHeaders addrHeaders = rmMessageContext.getAddressingHeaders();
AcknowledgementProcessor ackProcessor = new AcknowledgementProcessor(storageManager);
if (rmHeaders.getSequenceAcknowledgement() != null) {
ackProcessor.processMessage(rmMessageContext);
}
if (rmHeaders.getSequence() != null) {
if (rmHeaders.getSequence().getMessageNumber() != null) {
String sequenceUUID = rmHeaders.getSequence().getIdentifier().getIdentifier();
long messageNumber = rmHeaders.getSequence().getMessageNumber().getMessageNumber();
String seqId = storageManager.getOutgoingSeqenceIdOfIncomingMsg(rmMessageContext);
boolean hasSequence = storageManager.isSequenceExist(seqId);
if (addrHeaders.getRelatesTo() != null && !addrHeaders.getRelatesTo().isEmpty()) {
RelatesTo relatesTo = (RelatesTo) addrHeaders.getRelatesTo().get(0);
String messageId = relatesTo.getURI().toString();
seqId = storageManager.getOutgoingSeqOfMsg(messageId);
}
if (!hasSequence) {
storageManager.addIncomingSequence(seqId);
}
if (!storageManager.isMessageExist(seqId, messageNumber)) {
//Create a copy of the RMMessageContext.
RMMessageContext rmMsgContext = new RMMessageContext();
//Copy the RMMEssageContext
rmMessageContext.copyContents(rmMsgContext);
rmMsgContext.setSequenceID(sequenceUUID);
rmMsgContext.setMsgNumber(messageNumber);
try {
MessageContext msgContext = new MessageContext(rmMessageContext.getMsgContext().getAxisEngine());
RMMessageContext.copyMessageContext(rmMessageContext.getMsgContext(),
msgContext);
String soapMsg = rmMessageContext.getMsgContext().getRequestMessage()
.getSOAPEnvelope()
.toString();
Message reqMsg = new Message(soapMsg);
msgContext.setRequestMessage(reqMsg);
rmMsgContext.setMsgContext(msgContext);
rmMsgContext.setMessageType(Constants.MSG_TYPE_SERVICE_REQUEST);
} catch (Exception e) {
log.error(e);
throw new AxisFault(new QName(Constants.FaultCodes.WSRM_SERVER_INTERNAL_ERROR),
Constants.FaultMessages.SERVER_INTERNAL_ERROR, null, null);
}
storageManager.insertIncomingMessage(rmMsgContext);
}
// refresh the ack for every message arrived
//But send only if needed.
if (rmHeaders.getAckRequest() != null ||
rmHeaders.getSequence().getLastMessage() != null) {
storageManager.sendAck(sequenceUUID);
return ackProcessor.sendAcknowledgement(rmMessageContext);
} else {
boolean sync = ackProcessor.sendAcknowledgement(rmMessageContext);
return sync;