You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ch...@apache.org on 2006/10/11 06:31:52 UTC

svn commit: r462697 [1/3] - in /webservices/sandesha/trunk/java/src/org/apache/sandesha2: handlers/ i18n/ msgprocessors/ storage/beans/ storage/inmemory/ transport/ util/ workers/ wsrm/

Author: chamikara
Date: Tue Oct 10 21:31:51 2006
New Revision: 462697

URL: http://svn.apache.org/viewvc?view=rev&rev=462697
Log:
Did changes to use a cloned version of the CreateSequence message as the reference in the
RMS side. The original CreateSequence message will get subjected to things like encryption
and it may not be possible to use it as a reference.
When an incoming sequence is offered, this reference will be used for the RMD side
of that as well.

Applied the patch from Andrew.

Modified:
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaInHandler.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/MakeConnectionProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/MsgProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/TerminateSeqResponseMsgProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/storage/beans/CreateSeqBean.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/storage/inmemory/InMemorySenderBeanMgr.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/transport/Sandesha2TransportSender.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/AcknowledgementManager.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SandeshaUtil.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/SenderWorker.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/MakeConnection.java

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java?view=diff&rev=462697&r1=462696&r2=462697
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java Tue Oct 10 21:31:51 2006
@@ -1,384 +1,380 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- *  
- */
-
-package org.apache.sandesha2.handlers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.soap.SOAPBody;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFault;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.RelatesTo;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.context.OperationContextFactory;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.sandesha2.RMMsgContext;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.client.SandeshaClientConstants;
-import org.apache.sandesha2.client.SandeshaListener;
-import org.apache.sandesha2.i18n.SandeshaMessageHelper;
-import org.apache.sandesha2.i18n.SandeshaMessageKeys;
-import org.apache.sandesha2.msgprocessors.ApplicationMsgProcessor;
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.Transaction;
-import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
-import org.apache.sandesha2.storage.beans.SequencePropertyBean;
-import org.apache.sandesha2.util.MsgInitializer;
-import org.apache.sandesha2.util.SandeshaUtil;
-import org.apache.sandesha2.wsrm.Sequence;
-
-/**
- * The Global handler of Sandesha2. This is used to perform things that should
- * be done before diapatching such as duplicate detection.
- */
-
-public class SandeshaGlobalInHandler extends AbstractHandler {
-
-	private static final long serialVersionUID = -7187928423123306156L;
-
-	private static final Log log = LogFactory.getLog(SandeshaGlobalInHandler.class.getName());
-
-	public void invoke(MessageContext msgContext) throws AxisFault {
-
-		if (log.isDebugEnabled())
-			log.debug("Enter: SandeshaGlobalInHandler::msgContext, " + msgContext.getEnvelope().getHeader());
-
-		ConfigurationContext configContext = msgContext.getConfigurationContext();
-		if (configContext == null)
-			throw new AxisFault(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet));
-
-		SOAPEnvelope envelope = msgContext.getEnvelope();
-		if (envelope == null)
-			throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.soapEnvNotSet));
-
-		String reinjectedMessage = (String) msgContext.getProperty(Sandesha2Constants.REINJECTED_MESSAGE);
-		if (reinjectedMessage != null && Sandesha2Constants.VALUE_TRUE.equals(reinjectedMessage))
-			return; // Reinjected messages are not processed by Sandesha2 inflow
-					// handlers
-
-		StorageManager storageManager = null;
-		try {
-			storageManager = SandeshaUtil
-					.getSandeshaStorageManager(configContext, configContext.getAxisConfiguration());
-			if (storageManager == null) {
-				log.debug("Sandesha2 cannot proceed. The StorageManager is not available");
-				return;
-			}
-		} catch (SandeshaException e1) {
-			// TODO make this a log
-			log.debug("Sandesha2 cannot proceed. Exception thrown when looking for the StorageManager");
-			return;
-		}
-
-		boolean withinTransaction = false;
-		String withinTransactionStr = (String) msgContext.getProperty(Sandesha2Constants.WITHIN_TRANSACTION);
-		if (withinTransactionStr != null && Sandesha2Constants.VALUE_TRUE.equals(withinTransactionStr)) {
-			withinTransaction = true;
-		}
-
-		Transaction transaction = null;
-		if (!withinTransaction) {
-			transaction = storageManager.getTransaction();
-			msgContext.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_TRUE);
-		}
-		boolean rolebacked = false;
-
-		try {
-			// processing faults.
-			// Had to do this before dispatching. A fault message comes with the
-			// relatesTo part. So this will
-			// fill the opContext of te req/res message. But RM keeps
-			// retransmitting. So RM has to report the
-			// error and stop this fault being dispatched as the response
-			// message.
-
-			SOAPFault faultPart = envelope.getBody().getFault();
-
-			if (faultPart != null) {
-				RelatesTo relatesTo = msgContext.getRelatesTo();
-				if (relatesTo != null) {
-					String relatesToValue = relatesTo.getValue();
-					OperationContext operationContext = configContext.getOperationContext(relatesToValue);
-					if (operationContext != null) {
-						MessageContext requestMessage = operationContext
-								.getMessageContext(OperationContextFactory.MESSAGE_LABEL_OUT_VALUE);
-						if (requestMessage != null) {
-							if (SandeshaUtil.isRetriableOnFaults(requestMessage)) {
-
-								SandeshaListener faultCallback = (SandeshaListener) operationContext
-										.getProperty(SandeshaClientConstants.SANDESHA_LISTENER);
-								if (faultCallback != null) {
-
-									// constructing the fault
-									AxisFault axisFault = getAxisFaultFromFromSOAPFault(faultPart);
-
-									// reporting the fault
-									// log.error(axisFault);
-									if (faultCallback != null) {
-										faultCallback.onError(axisFault);
-									}
-
-								}
-
-								// stopping the fault from going further and
-								// getting dispatched
-								msgContext.pause(); // TODO let this go in the
-								// last try
-								if (log.isDebugEnabled())
-									log.debug("Exit: SandeshaGlobalInHandler::msgContext");
-
-								return;
-							}
-						}
-					}
-				}
-			}
-
-			// Quitting the message with minimum processing if not intended for
-			// RM.
-			boolean isRMGlobalMessage = SandeshaUtil.isRMGlobalMessage(msgContext);
-			if (!isRMGlobalMessage) {
-				if (log.isDebugEnabled())
-					log.debug("Exit: SandeshaGlobalInHandler::msgContext, !isRMGlobalMessage");
-				return;
-			}
-
-			RMMsgContext rmMessageContext = MsgInitializer.initializeMessage(msgContext);
-
-			// Dropping duplicates
-			boolean dropped = dropIfDuplicate(rmMessageContext, storageManager);
-			if (dropped) {
-				processDroppedMessage(rmMessageContext, storageManager);
-				if (log.isDebugEnabled())
-					log.debug("Exit: SandeshaGlobalInHandler::msgContext, dropped");
-				return;
-			}
-
-			// Persisting the application messages
-			// if
-			// (rmMessageContext.getMessageType()==Sandesha2Constants.MessageTypes.APPLICATION)
-			// {
-			// SandeshaUtil.PersistMessageContext ()
-			// }
-
-			// Process if global processing possible. - Currently none
-			if (SandeshaUtil.isGloballyProcessableMessageType(rmMessageContext.getMessageType())) {
-				doGlobalProcessing(rmMessageContext);
-			}
-
-		} catch (Exception e) {
-			// message should not be sent in a exception situation.
-			msgContext.pause();
-
-			if (!withinTransaction) {
-				try {
-					transaction.rollback();
-					msgContext.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_FALSE);
-					rolebacked = true;
-				} catch (Exception e1) {
-					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.rollbackError, e1.toString());
-					log.debug(message, e);
-				}
-			}
-
-			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.inMsgError, e.toString());
-			if (log.isDebugEnabled())
-				log.debug("Exit: SandeshaGlobalInHandler::msgContext ", e);
-			throw new AxisFault(message, e);
-		} finally {
-			if (!withinTransaction && !rolebacked) {
-				try {
-					transaction.commit();
-					msgContext.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_FALSE);
-				} catch (Exception e) {
-					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.commitError, e.toString());
-					log.debug(message, e);
-				}
-			}
-		}
-		if (log.isDebugEnabled())
-			log.debug("Exit: SandeshaGlobalInHandler::msgContext");
-	}
-
-	private boolean dropIfDuplicate(RMMsgContext rmMsgContext, StorageManager storageManager) throws AxisFault {
-		if (log.isDebugEnabled())
-			log.debug("Enter: SandeshaGlobalInHandler::dropIfDuplicate");
-
-		boolean drop = false;
-
-		
-		
-		if (rmMsgContext.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
-
-			Sequence sequence = (Sequence) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
-			String sequenceId = null;
-
-			long msgNo = sequence.getMessageNumber().getMessageNumber();
-			
-			String propertyKey = SandeshaUtil.getSequencePropertyKey(rmMsgContext);
-
-			if (propertyKey != null && msgNo > 0) {
-				SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
-				SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(propertyKey,
-						Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
-				if (receivedMsgsBean != null) {
-					String receivedMsgStr = receivedMsgsBean.getValue();
-					ArrayList msgNoArrList = SandeshaUtil.getSplittedMsgNoArraylist(receivedMsgStr);
-
-					Iterator iterator = msgNoArrList.iterator();
-					while (iterator.hasNext()) {
-						String temp = (String) iterator.next();
-						String msgNoStr = new Long(msgNo).toString();
-						if (msgNoStr.equals(temp)) {
-							drop = true;
-						}
-					}
-				}
-
-				if (drop == false) {
-					// Checking for RM specific EMPTY_BODY LASTMESSAGE.
-					SOAPBody body = rmMsgContext.getSOAPEnvelope().getBody();
-					boolean emptyBody = false;
-					if (body.getChildElements().hasNext() == false) {
-						emptyBody = true;
-					}
-
-					if (emptyBody) {
-						if (sequence.getLastMessage() != null) {
-							log.debug(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.emptyLastMsg));
-							drop = true;
-
-							if (receivedMsgsBean == null) {
-								receivedMsgsBean = new SequencePropertyBean(sequenceId,
-										Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES, "");
-								seqPropMgr.insert(receivedMsgsBean);
-							}
-
-							String receivedMsgStr = (String) receivedMsgsBean.getValue();
-							if (receivedMsgStr != "" && receivedMsgStr != null)
-								receivedMsgStr = receivedMsgStr + "," + Long.toString(msgNo);
-							else
-								receivedMsgStr = Long.toString(msgNo);
-
-							receivedMsgsBean.setValue(receivedMsgStr);
-
-							// TODO correct the syntac into '[received msgs]'
-
-							seqPropMgr.update(receivedMsgsBean);
-
-							ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor();
-							ackProcessor.sendAckIfNeeded(rmMsgContext, receivedMsgStr, storageManager);
-							
-							
-							drop = true;
-
-						}
-					}
-				}
-			}
-		} else if (rmMsgContext.getMessageType() != Sandesha2Constants.MessageTypes.UNKNOWN) {
-			// droping other known message types if, an suitable operation
-			// context is not available,
-			// and if a relates to value is present.
-			RelatesTo relatesTo = rmMsgContext.getRelatesTo();
-			if (relatesTo != null) {
-				String value = relatesTo.getValue();
-
-				// TODO do not drop, relationshipTypes other than reply
-
-				ConfigurationContext configurationContext = rmMsgContext.getMessageContext().getConfigurationContext();
-				OperationContext operationContextFromMap = configurationContext.getOperationContext(value);
-				OperationContext operationContext = rmMsgContext.getMessageContext().getOperationContext();
-
-				// reply messages should be dropped if it cannot be instance
-				// dispatched.
-				// I.e. both not having a op. ctx not and not having a op. ctx
-				// in the global list.
-				if (operationContext == null && operationContextFromMap == null) {
-					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.droppingDuplicate);
-					log.debug(message);
-					drop = true;
-				}
-			}
-		}
-
-		if (drop) {
-			rmMsgContext.getMessageContext().pause();
-			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.droppingDuplicate);
-			log.debug(message);
-			if (log.isDebugEnabled())
-				log.debug("Exit: SandeshaGlobalInHandler::dropIfDuplicate, true");
-			return true;
-		}
-
-		if (log.isDebugEnabled())
-			log.debug("Exit: SandeshaGlobalInHandler::dropIfDuplicate, false");
-		return false;
-	}
-
-	private void processDroppedMessage(RMMsgContext rmMsgContext, StorageManager storageManager)
-			throws AxisFault {
-		if (log.isDebugEnabled())
-			log.debug("Enter: SandeshaGlobalInHandler::processDroppedMessage");
-
-		if (rmMsgContext.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
-			Sequence sequence = (Sequence) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
-			String sequenceId = null;
-
-			if (sequence != null) {
-				sequenceId = sequence.getIdentifier().getIdentifier();
-			}
-
-			SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
-			SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(sequenceId,
-					Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
-			String receivedMsgStr = receivedMsgsBean.getValue();
-
-			ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor();
-			// Even though the duplicate message is dropped, hv to send the ack
-			// if needed.
-			ackProcessor.sendAckIfNeeded(rmMsgContext, receivedMsgStr, storageManager);
-
-		}
-		if (log.isDebugEnabled())
-			log.debug("Exit: SandeshaGlobalInHandler::processDroppedMessage");
-	}
-
-	private void doGlobalProcessing(RMMsgContext rmMsgCtx) throws SandeshaException {
-	}
-
-	public String getName() {
-		return Sandesha2Constants.GLOBAL_IN_HANDLER_NAME;
-	}
-
-	private AxisFault getAxisFaultFromFromSOAPFault(SOAPFault faultPart) {
-		AxisFault axisFault = new AxisFault(faultPart.getCode(), faultPart.getReason(), faultPart.getNode(), faultPart
-				.getRole(), faultPart.getDetail());
-
-		return axisFault;
-	}
-
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *  
+ */
+
+package org.apache.sandesha2.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFault;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.OperationContextFactory;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SandeshaListener;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.msgprocessors.ApplicationMsgProcessor;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.util.MsgInitializer;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.Sequence;
+
+/**
+ * The Global handler of Sandesha2. This is used to perform things that should
+ * be done before diapatching such as duplicate detection.
+ */
+
+public class SandeshaGlobalInHandler extends AbstractHandler {
+
+	private static final long serialVersionUID = -7187928423123306156L;
+
+	private static final Log log = LogFactory.getLog(SandeshaGlobalInHandler.class.getName());
+
+	public void invoke(MessageContext msgContext) throws AxisFault {
+
+		if (log.isDebugEnabled())
+			log.debug("Enter: SandeshaGlobalInHandler::invoke, " + msgContext.getEnvelope().getHeader());
+
+		ConfigurationContext configContext = msgContext.getConfigurationContext();
+		if (configContext == null)
+			throw new AxisFault(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet));
+
+		SOAPEnvelope envelope = msgContext.getEnvelope();
+		if (envelope == null)
+			throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.soapEnvNotSet));
+
+		String reinjectedMessage = (String) msgContext.getProperty(Sandesha2Constants.REINJECTED_MESSAGE);
+		if (reinjectedMessage != null && Sandesha2Constants.VALUE_TRUE.equals(reinjectedMessage))
+			return; // Reinjected messages are not processed by Sandesha2 inflow
+					// handlers
+
+		StorageManager storageManager = null;
+		try {
+			storageManager = SandeshaUtil
+					.getSandeshaStorageManager(configContext, configContext.getAxisConfiguration());
+			if (storageManager == null) {
+				log.debug("Sandesha2 cannot proceed. The StorageManager is not available");
+				return;
+			}
+		} catch (SandeshaException e1) {
+			// TODO make this a log
+			log.debug("Sandesha2 cannot proceed. Exception thrown when looking for the StorageManager", e1);
+			return;
+		}
+
+		boolean withinTransaction = false;
+		String withinTransactionStr = (String) msgContext.getProperty(Sandesha2Constants.WITHIN_TRANSACTION);
+		if (withinTransactionStr != null && Sandesha2Constants.VALUE_TRUE.equals(withinTransactionStr)) {
+			withinTransaction = true;
+		}
+
+		Transaction transaction = null;
+		if (!withinTransaction) {
+			transaction = storageManager.getTransaction();
+			msgContext.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_TRUE);
+		}
+		boolean rolebacked = false;
+
+		try {
+			// processing faults.
+			// Had to do this before dispatching. A fault message comes with the
+			// relatesTo part. So this will
+			// fill the opContext of te req/res message. But RM keeps
+			// retransmitting. So RM has to report the
+			// error and stop this fault being dispatched as the response
+			// message.
+
+			SOAPFault faultPart = envelope.getBody().getFault();
+
+			if (faultPart != null) {
+				RelatesTo relatesTo = msgContext.getRelatesTo();
+				if (relatesTo != null) {
+					String relatesToValue = relatesTo.getValue();
+					OperationContext operationContext = configContext.getOperationContext(relatesToValue);
+					if (operationContext != null) {
+						MessageContext requestMessage = operationContext
+								.getMessageContext(OperationContextFactory.MESSAGE_LABEL_OUT_VALUE);
+						if (requestMessage != null) {
+							if (SandeshaUtil.isRetriableOnFaults(requestMessage)) {
+
+								SandeshaListener faultCallback = (SandeshaListener) operationContext
+										.getProperty(SandeshaClientConstants.SANDESHA_LISTENER);
+								if (faultCallback != null) {
+
+									// constructing the fault
+									AxisFault axisFault = getAxisFaultFromFromSOAPFault(faultPart);
+
+									// reporting the fault
+									// log.error(axisFault);
+									if (faultCallback != null) {
+										faultCallback.onError(axisFault);
+									}
+
+								}
+
+								// stopping the fault from going further and
+								// getting dispatched
+								msgContext.pause(); // TODO let this go in the
+								// last try
+								if (log.isDebugEnabled())
+									log.debug("Exit: SandeshaGlobalInHandler::invoke");
+
+								return;
+							}
+						}
+					}
+				}
+			}
+
+			// Quitting the message with minimum processing if not intended for
+			// RM.
+			boolean isRMGlobalMessage = SandeshaUtil.isRMGlobalMessage(msgContext);
+			if (!isRMGlobalMessage) {
+				if (log.isDebugEnabled())
+					log.debug("Exit: SandeshaGlobalInHandler::invoke, !isRMGlobalMessage");
+				return;
+			}
+
+			RMMsgContext rmMessageContext = MsgInitializer.initializeMessage(msgContext);
+
+			// Dropping duplicates
+			boolean dropped = dropIfDuplicate(rmMessageContext, storageManager);
+			if (dropped) {
+				processDroppedMessage(rmMessageContext, storageManager);
+				if (log.isDebugEnabled())
+					log.debug("Exit: SandeshaGlobalInHandler::invoke, dropped");
+				return;
+			}
+
+			// Persisting the application messages
+			// if
+			// (rmMessageContext.getMessageType()==Sandesha2Constants.MessageTypes.APPLICATION)
+			// {
+			// SandeshaUtil.PersistMessageContext ()
+			// }
+
+			// Process if global processing possible. - Currently none
+			if (SandeshaUtil.isGloballyProcessableMessageType(rmMessageContext.getMessageType())) {
+				doGlobalProcessing(rmMessageContext);
+			}
+
+		} catch (Exception e) {
+			// message should not be sent in a exception situation.
+			msgContext.pause();
+
+			if (!withinTransaction) {
+				try {
+					transaction.rollback();
+					msgContext.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_FALSE);
+					rolebacked = true;
+				} catch (Exception e1) {
+					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.rollbackError, e1.toString());
+					log.debug(message, e);
+				}
+			}
+
+			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.inMsgError, e.toString());
+			if (log.isDebugEnabled())
+				log.debug("Exit: SandeshaGlobalInHandler::invoke ", e);
+			throw new AxisFault(message, e);
+		} finally {
+			if (!withinTransaction && !rolebacked) {
+				try {
+					transaction.commit();
+					msgContext.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_FALSE);
+				} catch (Exception e) {
+					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.commitError, e.toString());
+					log.debug(message, e);
+				}
+			}
+		}
+		if (log.isDebugEnabled())
+			log.debug("Exit: SandeshaGlobalInHandler::invoke");
+	}
+
+	private boolean dropIfDuplicate(RMMsgContext rmMsgContext, StorageManager storageManager) throws AxisFault {
+		if (log.isDebugEnabled())
+			log.debug("Enter: SandeshaGlobalInHandler::dropIfDuplicate");
+
+		boolean drop = false;		
+		
+		if (rmMsgContext.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
+
+			Sequence sequence = (Sequence) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
+			String sequenceId = null;
+
+			long msgNo = sequence.getMessageNumber().getMessageNumber();
+			
+			String propertyKey = SandeshaUtil.getSequencePropertyKey(rmMsgContext);
+
+			if (propertyKey != null && msgNo > 0) {
+				SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
+				SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(propertyKey,
+						Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
+				if (receivedMsgsBean != null) {
+					String receivedMsgStr = receivedMsgsBean.getValue();
+					ArrayList msgNoArrList = SandeshaUtil.getSplittedMsgNoArraylist(receivedMsgStr);
+
+					Iterator iterator = msgNoArrList.iterator();
+					while (iterator.hasNext()) {
+						String temp = (String) iterator.next();
+						String msgNoStr = new Long(msgNo).toString();
+						if (msgNoStr.equals(temp)) {
+							drop = true;
+						}
+					}
+				}
+
+				if (drop == false) {
+					// Checking for RM specific EMPTY_BODY LASTMESSAGE.
+					SOAPBody body = rmMsgContext.getSOAPEnvelope().getBody();
+					boolean emptyBody = false;
+					if (body.getChildElements().hasNext() == false) {
+						emptyBody = true;
+					}
+
+					if (emptyBody) {
+						if (sequence.getLastMessage() != null) {
+							log.debug(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.emptyLastMsg));
+							drop = true;
+
+							if (receivedMsgsBean == null) {
+								receivedMsgsBean = new SequencePropertyBean(sequenceId,
+										Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES, "");
+								seqPropMgr.insert(receivedMsgsBean);
+							}
+
+							String receivedMsgStr = receivedMsgsBean.getValue();
+							if (receivedMsgStr != "" && receivedMsgStr != null)
+								receivedMsgStr = receivedMsgStr + "," + Long.toString(msgNo);
+							else
+								receivedMsgStr = Long.toString(msgNo);
+
+							receivedMsgsBean.setValue(receivedMsgStr);
+
+							// TODO correct the syntac into '[received msgs]'
+
+							seqPropMgr.update(receivedMsgsBean);
+
+							ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor();
+							ackProcessor.sendAckIfNeeded(rmMsgContext, receivedMsgStr, storageManager);
+							
+							
+							drop = true;
+
+						}
+					}
+				}
+			}
+		} else if (rmMsgContext.getMessageType() != Sandesha2Constants.MessageTypes.UNKNOWN) {
+			// droping other known message types if, an suitable operation
+			// context is not available,
+			// and if a relates to value is present.
+			RelatesTo relatesTo = rmMsgContext.getRelatesTo();
+			if (relatesTo != null) {
+				String value = relatesTo.getValue();
+
+				// TODO do not drop, relationshipTypes other than reply
+
+				ConfigurationContext configurationContext = rmMsgContext.getMessageContext().getConfigurationContext();
+				OperationContext operationContextFromMap = configurationContext.getOperationContext(value);
+				OperationContext operationContext = rmMsgContext.getMessageContext().getOperationContext();
+
+				// reply messages should be dropped if it cannot be instance
+				// dispatched.
+				// I.e. both not having a op. ctx not and not having a op. ctx
+				// in the global list.
+				if (operationContext == null && operationContextFromMap == null) {
+					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.droppingDuplicate);
+					log.debug(message);
+					drop = true;
+				}
+			}
+		}
+
+		if (drop) {
+			rmMsgContext.getMessageContext().pause();
+			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.droppingDuplicate);
+			log.debug(message);
+			if (log.isDebugEnabled())
+				log.debug("Exit: SandeshaGlobalInHandler::dropIfDuplicate, true");
+			return true;
+		}
+
+		if (log.isDebugEnabled())
+			log.debug("Exit: SandeshaGlobalInHandler::dropIfDuplicate, false");
+		return false;
+	}
+
+	private void processDroppedMessage(RMMsgContext rmMsgContext, StorageManager storageManager)
+			throws AxisFault {
+		if (log.isDebugEnabled())
+			log.debug("Enter: SandeshaGlobalInHandler::processDroppedMessage");
+
+		if (rmMsgContext.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
+			Sequence sequence = (Sequence) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
+			String sequenceId = null;
+
+			if (sequence != null) {
+				sequenceId = sequence.getIdentifier().getIdentifier();
+			}
+
+			SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
+			SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(sequenceId,
+					Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
+			String receivedMsgStr = receivedMsgsBean.getValue();
+
+			ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor();
+			// Even though the duplicate message is dropped, hv to send the ack
+			// if needed.
+			ackProcessor.sendAckIfNeeded(rmMsgContext, receivedMsgStr, storageManager);
+
+		}
+		if (log.isDebugEnabled())
+			log.debug("Exit: SandeshaGlobalInHandler::processDroppedMessage");
+	}
+
+	private void doGlobalProcessing(RMMsgContext rmMsgCtx) throws SandeshaException {
+	}
+
+	public String getName() {
+		return Sandesha2Constants.GLOBAL_IN_HANDLER_NAME;
+	}
+
+	private AxisFault getAxisFaultFromFromSOAPFault(SOAPFault faultPart) {
+		AxisFault axisFault = new AxisFault(faultPart.getCode(), faultPart.getReason(), faultPart.getNode(), faultPart
+				.getRole(), faultPart.getDetail());
+
+		return axisFault;
+	}
+
+}

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaInHandler.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaInHandler.java?view=diff&rev=462697&r1=462696&r2=462697
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaInHandler.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaInHandler.java Tue Oct 10 21:31:51 2006
@@ -1,169 +1,164 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- *  
- */
-
-package org.apache.sandesha2.handlers;
-
-import java.util.Iterator;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.sandesha2.MessageValidator;
-import org.apache.sandesha2.RMMsgContext;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.i18n.SandeshaMessageHelper;
-import org.apache.sandesha2.i18n.SandeshaMessageKeys;
-import org.apache.sandesha2.msgprocessors.AckRequestedProcessor;
-import org.apache.sandesha2.msgprocessors.AcknowledgementProcessor;
-import org.apache.sandesha2.msgprocessors.MsgProcessor;
-import org.apache.sandesha2.msgprocessors.MsgProcessorFactory;
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.Transaction;
-import org.apache.sandesha2.util.MsgInitializer;
-import org.apache.sandesha2.util.SandeshaUtil;
-import org.apache.sandesha2.wsrm.Sequence;
-
-/**
- * This is invoked in the inFlow of an RM endpoint. This is responsible for
- * selecting an suitable message processor and letting it process the message.
- */
-
-public class SandeshaInHandler extends AbstractHandler {
-
-	private static final long serialVersionUID = 733210926016820857L;
-
-	private static final Log log = LogFactory.getLog(SandeshaInHandler.class.getName());
-
-	public String getName() {
-		return Sandesha2Constants.IN_HANDLER_NAME;
-	}
-
-	public void invoke(MessageContext msgCtx) throws AxisFault {
-		
-		if (log.isDebugEnabled())
-			log.debug("Enter: SandeshaInHandler::invoke, " + msgCtx.getEnvelope().getHeader());
-
-		ConfigurationContext context = msgCtx.getConfigurationContext();
-		if (context == null) {
-			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet);
-			log.debug(message);
-			throw new AxisFault(message);
-		}
-
-		String DONE = (String) msgCtx.getProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE);
-		if (null != DONE && "true".equals(DONE))
-			return;
-
-		String reinjectedMessage = (String) msgCtx.getProperty(Sandesha2Constants.REINJECTED_MESSAGE);
-		if (reinjectedMessage != null && Sandesha2Constants.VALUE_TRUE.equals(reinjectedMessage)) {
-			if (log.isDebugEnabled())
-				log.debug("Exit: SandeshaInHandler::invoke, reinjectedMessage");
-			return; // Reinjected messages are not processed by Sandesha2 inflow
-					// handlers
-		}
-		
-		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());
-
-		boolean withinTransaction = false;
-		String withinTransactionStr = (String) msgCtx.getProperty(Sandesha2Constants.WITHIN_TRANSACTION);
-		if (withinTransactionStr != null && Sandesha2Constants.VALUE_TRUE.equals(withinTransactionStr)) {
-			withinTransaction = true;
-		}
-
-		Transaction transaction = null;
-		if (!withinTransaction) {
-			transaction = storageManager.getTransaction();
-			msgCtx.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_TRUE);
-		}
-		boolean rolebacked = false;
-
-		try {
-
-			// Process Ack headers in the message
-			AcknowledgementProcessor ackProcessor = new AcknowledgementProcessor();
-			ackProcessor.processAckHeaders(msgCtx);
-
-			// Process Ack Request headers in the message
-			AckRequestedProcessor reqProcessor = new AckRequestedProcessor();
-			reqProcessor.processAckRequestedHeaders(msgCtx);
-
-			AxisService axisService = msgCtx.getAxisService();
-			if (axisService == null) {
-				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.axisServiceIsNull);
-				log.debug(message);
-				throw new AxisFault(message);
-			}
-
-			RMMsgContext rmMsgCtx = null;
-			try {
-				rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
-			} catch (SandeshaException ex) {
-				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotInnitMessage);
-				log.debug(message);
-				throw new AxisFault(message);
-			}
-			
-			// validating the message
-			MessageValidator.validateMessage(rmMsgCtx, storageManager);
-
-			MsgProcessor msgProcessor = MsgProcessorFactory.getMessageProcessor(rmMsgCtx);
-
-			try {
-				if (msgProcessor != null)
-					msgProcessor.processInMessage(rmMsgCtx);
-			} catch (SandeshaException se) {
-				throw se;
-			}
-
-		} catch (AxisFault e) {
-			// message should not be sent in a exception situation.
-			msgCtx.pause();
-
-			if (!withinTransaction) {
-				try {
-					transaction.rollback();
-					msgCtx.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_FALSE);
-					rolebacked = true;
-				} catch (Exception e1) {
-					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.rollbackError, e1.toString());
-					log.debug(message, e);
-				}
-			}
-
-			throw e;
-		} finally {
-			if (!withinTransaction && !rolebacked) {
-				try {
-					transaction.commit();
-					msgCtx.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_FALSE);
-				} catch (Exception e) {
-					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.commitError, e.toString());
-					log.debug(message, e);
-				}
-			}
-		}
-		if (log.isDebugEnabled())
-			log.debug("Exit: SandeshaInHandler::invoke");
-	}
-
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *  
+ */
+
+package org.apache.sandesha2.handlers;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.MessageValidator;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.msgprocessors.AckRequestedProcessor;
+import org.apache.sandesha2.msgprocessors.AcknowledgementProcessor;
+import org.apache.sandesha2.msgprocessors.MsgProcessor;
+import org.apache.sandesha2.msgprocessors.MsgProcessorFactory;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.util.MsgInitializer;
+import org.apache.sandesha2.util.SandeshaUtil;
+
+/**
+ * This is invoked in the inFlow of an RM endpoint. This is responsible for
+ * selecting an suitable message processor and letting it process the message.
+ */
+
+public class SandeshaInHandler extends AbstractHandler {
+
+	private static final long serialVersionUID = 733210926016820857L;
+
+	private static final Log log = LogFactory.getLog(SandeshaInHandler.class.getName());
+
+	public String getName() {
+		return Sandesha2Constants.IN_HANDLER_NAME;
+	}
+
+	public void invoke(MessageContext msgCtx) throws AxisFault {
+		
+		if (log.isDebugEnabled())
+			log.debug("Enter: SandeshaInHandler::invoke, " + msgCtx.getEnvelope().getHeader());
+
+		ConfigurationContext context = msgCtx.getConfigurationContext();
+		if (context == null) {
+			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet);
+			log.debug(message);
+			throw new AxisFault(message);
+		}
+
+		String DONE = (String) msgCtx.getProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE);
+		if (null != DONE && "true".equals(DONE)) {
+			if (log.isDebugEnabled())
+				log.debug("Exit: SandeshaInHandler::invoke, Application processing done");
+			return;
+		}
+
+		String reinjectedMessage = (String) msgCtx.getProperty(Sandesha2Constants.REINJECTED_MESSAGE);
+		if (reinjectedMessage != null && Sandesha2Constants.VALUE_TRUE.equals(reinjectedMessage)) {
+			if (log.isDebugEnabled())
+				log.debug("Exit: SandeshaInHandler::invoke, reinjectedMessage");
+			return; // Reinjected messages are not processed by Sandesha2 inflow
+					// handlers
+		}
+		
+		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());
+
+		boolean withinTransaction = false;
+		String withinTransactionStr = (String) msgCtx.getProperty(Sandesha2Constants.WITHIN_TRANSACTION);
+		if (withinTransactionStr != null && Sandesha2Constants.VALUE_TRUE.equals(withinTransactionStr)) {
+			withinTransaction = true;
+		}
+
+		Transaction transaction = null;
+		if (!withinTransaction) {
+			transaction = storageManager.getTransaction();
+			msgCtx.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_TRUE);
+		}
+		boolean rolebacked = false;
+
+		try {
+
+			// Process Ack headers in the message
+			AcknowledgementProcessor ackProcessor = new AcknowledgementProcessor();
+			ackProcessor.processAckHeaders(msgCtx);
+
+			// Process Ack Request headers in the message
+			AckRequestedProcessor reqProcessor = new AckRequestedProcessor();
+			reqProcessor.processAckRequestedHeaders(msgCtx);
+
+			AxisService axisService = msgCtx.getAxisService();
+			if (axisService == null) {
+				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.axisServiceIsNull);
+				log.debug(message);
+				throw new AxisFault(message);
+			}
+
+			RMMsgContext rmMsgCtx = null;
+			try {
+				rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
+			} catch (SandeshaException ex) {
+				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotInnitMessage);
+				log.debug(message);
+				throw new AxisFault(message, ex);
+			}
+			
+			// validating the message
+			MessageValidator.validateMessage(rmMsgCtx, storageManager);
+
+			MsgProcessor msgProcessor = MsgProcessorFactory.getMessageProcessor(rmMsgCtx);
+
+			if (msgProcessor != null)
+				msgProcessor.processInMessage(rmMsgCtx);
+
+		} catch (AxisFault e) {
+			// message should not be sent in a exception situation.
+			msgCtx.pause();
+
+			if (!withinTransaction) {
+				try {
+					transaction.rollback();
+					msgCtx.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_FALSE);
+					rolebacked = true;
+				} catch (Exception e1) {
+					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.rollbackError, e1.toString());
+					log.debug(message, e);
+				}
+			}
+
+			throw e;
+		} finally {
+			if (!withinTransaction && !rolebacked) {
+				try {
+					transaction.commit();
+					msgCtx.setProperty(Sandesha2Constants.WITHIN_TRANSACTION, Sandesha2Constants.VALUE_FALSE);
+				} catch (Exception e) {
+					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.commitError, e.toString());
+					log.debug(message, e);
+				}
+			}
+		}
+		if (log.isDebugEnabled())
+			log.debug("Exit: SandeshaInHandler::invoke");
+	}
+
+}

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java?view=diff&rev=462697&r1=462696&r2=462697
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java Tue Oct 10 21:31:51 2006
@@ -85,7 +85,7 @@
 	public static final String cannotDecideRMVersion="cannotDecideRMVersion";
 	public static final String specVersionPropertyNotAvailable="specVersionPropertyNotAvailable";
 	public static final String specVersionNotSet="specVersionNotSet";
