//deleting the create sequence entry.
retransmitterMgr.delete(createSeqMsgId);
//storing new out sequence id
SequencePropertyBeanMgr sequencePropMgr = storageManager
.getSequencePropretyBeanMgr();
SequencePropertyBean outSequenceBean = new SequencePropertyBean(
internalSequenceId, Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID,
newOutSequenceId);
SequencePropertyBean internalSequenceBean = new SequencePropertyBean(
newOutSequenceId,
Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID, internalSequenceId);
sequencePropMgr.insert(outSequenceBean);
sequencePropMgr.insert(internalSequenceBean);
createSeqResponseTransaction.commit();
Transaction offerProcessTransaction = storageManager.getTransaction();
//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(internalSequenceId,
Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE);
//TODO this should be detected in the Fault manager.
if (offeredSequenceBean == null) {
String message = "No offered sequence entry. But an accept was received";
log.debug(message);
throw new SandeshaException(message);
}
String offeredSequenceId = (String) offeredSequenceBean.getValue();
EndpointReference acksToEPR = accept.getAcksTo().getAddress()
.getEpr();
SequencePropertyBean acksToBean = new SequencePropertyBean();
acksToBean.setName(Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);
acksToBean.setSequenceID(offeredSequenceId);
acksToBean.setValue(acksToEPR.getAddress());
sequencePropMgr.insert(acksToBean);
NextMsgBean nextMsgBean = new NextMsgBean();
nextMsgBean.setSequenceID(offeredSequenceId);
nextMsgBean.setNextMsgNoToProcess(1);
NextMsgBeanMgr nextMsgMgr = storageManager.getNextMsgBeanMgr();
nextMsgMgr.insert(nextMsgBean);
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.setSequenceID(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);
}
offerProcessTransaction.commit();