// deleting the create sequence entry.
senderBeanMgr.delete(createSeqMsgId);
// storing new out sequence id
SequencePropertyBeanMgr sequencePropMgr = storageManager.getSequencePropertyBeanMgr();
SequencePropertyBean outSequenceBean = new SequencePropertyBean(sequencePropertyKey,
Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID, newOutSequenceId);
SequencePropertyBean internalSequenceBean = new SequencePropertyBean(newOutSequenceId,
Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID, sequencePropertyKey);
sequencePropMgr.insert(outSequenceBean);
sequencePropMgr.insert(internalSequenceBean);
// Store the security token under the new sequence id
if(tokenData != null) {
SequencePropertyBean newToken = new SequencePropertyBean(newOutSequenceId,
Sandesha2Constants.SequenceProperties.SECURITY_TOKEN, tokenData);
sequencePropMgr.insert(newToken);
}
// processing for accept (offer has been sent)
Accept accept = createSeqResponsePart.getAccept();
if (accept != null) {
// Find offered sequence from internal sequence id.
SequencePropertyBean offeredSequenceBean = sequencePropMgr.retrieve(sequencePropertyKey,
Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE);
// TODO this should be detected in the Fault manager.
if (offeredSequenceBean == null) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.accptButNoSequenceOffered);
log.debug(message);
throw new SandeshaException(message);
}
String offeredSequenceId = (String) offeredSequenceBean.getValue();
EndpointReference acksToEPR = accept.getAcksTo().getEPR();
SequencePropertyBean acksToBean = new SequencePropertyBean();
acksToBean.setName(Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);
acksToBean.setSequencePropertyKey(offeredSequenceId);
acksToBean.setValue(acksToEPR.getAddress());
sequencePropMgr.insert(acksToBean);
RMDBean rmdBean = new RMDBean();
rmdBean.setSequenceID(offeredSequenceId);
rmdBean.setNextMsgNoToProcess(1);
boolean pollingMode = false;
if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(createSeqResponseRMMsgCtx.getRMSpecVersion())) {
String replyToAddress = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
Sandesha2Constants.SequenceProperties.REPLY_TO_EPR, storageManager);
if (replyToAddress!=null) {
if (AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(replyToAddress))
pollingMode = true;
else if (AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(replyToAddress))
pollingMode = true;
else if (replyToAddress.startsWith(Sandesha2Constants.WSRM_ANONYMOUS_URI_PREFIX))
pollingMode = true;
}
}
//Storing the referenceMessage of the sending side sequence as the reference message
//of the receiving side as well.
//This can be used when creating new outgoing messages.
String referenceMsgStoreKey = rmsBean.getReferenceMessageStoreKey();
MessageContext referenceMsg = storageManager.retrieveMessageContext(referenceMsgStoreKey, configCtx);
String newMessageStoreKey = SandeshaUtil.getUUID();
storageManager.storeMessageContext(newMessageStoreKey,referenceMsg);
rmdBean.setReferenceMessageKey(newMessageStoreKey);
rmdBean.setPollingMode(pollingMode);
//if PollingMode is true, starting the pollingmanager.
if (pollingMode)
SandeshaUtil.startPollingManager(configCtx);
RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
rmdBeanMgr.insert(rmdBean);
String rmSpecVersion = createSeqResponseRMMsgCtx.getRMSpecVersion();
SequencePropertyBean specVersionBean = new SequencePropertyBean(offeredSequenceId,
Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION, rmSpecVersion);
sequencePropMgr.insert(specVersionBean);
SequencePropertyBean receivedMsgBean = new SequencePropertyBean(offeredSequenceId,
Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES, "");
sequencePropMgr.insert(receivedMsgBean);
SequencePropertyBean msgsBean = new SequencePropertyBean();
msgsBean.setSequencePropertyKey(offeredSequenceId);
msgsBean.setName(Sandesha2Constants.SequenceProperties.CLIENT_COMPLETED_MESSAGES);
msgsBean.setValue("");
sequencePropMgr.insert(msgsBean);
// setting the addressing version.
String addressingNamespace = createSeqResponseRMMsgCtx.getAddressingNamespaceValue();
SequencePropertyBean addressingVersionBean = new SequencePropertyBean(offeredSequenceId,
Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, addressingNamespace);
sequencePropMgr.insert(addressingVersionBean);
// Store the security token for the offered sequence
if(tokenData != null) {
SequencePropertyBean newToken = new SequencePropertyBean(offeredSequenceId,
Sandesha2Constants.SequenceProperties.SECURITY_TOKEN, tokenData);
sequencePropMgr.insert(newToken);
}
}