-	public static final String specDoesNotSupportElement="specDoesNotSupportElements";
+	public static final String specDoesNotSupportElement="specDoesNotSupportElement";
 		
 	public static final String couldNotSendTerminate="couldNotSendTerminate";
 	public static final String couldNotSendClose="couldNotSendClose";

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties?view=diff&rev=462697&r1=462696&r2=462697
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties Tue Oct 10 21:31:51 2006
@@ -106,7 +106,7 @@
 cannotDecideRMVersion=Message does not has a valid RM namespace value - cannot decide the RM version.
 specVersionPropertyNotAvailable=''SpecVersion'' sequence property is not available for the incoming sequence {0}: cannot find the RM version for outgoing side.
 specVersionNotSet=Error: 'SpecVersion'' is not set.
-specDoesNotSupportElement=Spec {0} does not support the element {1}
+specDoesNotSupportElement=Spec ''{0}'' does not support the element {1}
 
 couldNotSendTerminate=Could not send the terminate message due to error {0}.
 couldNotSendClose=Could not send the close sequence message due to error {0}.

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?view=diff&rev=462697&r1=462696&r2=462697
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java Tue Oct 10 21:31:51 2006
@@ -302,7 +302,7 @@
 				rmMsgCtx.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
 
 			} catch (Exception ex) {
-				throw new SandeshaException(ex.getMessage());
+				throw new SandeshaException(ex.getMessage(), ex);
 			}
 
 			// pause the message
