ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mckie...@apache.org
Subject svn commit: r592747 - in /webservices/sandesha/trunk/java/modules: core/src/main/java/org/apache/sandesha2/ core/src/main/java/org/apache/sandesha2/client/ core/src/main/java/org/apache/sandesha2/util/ core/src/main/java/org/apache/sandesha2/wsrm/ test...
Date Wed, 07 Nov 2007 13:50:33 GMT
Author: mckierna
Date: Wed Nov  7 05:50:32 2007
New Revision: 592747

URL: http://svn.apache.org/viewvc?rev=592747&view=rev
Log:
https://issues.apache.org/jira/browse/SANDESHA2-126

Added:
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/LastMessageNumber.java
Modified:
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClient.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SequenceManager.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/TerminateManager.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/CloseSequence.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/TerminateSequence.java
    webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/faulttests/SequenceTerminatedFaultTest.java
    webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/wsrm/TerminateSequenceTest.java
    webservices/sandesha/trunk/java/modules/tests/test-resources/TerminateSequence.xml

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java
Wed Nov  7 05:50:32 2007
@@ -184,6 +184,8 @@
 
 		String CLOSE_SEQUENCE = "CloseSequence";
 		
+		String LAST_MSG_NUMBER = "LastMsgNumber";
+		
 		String CLOSE_SEQUENCE_RESPONSE = "CloseSequenceResponse";
 		
 		String TERMINATE_SEQUENCE_RESPONSE = "TerminateSequenceResponse";

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClient.java?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClient.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClient.java
Wed Nov  7 05:50:32 2007
@@ -65,6 +65,7 @@
 import org.apache.sandesha2.wsrm.AckRequested;
 import org.apache.sandesha2.wsrm.CloseSequence;
 import org.apache.sandesha2.wsrm.Identifier;
