FaultManager faultManager = new FaultManager();
RMMsgContext faultMessageContext = faultManager.checkForCreateSequenceRefused(createSeqMsg);
if (faultMessageContext != null) {
ConfigurationContext configurationContext = createSeqMsg.getConfigurationContext();
AxisEngine engine = new AxisEngine(configurationContext);
try {
engine.sendFault(faultMessageContext.getMessageContext());
} catch (AxisFault e) {
throw new SandeshaException ("Could not send the fault message",e);
}
return;
}
MessageContext outMessage = null;
outMessage = Utils.createOutMessageContext(createSeqMsg); //createing a new response message.
ConfigurationContext context = createSeqMsg.getConfigurationContext();
StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context);
SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
Transaction createSequenceTransaction = storageManager.getTransaction(); //begining of a new transaction
try {
String newSequenceId = SequenceManager.setupNewSequence(createSeqRMMsg); //newly created sequnceID.
RMMsgContext createSeqResponse = RMMsgCreator.createCreateSeqResponseMsg(
createSeqRMMsg, outMessage,newSequenceId); // converting the blank out message in to a create
// sequence response.
createSeqResponse.setFlow(MessageContext.OUT_FLOW);
createSeqResponse.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE,"true"); //for making sure that this wont be processed again.
CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
//OFFER PROCESSING
SequenceOffer offer = createSeqPart.getSequenceOffer();
if (offer != null) {
Accept accept = createSeqResPart.getAccept();
if (accept == null) {
String message = "An accept part has not been generated for the create seq request with an offer part";
log.debug(message);
throw new SandeshaException(message);
}
String offeredSequenceID = offer.getIdentifer().getIdentifier(); //offered seq. id.
boolean offerEcepted = offerAccepted (offeredSequenceID,context,createSeqRMMsg);
if (offerEcepted) {
//Setting the CreateSequence table entry for the outgoing side.
CreateSeqBean createSeqBean = new CreateSeqBean();
createSeqBean.setSequenceID(offeredSequenceID);
String outgoingSideInternalSequenceID = SandeshaUtil.getOutgoingSideInternalSequenceID(newSequenceId);
createSeqBean.setInternalSequenceID(outgoingSideInternalSequenceID);
createSeqBean.setCreateSeqMsgID(SandeshaUtil.getUUID()); //this is a dummy value.
CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
createSeqMgr.insert(createSeqBean);
//Setting sequence properties for the outgoing sequence.
//Only will be used by the server side response path. Will be wasted properties for the client side.
//setting the out_sequence_id
SequencePropertyBean outSequenceBean = new SequencePropertyBean();
outSequenceBean.setName(Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
outSequenceBean.setValue(offeredSequenceID);
outSequenceBean.setSequenceID(outgoingSideInternalSequenceID);
seqPropMgr.insert(outSequenceBean);
//setting the internal_sequence_id
SequencePropertyBean internalSequenceBean = new SequencePropertyBean();
internalSequenceBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
internalSequenceBean.setSequenceID(offeredSequenceID);
internalSequenceBean.setValue(outgoingSideInternalSequenceID);
seqPropMgr.insert(internalSequenceBean);
} else {
//removing the accept part.
createSeqResPart.setAccept(null);
createSeqResponse.addSOAPEnvelope();
}
}
EndpointReference acksTo = createSeqPart.getAcksTo().getAddress().getEpr();
if (acksTo == null || acksTo.getAddress() == null
|| acksTo.getAddress() == "") {
String message = "Acks to not present in the create sequence message";
log.debug(message);
throw new AxisFault(message);
}
SequencePropertyBean acksToBean = new SequencePropertyBean(
newSequenceId, Sandesha2Constants.SequenceProperties.ACKS_TO_EPR,acksTo.getAddress());
seqPropMgr.insert(acksToBean);
outMessage.setResponseWritten(true);
//commiting tr. before sending the response msg.
createSequenceTransaction.commit();
Transaction updateLastActivatedTransaction = storageManager.getTransaction();
SequenceManager.updateLastActivatedTime(newSequenceId,createSeqRMMsg.getMessageContext().getConfigurationContext());
updateLastActivatedTransaction.commit();
AxisEngine engine = new AxisEngine(context);
engine.send(outMessage);
SequencePropertyBean toBean = seqPropMgr.retrieve(newSequenceId,Sandesha2Constants.SequenceProperties.TO_EPR);
if (toBean==null) {
String message = "Internal Error: wsa:To value is not set";
log.debug(message);