@@ -910,6 +910,13 @@
 		createSeqBean.setInternalSequenceID(internalSequenceId);
 		createSeqBean.setCreateSeqMsgID(createSeqMsg.getMessageID());
 		createSeqBean.setCreateSequenceMsgStoreKey(createSequenceMessageStoreKey);
+		
+		//cloning the message and storing it as a reference.
+		MessageContext clonedMessage = SandeshaUtil.cloneMessageContext(createSeqMsg);
+		String clonedMsgStoreKey = SandeshaUtil.getUUID();
+		storageManager.storeMessageContext(clonedMsgStoreKey, clonedMessage);
+		createSeqBean.setReferenceMessageStoreKey(clonedMsgStoreKey);
+		
 		
 		//TODO set the replyTo of CreateSeq (and others) to Anymomous if Application Msgs hv it as Anonymous.
 		

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java?view=diff&rev=462697&r1=462696&r2=462697
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java Tue Oct 10 21:31:51 2006
@@ -1,306 +1,302 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- *  
- */
-
-package org.apache.sandesha2.msgprocessors;
-
-import java.util.Collection;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.util.Utils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.sandesha2.RMMsgContext;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.client.SandeshaClientConstants;
-import org.apache.sandesha2.client.SandeshaListener;
-import org.apache.sandesha2.i18n.SandeshaMessageHelper;
-import org.apache.sandesha2.i18n.SandeshaMessageKeys;
-import org.apache.sandesha2.security.SecurityManager;
-import org.apache.sandesha2.security.SecurityToken;
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
-import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
-import org.apache.sandesha2.storage.beans.CreateSeqBean;
-import org.apache.sandesha2.storage.beans.SequencePropertyBean;
-import org.apache.sandesha2.util.FaultManager;
-import org.apache.sandesha2.util.RMMsgCreator;
-import org.apache.sandesha2.util.SandeshaUtil;
-import org.apache.sandesha2.util.SequenceManager;
-import org.apache.sandesha2.util.SpecSpecificConstants;
-import org.apache.sandesha2.wsrm.Accept;
-import org.apache.sandesha2.wsrm.CreateSequence;
-import org.apache.sandesha2.wsrm.CreateSequenceResponse;
-import org.apache.sandesha2.wsrm.SequenceOffer;
-
-/**
- * Responsible for processing an incoming Create Sequence message.
- */
-
-public class CreateSeqMsgProcessor implements MsgProcessor {
-
-	private static final Log log = LogFactory.getLog(CreateSeqMsgProcessor.class);
-
-	public void processInMessage(RMMsgContext createSeqRMMsg) throws AxisFault {
-		if (log.isDebugEnabled())
-			log.debug("Enter: CreateSeqMsgProcessor::processInMessage");
-
-		MessageContext createSeqMsg = createSeqRMMsg.getMessageContext();
-		CreateSequence createSeqPart = (CreateSequence) createSeqRMMsg
-				.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
-		if (createSeqPart == null) {
-			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noCreateSeqParts);
-			log.debug(message);
-			throw new SandeshaException(message);
-		}
-
-		ConfigurationContext context = createSeqMsg.getConfigurationContext();
-		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());
-
-		FaultManager faultManager = new FaultManager();
-		SandeshaException fault = faultManager.checkForCreateSequenceRefused(createSeqMsg, storageManager);
-		if (fault != null) {
-			throw fault;
-		}
-		
-		// If the inbound CreateSequence includes a SecurityTokenReference then
-		// ask the security manager to resolve that to a token for us. We also
-		// check that the Create was secured using the token.
-		OMElement theSTR = createSeqPart.getSecurityTokenReference();
-		SecurityToken token = null;
-		if(theSTR != null) {
-			SecurityManager secManager = SandeshaUtil.getSecurityManager(context);
-			MessageContext msgcontext = createSeqRMMsg.getMessageContext();
-			token = secManager.getSecurityToken(theSTR, msgcontext);
-			
-			// The create must be the body part of this message, so we check the
-			// security of that element.
-			OMElement body = msgcontext.getEnvelope().getBody();
-			secManager.checkProofOfPossession(token, body, msgcontext);
-		}
-
-		MessageContext outMessage = null;
-		try {
-			outMessage = Utils.createOutMessageContext(createSeqMsg); // createing
-																		// a new
-																		// response
-																		// message.
-		} catch (AxisFault e1) {
-			throw new SandeshaException(e1);
-		}
-		SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
-
-		try {
-			String newSequenceId = SequenceManager.setupNewSequence(createSeqRMMsg, storageManager); // newly
-																										// created
-																										// sequnceID.
-
-			
-			
-			RMMsgContext createSeqResponse = RMMsgCreator.createCreateSeqResponseMsg(createSeqRMMsg, outMessage,
-					newSequenceId, storageManager); // 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 = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcceptPart);
-					log.debug(message);
-					throw new SandeshaException(message);
-				}
-
-				String offeredSequenceID = offer.getIdentifer().getIdentifier(); // offered
-																					// seq.
-																					// id.
-
-				boolean offerEcepted = offerAccepted(offeredSequenceID, context, createSeqRMMsg, storageManager);
-
-				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.
-					
-					String outgoingSideSequencePropertyKey = outgoingSideInternalSequenceId;
-
-					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.setSequencePropertyKey(outgoingSideSequencePropertyKey);
-					seqPropMgr.insert(outSequenceBean);
-
-					// setting the internal_sequence_id
-					SequencePropertyBean internalSequenceBean = new SequencePropertyBean();
-					internalSequenceBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
-					internalSequenceBean.setSequencePropertyKey(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 = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcksToPartInCreateSequence);
-				log.debug(message);
-				throw new AxisFault(message);
-			}
-			
-			//TODO add createSequenceResponse message as the referenceMessage to the NextMsgBean.
-			
-
-			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.
-
-			SequenceManager.updateLastActivatedTime(newSequenceId, storageManager);
-
-			AxisEngine engine = new AxisEngine(context);
-			engine.send(outMessage);
-
-			SequencePropertyBean toBean = seqPropMgr.retrieve(newSequenceId,
-					Sandesha2Constants.SequenceProperties.TO_EPR);
-			if (toBean == null) {
-				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
-				log.debug(message);
-				throw new SandeshaException(message);
-			}
-
-			EndpointReference toEPR = new EndpointReference(toBean.getValue());
-
-			String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(newSequenceId,
-					Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, storageManager);
-			String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);
-
-			if (anonymousURI.equals(toEPR.getAddress())) {
-				createSeqMsg.getOperationContext().setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN, "true");
-			} else {
-				createSeqMsg.getOperationContext().setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN, "false");
-			}
-
-		} catch (AxisFault e1) {
-			throw new SandeshaException(e1);
-		}
-
-		createSeqRMMsg.pause();
-
-		if (log.isDebugEnabled())
-			log.debug("Exit: CreateSeqMsgProcessor::processInMessage");
-	}
-
-	private boolean offerAccepted(String sequenceId, ConfigurationContext configCtx, RMMsgContext createSeqRMMsg,
-			StorageManager storageManager) throws SandeshaException {
-		if (log.isDebugEnabled())
-			log.debug("Enter: CreateSeqMsgProcessor::offerAccepted, " + sequenceId);
-
-		if ("".equals(sequenceId)) {
-			if (log.isDebugEnabled())
-				log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + false);
-			return false;
-		}
-
-		CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
-
-		CreateSeqBean createSeqFindBean = new CreateSeqBean();
-		createSeqFindBean.setSequenceID(sequenceId);
-		Collection arr = createSeqMgr.find(createSeqFindBean);
-
-		if (arr.size() > 0) {
-			if (log.isDebugEnabled())
-				log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + false);
-			return false;
-		}
-		if (sequenceId.length() <= 1) {
-			if (log.isDebugEnabled())
-				log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + false);
-			return false; // Single character offers are NOT accepted.
-		}
-
-		if (log.isDebugEnabled())
-			log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + true);
-		return true;
-	}
-
-	public void processOutMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
-		if (log.isDebugEnabled())
-			log.debug("Enter: CreateSeqMsgProcessor::processOutMessage");
-
-		MessageContext msgCtx = rmMsgCtx.getMessageContext();
-
-		// adding the SANDESHA_LISTENER
-		SandeshaListener faultCallback = (SandeshaListener) msgCtx.getOptions().getProperty(
-				SandeshaClientConstants.SANDESHA_LISTENER);
-		if (faultCallback != null) {
-			OperationContext operationContext = msgCtx.getOperationContext();
-			if (operationContext != null) {
-				operationContext.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, faultCallback);
-			}
-		}
-		if (log.isDebugEnabled())
-			log.debug("Exit: CreateSeqMsgProcessor::processOutMessage");
-	}
-	
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *  
+ */
+
+package org.apache.sandesha2.msgprocessors;
+
+import java.util.Collection;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SandeshaListener;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.security.SecurityManager;
+import org.apache.sandesha2.security.SecurityToken;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.CreateSeqBean;
+import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.util.FaultManager;
+import org.apache.sandesha2.util.RMMsgCreator;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.util.SequenceManager;
+import org.apache.sandesha2.util.SpecSpecificConstants;
+import org.apache.sandesha2.wsrm.Accept;
+import org.apache.sandesha2.wsrm.CreateSequence;
+import org.apache.sandesha2.wsrm.CreateSequenceResponse;
+import org.apache.sandesha2.wsrm.SequenceOffer;
+
+/**
+ * Responsible for processing an incoming Create Sequence message.
+ */
+
+public class CreateSeqMsgProcessor implements MsgProcessor {
+
+	private static final Log log = LogFactory.getLog(CreateSeqMsgProcessor.class);
+
+	public void processInMessage(RMMsgContext createSeqRMMsg) throws AxisFault {
+		if (log.isDebugEnabled())
+			log.debug("Enter: CreateSeqMsgProcessor::processInMessage");
+
+		MessageContext createSeqMsg = createSeqRMMsg.getMessageContext();
+		CreateSequence createSeqPart = (CreateSequence) createSeqRMMsg
+				.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
+		if (createSeqPart == null) {
+			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noCreateSeqParts);
+			log.debug(message);
+			throw new SandeshaException(message);
+		}
+
+		ConfigurationContext context = createSeqMsg.getConfigurationContext();
+		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());
+
+		FaultManager faultManager = new FaultManager();
+		SandeshaException fault = faultManager.checkForCreateSequenceRefused(createSeqMsg, storageManager);
+		if (fault != null) {
+			throw fault;
+		}
+		
+		// If the inbound CreateSequence includes a SecurityTokenReference then
+		// ask the security manager to resolve that to a token for us. We also
+		// check that the Create was secured using the token.
+		OMElement theSTR = createSeqPart.getSecurityTokenReference();
+		SecurityToken token = null;
+		if(theSTR != null) {
+			SecurityManager secManager = SandeshaUtil.getSecurityManager(context);
+			MessageContext msgcontext = createSeqRMMsg.getMessageContext();
+			token = secManager.getSecurityToken(theSTR, msgcontext);
+			
+			// The create must be the body part of this message, so we check the
+			// security of that element.
+			OMElement body = msgcontext.getEnvelope().getBody();
+			secManager.checkProofOfPossession(token, body, msgcontext);
+		}
+
+		MessageContext outMessage = null;
+		try {
+			outMessage = Utils.createOutMessageContext(createSeqMsg); // createing
+																		// a new
+																		// response
+																		// message.
+		} catch (AxisFault e1) {
+			throw new SandeshaException(e1);
+		}
+		SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
+
+		try {
+			String newSequenceId = SequenceManager.setupNewSequence(createSeqRMMsg, storageManager); // newly
+																										// created
+																										// sequnceID.
+
+			
+			
+			RMMsgContext createSeqResponse = RMMsgCreator.createCreateSeqResponseMsg(createSeqRMMsg, outMessage,
+					newSequenceId, storageManager); // 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 = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcceptPart);
+					log.debug(message);
+					throw new SandeshaException(message);
+				}
+
+				String offeredSequenceID = offer.getIdentifer().getIdentifier(); // offered
+																					// seq.
+																					// id.
+
+				boolean offerEcepted = offerAccepted(offeredSequenceID, context, createSeqRMMsg, storageManager);
+
+				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.
+					
+					String outgoingSideSequencePropertyKey = outgoingSideInternalSequenceId;
+
+					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.setSequencePropertyKey(outgoingSideSequencePropertyKey);
+					seqPropMgr.insert(outSequenceBean);
+
+					// setting the internal_sequence_id
+					SequencePropertyBean internalSequenceBean = new SequencePropertyBean();
+					internalSequenceBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
+					internalSequenceBean.setSequencePropertyKey(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 = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcksToPartInCreateSequence);
+				log.debug(message);
+				throw new AxisFault(message);
+			}
+			
+			//TODO add createSequenceResponse message as the referenceMessage to the NextMsgBean.
+			
+
+			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.
+
+			SequenceManager.updateLastActivatedTime(newSequenceId, storageManager);
+
+			AxisEngine engine = new AxisEngine(context);
+			engine.send(outMessage);
+
+			SequencePropertyBean toBean = seqPropMgr.retrieve(newSequenceId,
+					Sandesha2Constants.SequenceProperties.TO_EPR);
+			if (toBean == null) {
+				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
+				log.debug(message);
+				throw new SandeshaException(message);
+			}
+
+			EndpointReference toEPR = new EndpointReference(toBean.getValue());
+
+			String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(newSequenceId,
+					Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, storageManager);
+			String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);
+
+			if (anonymousURI.equals(toEPR.getAddress())) {
+				createSeqMsg.getOperationContext().setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN, "true");
+			} else {
+				createSeqMsg.getOperationContext().setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN, "false");
+			}
+
+		} catch (AxisFault e1) {
+			throw new SandeshaException(e1);
+		}
+
+		createSeqRMMsg.pause();
+
+		if (log.isDebugEnabled())
+			log.debug("Exit: CreateSeqMsgProcessor::processInMessage");
+	}
+
+	private boolean offerAccepted(String sequenceId, ConfigurationContext configCtx, RMMsgContext createSeqRMMsg,
+			StorageManager storageManager) throws SandeshaException {
+		if (log.isDebugEnabled())
+			log.debug("Enter: CreateSeqMsgProcessor::offerAccepted, " + sequenceId);
+
+		if ("".equals(sequenceId)) {
+			if (log.isDebugEnabled())
+				log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + false);
+			return false;
+		}
+
+		CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
+
+		CreateSeqBean createSeqFindBean = new CreateSeqBean();
+		createSeqFindBean.setSequenceID(sequenceId);
+		Collection arr = createSeqMgr.find(createSeqFindBean);
+
+		if (arr.size() > 0) {
+			if (log.isDebugEnabled())
+				log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + false);
+			return false;
+		}
+		if (sequenceId.length() <= 1) {
+			if (log.isDebugEnabled())
+				log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + false);
+			return false; // Single character offers are NOT accepted.
+		}
+
+		if (log.isDebugEnabled())
+			log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + true);
+		return true;
+	}
+
+	public void processOutMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
+		if (log.isDebugEnabled())
+			log.debug("Enter: CreateSeqMsgProcessor::processOutMessage");
+
+		MessageContext msgCtx = rmMsgCtx.getMessageContext();
+
+		// adding the SANDESHA_LISTENER
+		SandeshaListener faultCallback = (SandeshaListener) msgCtx.getOptions().getProperty(
+				SandeshaClientConstants.SANDESHA_LISTENER);
+		if (faultCallback != null) {
+			OperationContext operationContext = msgCtx.getOperationContext();
+			if (operationContext != null) {
+				operationContext.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, faultCallback);
+			}
+		}
+		if (log.isDebugEnabled())
+			log.debug("Exit: CreateSeqMsgProcessor::processOutMessage");
+	}
+	
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org