+import org.apache.sandesha2.wsrm.LastMessageNumber;
 import org.apache.sandesha2.wsrm.TerminateSequence;
 
 /**
@@ -984,11 +985,49 @@
 		// Get a transaction for getting the sequence properties
 		Transaction transaction = null;
 		String sequenceID = null;
-		
+		SOAPEnvelope dummyEnvelope = null;
 		try
 		{
 			transaction = storageManager.getTransaction();
 			sequenceID = SandeshaUtil.getSequenceIDFromInternalSequenceID(internalSequenceID, storageManager);
+			if (sequenceID == null)
+				sequenceID = Sandesha2Constants.TEMP_SEQUENCE_ID;	
+
+			String rmSpecVersion = (String) options.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
+
+			if (rmSpecVersion == null)
+				rmSpecVersion = SpecSpecificConstants.getDefaultSpecVersion();
+
+			if (!SpecSpecificConstants.isSequenceClosingAllowed(rmSpecVersion))
+				throw new SandeshaException(SandeshaMessageHelper.getMessage(
+						SandeshaMessageKeys.closeSequenceSpecLevel, rmSpecVersion));
+			
+			SOAPFactory factory = null;
+			String soapNamespaceURI = options.getSoapVersionURI();
+			if (soapNamespaceURI == null) 
+				soapNamespaceURI = getSOAPNamespaceURI(storageManager, internalSequenceID);
+
+			if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapNamespaceURI)) {
+				factory = new SOAP12Factory();
+				dummyEnvelope = factory.getDefaultEnvelope();
+			} else {
+				factory = new SOAP11Factory();
+				dummyEnvelope = factory.getDefaultEnvelope();
+			}
+
+			String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmSpecVersion);
+
+			CloseSequence closeSequence = new CloseSequence(rmNamespaceValue);
+			Identifier identifier = new Identifier(rmNamespaceValue);
+			identifier.setIndentifer(sequenceID);
+			closeSequence.setIdentifier(identifier);
+			if(closeSequence.isLastMsgNumberRequired(rmNamespaceValue)){
+				LastMessageNumber lastMsgNumber = new LastMessageNumber(rmNamespaceValue);
+				lastMsgNumber.setMessageNumber(SandeshaUtil.getLastMessageNumber(internalSequenceID,
storageManager));
+				closeSequence.setLastMessageNumber(lastMsgNumber);
+			}
+			closeSequence.toSOAPEnvelope(dummyEnvelope);
+
 		}
 		finally
 		{
@@ -996,41 +1035,6 @@
 			if(transaction != null) transaction.commit();
 		}
 		
-		if (sequenceID == null)
-			sequenceID = Sandesha2Constants.TEMP_SEQUENCE_ID;	
-
-		String rmSpecVersion = (String) options.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
-
-		if (rmSpecVersion == null)
-			rmSpecVersion = SpecSpecificConstants.getDefaultSpecVersion();
-
-		if (!SpecSpecificConstants.isSequenceClosingAllowed(rmSpecVersion))
-			throw new SandeshaException(SandeshaMessageHelper.getMessage(
-					SandeshaMessageKeys.closeSequenceSpecLevel, rmSpecVersion));
-
-		SOAPEnvelope dummyEnvelope = null;
-		SOAPFactory factory = null;
-		String soapNamespaceURI = options.getSoapVersionURI();
-		if (soapNamespaceURI == null) 
-			soapNamespaceURI = getSOAPNamespaceURI(storageManager, internalSequenceID);
-
-		if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapNamespaceURI)) {
-			factory = new SOAP12Factory();
-			dummyEnvelope = factory.getDefaultEnvelope();
-		} else {
-			factory = new SOAP11Factory();
-			dummyEnvelope = factory.getDefaultEnvelope();
-		}
-
-		String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmSpecVersion);
-
-		CloseSequence closeSequence = new CloseSequence(rmNamespaceValue);
-		Identifier identifier = new Identifier(rmNamespaceValue);
-		identifier.setIndentifer(sequenceID);
-		closeSequence.setIdentifier(identifier);
-
-		closeSequence.toSOAPEnvelope(dummyEnvelope);
-
 		return dummyEnvelope;
 	}
 
@@ -1172,6 +1176,20 @@
 		Identifier identifier = new Identifier(rmNamespaceValue);
 		identifier.setIndentifer(sequenceID);
 		terminateSequence.setIdentifier(identifier);
+		if(TerminateSequence.isLastMsgNumberRequired(rmNamespaceValue)){
+			try
+			{
+				transaction = storageManager.getTransaction();
+				LastMessageNumber lastMessageNumber = new LastMessageNumber(rmNamespaceValue);
+				lastMessageNumber.setMessageNumber(SandeshaUtil.getLastMessageNumber(internalSequenceID,
storageManager));
+				terminateSequence.setLastMessageNumber(lastMessageNumber);
+			}
+			finally
+			{
+				// Commit the tran whatever happened
+				if(transaction != null) transaction.commit();
+			}
+		}
 		terminateSequence.toSOAPEnvelope(dummyEnvelope);
 
 		return dummyEnvelope;

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
Wed Nov  7 05:50:32 2007
@@ -58,6 +58,7 @@
 import org.apache.sandesha2.wsrm.Endpoint;
 import org.apache.sandesha2.wsrm.IOMRMPart;
 import org.apache.sandesha2.wsrm.Identifier;
+import org.apache.sandesha2.wsrm.LastMessageNumber;
 import org.apache.sandesha2.wsrm.MakeConnection;
 import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
 import org.apache.sandesha2.wsrm.SequenceOffer;
@@ -291,6 +292,11 @@
 		Identifier identifier = new Identifier(rmNamespaceValue);
 		identifier.setIndentifer(rmsBean.getSequenceID());
 		terminateSequencePart.setIdentifier(identifier);
+		if(TerminateSequence.isLastMsgNumberRequired(rmNamespaceValue)){
+			LastMessageNumber lastMsgNumber = new LastMessageNumber(rmNamespaceValue);
+			lastMsgNumber.setMessageNumber(SandeshaUtil.getLastMessageNumber(rmsBean.getInternalSequenceID(),
storageManager));
+			terminateSequencePart.setLastMessageNumber(lastMsgNumber);
+		}
 		terminateRMMessage.setMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ, terminateSequencePart);
 
 		// no need for an incoming transport for a terminate

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
Wed Nov  7 05:50:32 2007
@@ -618,6 +618,16 @@
 
 		return bean;
   }
+	
+	public static long getLastMessageNumber(String internalSequenceID, StorageManager storageManager)throws
SandeshaException {
+		
+		RMSBean rMSBean = getRMSBeanFromInternalSequenceId(storageManager, internalSequenceID);
+		long lastMessageNumber = 0;
+		if(rMSBean!=null){
+			lastMessageNumber = rMSBean.getHighestOutMessageNumber();
+		}
+		return lastMessageNumber;
+	}
 
 	public static String getSequenceIDFromInternalSequenceID(String internalSequenceID,
 			StorageManager storageManager) throws SandeshaException {

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SequenceManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SequenceManager.java?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SequenceManager.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SequenceManager.java
Wed Nov  7 05:50:32 2007
@@ -297,6 +297,8 @@
 	
 	public static void finalizeTimedOutSequence(String internalSequenceID, MessageContext messageContext,
 			StorageManager storageManager) throws SandeshaException {
+		if (log.isDebugEnabled()) log.debug("Enter: SequenceManager::finalizeTimedOutSequence:"
+ internalSequenceID);
+		
 		ConfigurationContext configurationContext = null;
 		if (messageContext == null)
 			configurationContext = storageManager.getContext();
@@ -309,8 +311,24 @@
 		// Notify any waiting clients that the sequence has timeed out.
 		FaultManager.notifyClientsOfFault(internalSequenceID, storageManager, configurationContext,
fault);
 		
+		//try and send a terminate message
+		try{
+			RMSBean bean = new RMSBean();
+			bean.setInternalSequenceID(internalSequenceID);
+			storageManager.getRMSBeanMgr().findUnique(bean);
+			if(bean!=null){
+				TerminateManager.checkAndTerminate(configurationContext, storageManager, bean);
+			}			
+		}
+		catch(Exception e){
+			//log this error but continue to timeout sequence
+			if (log.isDebugEnabled()) log.debug("SequenceManager::finalizeTimedOutSequence:Error caught:"
+ e);
+		}
+
+		
 		// Already an active transaction, so don't want a new one
 		TerminateManager.timeOutSendingSideSequence(internalSequenceID, storageManager);
+		
 
 		if (messageContext != null) {
 			SandeshaListener listener = (SandeshaListener) messageContext
@@ -320,6 +338,7 @@
 				listener.onTimeOut(report);
 			}
 		}
+		if (log.isDebugEnabled()) log.debug("Exit: SequenceManager::finalizeTimedOutSequence");
 	}
 
 	public static String getSpecVersion(MessageContext applicationMessage, StorageManager storageManager)

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/TerminateManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/TerminateManager.java?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/TerminateManager.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/TerminateManager.java
Wed Nov  7 05:50:32 2007
@@ -233,7 +233,7 @@
 		rmsBean.setTerminateAdded(true);
 		storageManager.getRMSBeanMgr().update(rmsBean);
 		
-		cleanSendingSideData (rmsBean.getInternalSequenceID(), storageManager);
+		cleanSendingSideData (rmsBean.getInternalSequenceID(), storageManager, rmsBean);
 	}
 
 	public static void timeOutSendingSideSequence(String internalSequenceId,
@@ -244,10 +244,10 @@
 		rmsBean.setLastActivatedTime(System.currentTimeMillis());
 		storageManager.getRMSBeanMgr().update(rmsBean);
 
-		cleanSendingSideData(internalSequenceId, storageManager);
+		cleanSendingSideData(internalSequenceId, storageManager, rmsBean);
 	}
 
-	private static void cleanSendingSideData(String internalSequenceId, StorageManager storageManager)
throws SandeshaException {
+	private static void cleanSendingSideData(String internalSequenceId, StorageManager storageManager,
RMSBean rmsBean) throws SandeshaException {
 
 		SenderBeanMgr retransmitterBeanMgr = storageManager.getSenderBeanMgr();
 
@@ -256,10 +256,13 @@
 		Iterator iterator = collection.iterator();
 		while (iterator.hasNext()) {
 			SenderBean retransmitterBean = (SenderBean) iterator.next();
-			retransmitterBeanMgr.delete(retransmitterBean.getMessageID());
-
-			String messageStoreKey = retransmitterBean.getMessageContextRefKey();
-			storageManager.removeMessageContext(messageStoreKey);
+			if(retransmitterBean.getMessageType()!=Sandesha2Constants.MessageTypes.TERMINATE_SEQ ||
rmsBean.isTerminated()){
+				//remove all but terminate sequence messages
+				retransmitterBeanMgr.delete(retransmitterBean.getMessageID());
+
+				String messageStoreKey = retransmitterBean.getMessageContextRefKey();
+				storageManager.removeMessageContext(messageStoreKey);				
+			}
 		}
 	}
 

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/CloseSequence.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/CloseSequence.java?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/CloseSequence.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/CloseSequence.java
Wed Nov  7 05:50:32 2007
@@ -37,7 +37,7 @@
 public class CloseSequence implements IOMRMPart {
 
 	private Identifier identifier;
-	
+	private LastMessageNumber lastMessageNumber;
 	private String namespaceValue = null;
 	
 	public CloseSequence(String namespaceValue) throws SandeshaException {
@@ -72,6 +72,12 @@
 		if(identifierPart != null){
 			identifier.fromOMElement(identifierPart);
 		}
+		
+		OMElement lastMessageNumberPart = closeSeqPart.getFirstChildWithName(new QName(namespaceValue,
Sandesha2Constants.WSRM_COMMON.LAST_MSG_NUMBER));
+		if(lastMessageNumberPart != null){
+			lastMessageNumber = new LastMessageNumber(namespaceValue);
+			lastMessageNumber.fromOMElement(lastMessageNumberPart);
+		}
 		return this;
 	}
 	
@@ -92,6 +98,10 @@
 		OMElement closeSequenceElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE,
rmNamespace);
 		
 		identifier.toOMElement(closeSequenceElement, rmNamespace);
+		if(lastMessageNumber!=null){
+			lastMessageNumber.toOMElement(closeSequenceElement, rmNamespace);
+		}
+		
 		body.addChild(closeSequenceElement);
 
 		return body;
@@ -125,6 +135,21 @@
 			return true;
 		
 		return false;
+	}
+	
+	public boolean isLastMsgNumberRequired(String namespaceName){
+		if (Sandesha2Constants.SPEC_2007_02.NS_URI.equals(namespaceName))
+			return true;
+		else 
+			return false;		
+	}
+	
+	public void setLastMessageNumber(LastMessageNumber number){
+		this.lastMessageNumber = number;
+	}
+	
+	public LastMessageNumber getLastMessageNumber(){
+		return this.lastMessageNumber;
 	}
 
 }

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/LastMessageNumber.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/LastMessageNumber.java?rev=592747&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/LastMessageNumber.java
(added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/LastMessageNumber.java
Wed Nov  7 05:50:32 2007
@@ -0,0 +1,90 @@
+/*
+ * 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.wsrm;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+
+public class LastMessageNumber
+{
+	private long messageNumber;
+	
+	private String namespaceValue = null;
+	
+	public LastMessageNumber(String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException (SandeshaMessageHelper.getMessage(
+					SandeshaMessageKeys.unknownSpec,
+					namespaceValue));
+		
+		this.namespaceValue = namespaceValue;
+	}
+	
+	public long getMessageNumber(){
+		return messageNumber;
+	}
+	public void setMessageNumber(long messageNumber){
+		this.messageNumber = messageNumber;
+	}
+	
+	public Object fromOMElement(OMElement msgNumberPart) throws OMException {
+		if (msgNumberPart==null)
+			throw new OMException (SandeshaMessageHelper.getMessage(
+					SandeshaMessageKeys.noMessageNumberPartInElement,
+					msgNumberPart.toString()));
+		
+		String msgNoStr = msgNumberPart.getText();
+		messageNumber = Long.parseLong(msgNoStr);
+		return this;
+	}
+	
+	public OMElement toOMElement(OMElement element, OMNamespace rmNamespace) throws OMException
{
+		if (messageNumber <= 0 ){
+			throw new OMException(SandeshaMessageHelper.getMessage(
+					SandeshaMessageKeys.setAValidMsgNumber,
+					Long.toString(messageNumber)));
+		}
+		
+		OMFactory factory = element.getOMFactory();
+		
+		OMElement messageNoElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.LAST_MSG_NUMBER,rmNamespace);
+		messageNoElement.setText(Long.toString(messageNumber));
+		element.addChild(messageNoElement);
+		
+		return element;
+	}
+	
+	public String getNamespaceValue() throws OMException {
+		return namespaceValue;
+	}
+
+	public boolean isNamespaceSupported (String namespaceName) {
+		
+		if (Sandesha2Constants.SPEC_2007_02.NS_URI.equals(namespaceName))
+			return true; //only supported for 2007_02
+		
+		return false;
+	}
+
+}
+

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/TerminateSequence.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/TerminateSequence.java?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/TerminateSequence.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/wsrm/TerminateSequence.java
Wed Nov  7 05:50:32 2007
@@ -37,7 +37,7 @@
 public class TerminateSequence implements IOMRMPart {
 
 	private Identifier identifier;
-	
+	private LastMessageNumber lastMessageNumber;
 	private String namespaceValue = null;
 	
 	public TerminateSequence(String namespaceValue) throws SandeshaException {
@@ -72,6 +72,12 @@
 		if(identifierPart != null){
 			identifier.fromOMElement(identifierPart);
 		}
+		
+		OMElement lastMessageNumberPart = terminateSeqPart.getFirstChildWithName(new QName(namespaceValue,
Sandesha2Constants.WSRM_COMMON.LAST_MSG_NUMBER));
+		if(lastMessageNumberPart != null){
+			lastMessageNumber = new LastMessageNumber(namespaceValue);
+			lastMessageNumber.fromOMElement(lastMessageNumberPart);
+		}
 
 		return this;
 	}
@@ -93,8 +99,12 @@
 				Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE, rmNamespace);
 		
 		identifier.toOMElement(terminateSequenceElement, rmNamespace);
+		
+		if(lastMessageNumber!=null){
+			lastMessageNumber.toOMElement(terminateSequenceElement, rmNamespace);
+		}
+		
 		body.addChild(terminateSequenceElement);
-
 		return body;
 	}
 
@@ -105,6 +115,14 @@
 	public void setIdentifier(Identifier identifier) {
 		this.identifier = identifier;
 	}
+	
+	public void setLastMessageNumber(LastMessageNumber number){
+		this.lastMessageNumber = number;
+	}
+	
+	public LastMessageNumber getLastMessageNumber(){
+		return this.lastMessageNumber;
+	}
 
 	public void toSOAPEnvelope(SOAPEnvelope envelope) {
 		SOAPBody body = envelope.getBody();
@@ -126,6 +144,14 @@
 			return true;
 		
 		return false;
+	}
+	
+	public static boolean isLastMsgNumberRequired(String namespaceName){
+		
+		if (Sandesha2Constants.SPEC_2007_02.NS_URI.equals(namespaceName))
+			return true;
+		else
+			return false;		
 	}
 	
 }

Modified: webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/faulttests/SequenceTerminatedFaultTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/faulttests/SequenceTerminatedFaultTest.java?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/faulttests/SequenceTerminatedFaultTest.java
(original)
+++ webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/faulttests/SequenceTerminatedFaultTest.java
Wed Nov  7 05:50:32 2007
@@ -51,6 +51,7 @@
 import org.apache.sandesha2.wsrm.AckRequested;
 import org.apache.sandesha2.wsrm.CloseSequence;
 import org.apache.sandesha2.wsrm.Identifier;
+import org.apache.sandesha2.wsrm.LastMessageNumber;
 import org.apache.sandesha2.wsrm.MessageNumber;
 import org.apache.sandesha2.wsrm.Sequence;
 
@@ -476,6 +477,9 @@
 		Identifier id1 = new Identifier(rmNamespaceValue);
 		id1.setIndentifer(uuid);
 		sequence.setIdentifier(id1);
+		LastMessageNumber lastMsgNumber = new LastMessageNumber(rmNamespaceValue);
+		lastMsgNumber.setMessageNumber(1);
+		sequence.setLastMessageNumber(lastMsgNumber);
 		applicationRMMsg.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE, sequence);
 		applicationRMMsg.addSOAPEnvelope();
 
@@ -547,5 +551,6 @@
 	}
 
 }
+
 
 

Modified: webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/wsrm/TerminateSequenceTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/wsrm/TerminateSequenceTest.java?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/wsrm/TerminateSequenceTest.java
(original)
+++ webservices/sandesha/trunk/java/modules/tests/src/test/java/org/apache/sandesha2/wsrm/TerminateSequenceTest.java
Wed Nov  7 05:50:32 2007
@@ -29,12 +29,14 @@
 public class TerminateSequenceTest extends SandeshaTestCase {
 
 	SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
-	String rmNamespace = Sandesha2Constants.SPEC_2005_02.NS_URI;
+	String rmNamespace = Sandesha2Constants.SPEC_2007_02.NS_URI;
 	
     public TerminateSequenceTest() {
         super("TerminateSequenceTest");
     }
 
+    
+    
     public void testFromOMElement() throws SandeshaException {
         TerminateSequence terminateSequence =  new TerminateSequence(rmNamespace);
         SOAPEnvelope env = getSOAPEnvelope("", "TerminateSequence.xml");
@@ -42,6 +44,7 @@
 
         Identifier identifier = terminateSequence.getIdentifier();
         assertEquals("uuid:59b0c910-1625-11da-bdfc-b09ed76a1f06", identifier.getIdentifier());
+        assertEquals(1, terminateSequence.getLastMessageNumber().getMessageNumber());
     }
 
     public void testToSOAPEnvelope() throws SandeshaException {
@@ -50,6 +53,12 @@
         identifier.setIndentifer("uuid:59b0c910-1625-11da-bdfc-b09ed76a1f06");
         terminateSequence.setIdentifier(identifier);
 
+        if(TerminateSequence.isLastMsgNumberRequired(Sandesha2Constants.SPEC_2007_02.NS_URI)){
+        	LastMessageNumber lastMessageNumber = new LastMessageNumber(Sandesha2Constants.SPEC_2007_02.NS_URI);
+        	lastMessageNumber.setMessageNumber(1);
+        	terminateSequence.setLastMessageNumber(lastMessageNumber);
+        }
+        
         SOAPEnvelope env = getEmptySOAPEnvelope();
         terminateSequence.toSOAPEnvelope(env);
 

Modified: webservices/sandesha/trunk/java/modules/tests/test-resources/TerminateSequence.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/tests/test-resources/TerminateSequence.xml?rev=592747&r1=592746&r2=592747&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/tests/test-resources/TerminateSequence.xml (original)
+++ webservices/sandesha/trunk/java/modules/tests/test-resources/TerminateSequence.xml Wed
Nov  7 05:50:32 2007
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"
xmlns:wsa="http://www.w3.org/2005/08/addressing"> 
+   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"
xmlns:wsa="http://www.w3.org/2005/08/addressing"> 
       <soapenv:Header>  
          <wsa:MessageID soapenv:mustUnderstand="1">uuid:64f5c3c0-1625-11da-a28e-b3b9c4e71445</wsa:MessageID>
 
          <wsa:To soapenv:mustUnderstand="1">http://127.0.0.1:9070/axis/services/RMService</wsa:To>
 
@@ -11,6 +11,7 @@
       <soapenv:Body>  
          <wsrm:TerminateSequence>   
             <wsrm:Identifier>uuid:59b0c910-1625-11da-bdfc-b09ed76a1f06</wsrm:Identifier>
 
+			<wsrm:LastMsgNumber>1</wsrm:LastMsgNumber>  
          </wsrm:TerminateSequence> 
       </soapenv:Body>
    </soapenv:Envelope>



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


Mime
View raw message