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/06/15 07:51:24 UTC

svn commit: r414476 [11/15] - in /webservices/sandesha/trunk: ./ c/ config/ interop/ java/ java/config/ java/interop/ java/interop/conf/ java/interop/src/ java/interop/src/org/ java/interop/src/org/apache/ java/interop/src/org/apache/sandesha2/ java/in...

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AckRequested.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AckRequested.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AckRequested.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AckRequested.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,157 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * Represent the AckRequested header block.
+ * 
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class AckRequested implements IOMRMPart {
+	
+	private Identifier identifier;
+	
+	private MessageNumber messageNumber;
+	
+	private OMFactory defaultFactory;
+	
+	private String namespaceValue = null;
+	
+	private boolean mustUnderstand = false;
+
+	public AckRequested(OMFactory factory,String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.namespaceValue = namespaceValue;
+	}
+
+	public String getNamespaceValue() {
+		return namespaceValue;
+	}
+
+	public Object fromOMElement(OMElement header) throws OMException,SandeshaException {
+
+		if (header == null || !(header instanceof SOAPHeader))
+			throw new OMException("Cant add the Ack Requested part to a non-header element");
+
+		OMElement ackReqPart = header.getFirstChildWithName(new QName(namespaceValue, Sandesha2Constants.WSRM_COMMON.ACK_REQUESTED));
+
+		if (ackReqPart == null)
+			throw new OMException("the passed element does not contain an ack requested part");
+
+		identifier = new Identifier(defaultFactory,namespaceValue);
+		identifier.fromOMElement(ackReqPart);
+
+		OMElement msgNoPart = ackReqPart.getFirstChildWithName(new QName(
+				namespaceValue, Sandesha2Constants.WSRM_COMMON.MSG_NUMBER));
+
+		if (msgNoPart != null) {
+			messageNumber = new MessageNumber(defaultFactory,namespaceValue);
+			messageNumber.fromOMElement(ackReqPart);
+		}
+
+		return this;
+	}
+
+	public OMElement toOMElement(OMElement header) throws OMException {
+
+		if (header == null || !(header instanceof SOAPHeader))
+			throw new OMException(
+					"Cant add the Ack Requested part to a non-header element");
+
+		if (identifier == null)
+			throw new OMException("Cant add ack Req block since the identifier is null");
+		
+		OMFactory factory = header.getOMFactory();
+		OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+
+		SOAPHeader SOAPHdr = (SOAPHeader) header;
+		SOAPHeaderBlock ackReqHdrBlock = SOAPHdr.addHeaderBlock(Sandesha2Constants.WSRM_COMMON.ACK_REQUESTED, rmNamespace);
+		ackReqHdrBlock.setMustUnderstand(isMustUnderstand());
+
+		identifier.toOMElement(ackReqHdrBlock);
+
+		if (messageNumber != null) {
+			messageNumber.toOMElement(ackReqHdrBlock);
+		}
+
+		return header;
+	}
+
+	public void setIdentifier(Identifier identifier) {
+		this.identifier = identifier;
+	}
+
+	public void setMessageNumber(MessageNumber messageNumber) {
+		this.messageNumber = messageNumber;
+	}
+
+	public Identifier getIdentifier() {
+		return identifier;
+	}
+
+	public MessageNumber getMessageNumber() {
+		return messageNumber;
+	}
+
+	public void toSOAPEnvelope(SOAPEnvelope envelope) {
+		SOAPHeader header = envelope.getHeader();
+		
+		//detach if already exist.
+		OMElement elem = header.getFirstChildWithName(new QName(namespaceValue,
+				Sandesha2Constants.WSRM_COMMON.ACK_REQUESTED));
+		if (elem!=null)
+			elem.detach();
+		
+		toOMElement(header);
+	}
+	
+	public boolean isMustUnderstand() {
+		return mustUnderstand;
+	}
+
+	public void setMustUnderstand(boolean mustUnderstand) {
+		this.mustUnderstand = mustUnderstand;
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}
\ No newline at end of file

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,138 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAttribute;
+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;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class AcknowledgementRange implements IOMRMElement {
+	
+	private long upperValue;
+	
+	private long lowerValue;
+	
+	private OMFactory defaultFactory;
+	
+	private String namespaceValue = null;
+	
+	public AcknowledgementRange(OMFactory factory, String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.namespaceValue = namespaceValue;
+	}
+
+	public String getNamespaceValue() {
+		return namespaceValue;
+	}
+
+	public Object fromOMElement(OMElement ackRangePart) throws OMException {
+
+		if (ackRangePart == null)
+			throw new OMException("The passed element is null");
+
+		OMAttribute lowerAttrib = ackRangePart.getAttribute(new QName(
+				Sandesha2Constants.WSRM_COMMON.LOWER));
+		OMAttribute upperAttrib = ackRangePart.getAttribute(new QName(
+				Sandesha2Constants.WSRM_COMMON.UPPER));
+
+		if (lowerAttrib == null || upperAttrib == null)
+			throw new OMException(
+					"Passed element does not contain upper or lower attributes");
+
+		try {
+			long lower = Long.parseLong(lowerAttrib.getAttributeValue());
+			long upper = Long.parseLong(upperAttrib.getAttributeValue());
+			upperValue = upper;
+			lowerValue = lower;
+		} catch (Exception ex) {
+			throw new OMException(
+					"The ack range does not have proper long values for Upper and Lower attributes");
+		}
+
+		return this;
+	}
+
+	public OMElement toOMElement(OMElement sequenceAckElement)
+			throws OMException {
+
+		if (sequenceAckElement == null)
+			throw new OMException("Cant set Ack Range part since element is null");
+
+		if (upperValue <= 0 || lowerValue <= 0 || lowerValue > upperValue)
+			throw new OMException(
+					"Cant set Ack Range part since Upper or Lower is not set to the correct value");
+
+		OMFactory factory = sequenceAckElement.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMAttribute lowerAttrib = factory.createOMAttribute(
+				Sandesha2Constants.WSRM_COMMON.LOWER, null, Long.toString(lowerValue));
+		OMAttribute upperAttrib = factory.createOMAttribute(
+				Sandesha2Constants.WSRM_COMMON.UPPER, null, Long.toString(upperValue));
+
+		OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement acknowledgementRangeElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.ACK_RANGE, rmNamespace);
+		
+		acknowledgementRangeElement.addAttribute(lowerAttrib);
+		acknowledgementRangeElement.addAttribute(upperAttrib);
+		sequenceAckElement.addChild(acknowledgementRangeElement);
+
+		return sequenceAckElement;
+	}
+
+	public long getLowerValue() {
+		return lowerValue;
+	}
+
+	public void setLowerValue(long lowerValue) {
+		this.lowerValue = lowerValue;
+	}
+
+	public long getUpperValue() {
+		return upperValue;
+	}
+
+	public void setUpperValue(long upperValue) {
+		this.upperValue = upperValue;
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}
\ No newline at end of file

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AcksTo.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AcksTo.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AcksTo.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/AcksTo.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,111 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class AcksTo implements IOMRMElement {
+
+	private Address address;
+	
+	private OMFactory defaultFactory;
+	
+	private String rmNamespaceValue = null;
+	
+	private String addressingNamespaceValue = null;
+
+	public AcksTo(OMFactory factory,String rmNamespaceValue,String addressingNamespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(rmNamespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.rmNamespaceValue = rmNamespaceValue;
+		this.addressingNamespaceValue = addressingNamespaceValue;
+	}
+	
+	public AcksTo (Address address,SOAPFactory factory,String rmNamespaceValue, String addressingNamespaceValue) throws SandeshaException {
+		this (factory,rmNamespaceValue,addressingNamespaceValue);
+		this.address = address;
+	}
+
+	public String getNamespaceValue(){
+		return rmNamespaceValue;
+	}
+
+	public Object fromOMElement(OMElement element) throws OMException,SandeshaException {
+		OMElement acksToPart = element.getFirstChildWithName(new QName(
+				rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.ACKS_TO));
+
+		if (acksToPart == null)
+			throw new OMException("Passed element does not contain an acksTo part");
+
+		address = new Address(defaultFactory,addressingNamespaceValue);
+		address.fromOMElement(acksToPart);
+
+		return this;
+	}
+
+	public OMElement toOMElement(OMElement element) throws OMException {
+
+		if (address == null)
+			throw new OMException("Cannot set AcksTo. Address is null");
+
+		OMFactory factory = element.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMNamespace rmNamespace = factory.createOMNamespace(rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement acksToElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.ACKS_TO, rmNamespace);
+		
+		address.toOMElement(acksToElement);
+		
+		element.addChild(acksToElement);
+		return element;
+	}
+
+	public Address getAddress() {
+		return address;
+	}
+
+	public void setAddress(Address address) {
+		this.address = address;
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}
\ No newline at end of file

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Address.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Address.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Address.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Address.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,96 @@
+/*
+ * Created on Sep 1, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.sandesha2.wsrm;
+
+import javax.xml.namespace.QName;
+
+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.axis2.addressing.EndpointReference;
+import org.apache.sandesha2.Sandesha2Constants;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class Address implements IOMRMElement {
+
+	private EndpointReference epr = null;
+	
+	private OMFactory defaultFactory;
+	
+	private String addressingNamespaceValue = null;
+	
+	public Address(OMFactory factory, String addressingNamespaceValue) {
+		this.defaultFactory = factory;
+		this.addressingNamespaceValue = addressingNamespaceValue;
+	}
+	
+	public Address (EndpointReference epr,OMFactory factory,String addressingNamespaceValue) {
+		this(factory,addressingNamespaceValue);
+		this.epr = epr;
+	}
+
+	public Object fromOMElement(OMElement element) throws OMException {
+
+		OMElement addressPart = element.getFirstChildWithName(new QName(
+				addressingNamespaceValue, Sandesha2Constants.WSA.ADDRESS));
+		if (addressPart == null)
+			throw new OMException("Cant find an Address element in the given part");
+		String addressText = addressPart.getText();
+		if (addressText == null || addressText == "")
+			throw new OMException(
+					"Passed element does not have a valid address text");
+
+		epr = new EndpointReference(addressText);
+		return this;
+	}
+
+	public String getNamespaceValue(){
+		return addressingNamespaceValue;
+	}
+
+	public OMElement toOMElement(OMElement element) throws OMException {
+
+		if (epr == null || epr.getAddress() == null || epr.getAddress() == "")
+			throw new OMException("cant set the address. The address value is not valid");
+
+		OMFactory factory = element.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMNamespace addressingNamespace = factory.createOMNamespace(addressingNamespaceValue,Sandesha2Constants.WSA.NS_PREFIX_ADDRESSING);
+		OMElement addressElement = factory.createOMElement(Sandesha2Constants.WSA.ADDRESS, addressingNamespace);
+		
+		addressElement.setText(epr.getAddress());
+		element.addChild(addressElement);
+
+		return element;
+	}
+
+	public EndpointReference getEpr() {
+		return epr;
+	}
+
+	public void setEpr(EndpointReference epr) {
+		this.epr = epr;
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}
\ No newline at end of file

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CloseSequence.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CloseSequence.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CloseSequence.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CloseSequence.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,125 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * Adds the Close Sequence body part.
+ * 
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class CloseSequence implements IOMRMPart {
+
+	private Identifier identifier;
+	
+	private OMFactory defaultFactory;
+	
+	private String namespaceValue = null;
+	
+	public CloseSequence(OMFactory factory, String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.namespaceValue = namespaceValue;
+	}
+
+	public String getNamespaceValue() {
+		return namespaceValue;
+	}
+
+	public Object fromOMElement(OMElement body) throws OMException,SandeshaException {
+
+		if (!(body instanceof SOAPBody))
+			throw new OMException("Cant extract 'close sequence' from a non body element");
+
+		OMElement closeSeqPart = body.getFirstChildWithName(new QName(
+				namespaceValue, Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE));
+
+		if (closeSeqPart == null)
+			throw new OMException("passed element does not contain a close sequence part");
+
+		identifier = new Identifier(defaultFactory,namespaceValue);
+		identifier.fromOMElement(closeSeqPart);
+
+		return this;
+	}
+
+	public OMElement toOMElement(OMElement body) throws OMException {
+
+		if (body == null || !(body instanceof SOAPBody))
+			throw new OMException(
+					"Cant add close sequence to a nonbody element");
+
+		if (identifier == null)
+			throw new OMException("Cant add close sequence since identifier is not set");
+
+		OMFactory factory = body.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement closeSequenceElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE, rmNamespace);
+		
+		identifier.toOMElement(closeSequenceElement);
+		body.addChild(closeSequenceElement);
+
+		return body;
+	}
+
+	public Identifier getIdentifier() {
+		return identifier;
+	}
+
+	public void setIdentifier(Identifier identifier) {
+		this.identifier = identifier;
+	}
+
+	public void toSOAPEnvelope(SOAPEnvelope envelope) {
+		SOAPBody body = envelope.getBody();
+		
+		//detach if already exist.
+		OMElement elem = body.getFirstChildWithName(new QName(namespaceValue,
+				Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE));
+		if (elem!=null)
+			elem.detach();
+		
+		toOMElement(body);
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CloseSequenceResponse.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CloseSequenceResponse.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CloseSequenceResponse.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CloseSequenceResponse.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,128 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * Adds the Close Sequence Response body part.
+ * 
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+public class CloseSequenceResponse implements IOMRMPart {
+
+	private Identifier identifier;
+	
+	private OMFactory defaultFactory;
+	
+	private String namespaceValue = null;
+	
+	public CloseSequenceResponse(OMFactory factory, String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.namespaceValue = namespaceValue;
+	}
+
+	public String getNamespaceValue() {
+		return namespaceValue;
+	}
+
+	public Object fromOMElement(OMElement body) throws OMException,SandeshaException {
+
+		if (!(body instanceof SOAPBody))
+			throw new OMException(
+					"Cant add 'close sequence response' to a non body element");
+
+		OMElement closeSeqResponsePart = body.getFirstChildWithName(new QName(
+				namespaceValue, Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE_RESPONSE));
+
+		if (closeSeqResponsePart == null)
+			throw new OMException("passed element does not contain a 'close sequence response' part");
+
+		identifier = new Identifier(defaultFactory,namespaceValue);
+		identifier.fromOMElement(closeSeqResponsePart);
+
+		return this;
+	}
+
+	public OMElement toOMElement(OMElement body) throws OMException {
+
+		if (body == null || !(body instanceof SOAPBody))
+			throw new OMException(
+					"Cant add close sequence response to a nonbody element");
+
+		if (identifier == null)
+			throw new OMException(
+					"Cant add close sequence response since identifier is not set");
+
+		OMFactory factory = body.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement closeSequenceResponseElement = factory.createOMElement(
+				Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE_RESPONSE, rmNamespace);
+		identifier.toOMElement(closeSequenceResponseElement);
+		body.addChild(closeSequenceResponseElement);
+
+		return body;
+	}
+
+	public Identifier getIdentifier() {
+		return identifier;
+	}
+
+	public void setIdentifier(Identifier identifier) {
+		this.identifier = identifier;
+	}
+
+	public void toSOAPEnvelope(SOAPEnvelope envelope) {
+		SOAPBody body = envelope.getBody();
+		
+		//detach if already exist.
+		OMElement elem = body.getFirstChildWithName(new QName(namespaceValue,
+				Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE_RESPONSE));
+		if (elem!=null)
+			elem.detach();
+		
+		toOMElement(body);
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+
+
+}

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CreateSequence.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CreateSequence.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CreateSequence.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CreateSequence.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,168 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * Represent the CreateSequence body element.
+ * 
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class CreateSequence implements IOMRMPart {
+	
+	private AcksTo acksTo = null;
+	
+	private Expires expires = null;
+	
+	private SequenceOffer sequenceOffer = null;
+	
+	private OMFactory defaultFactory;
+	
+	private String rmNamespaceValue = null;
+	
+	private String addressingNamespaceValue = null;
+	
+	public CreateSequence(OMFactory factory,String rmNamespaceValue,String addressingNamespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(rmNamespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.rmNamespaceValue = rmNamespaceValue;
+		this.addressingNamespaceValue = addressingNamespaceValue;
+	}
+	
+	public CreateSequence (AcksTo acksTo,SOAPFactory factory,String rmNamespaceValue,String addressingNamespaceValue) throws SandeshaException {
+		this (factory,rmNamespaceValue,addressingNamespaceValue);
+		this.acksTo = acksTo;
+	}
+
+	public String getNamespaceValue() {
+		return rmNamespaceValue;
+	}
+
+	public Object fromOMElement(OMElement bodyElement) throws OMException,SandeshaException {
+
+		OMElement createSequencePart = bodyElement
+				.getFirstChildWithName(new QName(rmNamespaceValue,
+						                         Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE));
+		if (createSequencePart == null)
+			throw new OMException("Create sequence is not present in the passed element");
+		
+		acksTo = new AcksTo(defaultFactory,rmNamespaceValue,addressingNamespaceValue);
+		acksTo.fromOMElement(createSequencePart);
+
+		OMElement offerPart = createSequencePart.getFirstChildWithName(new QName(rmNamespaceValue,
+																	   Sandesha2Constants.WSRM_COMMON.SEQUENCE_OFFER));
+		if (offerPart != null) {
+			sequenceOffer = new SequenceOffer(defaultFactory,rmNamespaceValue);
+			sequenceOffer.fromOMElement(createSequencePart);
+		}
+
+		OMElement expiresPart = createSequencePart.getFirstChildWithName(
+						new QName(rmNamespaceValue,
+						Sandesha2Constants.WSRM_COMMON.EXPIRES));
+		if (expiresPart != null) {
+			expires = new Expires(defaultFactory,rmNamespaceValue);
+			expires.fromOMElement(createSequencePart);
+		}
+
+		return this;
+	}
+
+	public OMElement toOMElement(OMElement bodyElement) throws OMException {
+
+		if (bodyElement == null || !(bodyElement instanceof SOAPBody))
+			throw new OMException("Cant add Create Sequence Part to a non-body element");
+
+		if (acksTo == null)
+			throw new OMException("Cant add create seqeunce part, having acks to as null");
+
+		SOAPBody soapBody = (SOAPBody) bodyElement;
+		
+		OMFactory factory = bodyElement.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		OMNamespace rmNamespace = factory.createOMNamespace(rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement createSequenceElement = factory.createOMElement(
+				Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE, rmNamespace);
+		
+		acksTo.toOMElement(createSequenceElement);
+
+		if (sequenceOffer != null) {
+			sequenceOffer.toOMElement(createSequenceElement);
+		}
+
+		if (expires != null) {
+			expires.toOMElement(createSequenceElement);
+		}
+
+		soapBody.addChild(createSequenceElement);
+		return soapBody;
+	}
+
+	public void setAcksTo(AcksTo acksTo) {
+		this.acksTo = acksTo;
+	}
+
+	public void setSequenceOffer(SequenceOffer sequenceOffer) {
+		this.sequenceOffer = sequenceOffer;
+	}
+
+	public AcksTo getAcksTo() {
+		return acksTo;
+	}
+
+	public SequenceOffer getSequenceOffer() {
+		return sequenceOffer;
+	}
+
+	public void toSOAPEnvelope(SOAPEnvelope envelope) {
+		SOAPBody body = envelope.getBody();
+		
+		//detach if already exist.
+		OMElement elem = body.getFirstChildWithName(new QName(rmNamespaceValue,
+				Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE));
+		if (elem!=null)
+			elem.detach();
+		
+		toOMElement(body);
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}
\ No newline at end of file

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CreateSequenceResponse.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CreateSequenceResponse.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CreateSequenceResponse.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/CreateSequenceResponse.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,183 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * Adds the CreateSequenceResponse body part.
+ * 
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class CreateSequenceResponse implements IOMRMPart {
+	
+	private Identifier identifier;
+	
+	private Accept accept;
+	
+	private Expires expires;
+	
+	private OMFactory defaultFactory;
+	
+	private String rmNamespaceValue = null;
+	
+	private String addressingNamespaceValue = null;
+
+	public CreateSequenceResponse(OMFactory factory, String rmNamespaceValue, String addressingNamespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(rmNamespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.rmNamespaceValue = rmNamespaceValue;
+		this.addressingNamespaceValue = addressingNamespaceValue;
+	}
+
+	public String getNamespaceValue() {
+		return rmNamespaceValue;
+	}
+
+	public Object fromOMElement(OMElement bodyElement) throws OMException,SandeshaException {
+
+		if (bodyElement == null || !(bodyElement instanceof SOAPBody))
+			throw new OMException("Cant get create sequnce response from a non-body element");
+
+		SOAPBody SOAPBody = (SOAPBody) bodyElement;
+
+		OMElement createSeqResponsePart = SOAPBody
+				.getFirstChildWithName(new QName(rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE_RESPONSE));
+		if (createSeqResponsePart == null)
+			throw new OMException("The passed element does not contain a create seqence response part");
+
+		identifier = new Identifier(defaultFactory,rmNamespaceValue);
+		identifier.fromOMElement(createSeqResponsePart);
+
+		OMElement expiresPart = createSeqResponsePart.getFirstChildWithName(
+					new QName(rmNamespaceValue,
+					Sandesha2Constants.WSRM_COMMON.EXPIRES));
+		if (expiresPart != null) {
+			expires = new Expires(defaultFactory,rmNamespaceValue);
+			expires.fromOMElement(createSeqResponsePart);
+		}
+
+		OMElement acceptPart = createSeqResponsePart.getFirstChildWithName(
+						new QName(rmNamespaceValue,
+						Sandesha2Constants.WSRM_COMMON.ACCEPT));
+		if (acceptPart != null) {
+			accept = new Accept(defaultFactory,rmNamespaceValue,addressingNamespaceValue);
+			accept.fromOMElement(createSeqResponsePart);
+		}
+
+		return this;
+	}
+
+	public OMElement toOMElement(OMElement bodyElement) throws OMException {
+
+		if (bodyElement == null || !(bodyElement instanceof SOAPBody))
+			throw new OMException(
+					"Cant get create sequnce response from a non-body element");
+
+		SOAPBody SOAPBody = (SOAPBody) bodyElement;
+
+		if (identifier == null)
+			throw new OMException("cant set create sequnce response since the Identifier is not set");
+
+		OMFactory factory = bodyElement.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMNamespace rmNamespace = factory.createOMNamespace(rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMNamespace addressingNamespace = factory.createOMNamespace(addressingNamespaceValue,Sandesha2Constants.WSA.NS_PREFIX_ADDRESSING);
+		
+		OMElement createSequenceResponseElement = factory.createOMElement(
+				Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE_RESPONSE,
+				rmNamespace);
+		
+		identifier.toOMElement(createSequenceResponseElement);
+
+		if (expires != null) {
+			expires.toOMElement(createSequenceResponseElement);
+		}
+
+		if (accept != null) {
+			accept.toOMElement(createSequenceResponseElement);
+		}
+
+		SOAPBody.addChild(createSequenceResponseElement);
+
+		
+
+		return SOAPBody;
+	}
+
+	public void setIdentifier(Identifier identifier) {
+		this.identifier = identifier;
+	}
+
+	public Identifier getIdentifier() {
+		return identifier;
+	}
+
+	public void setAccept(Accept accept) {
+		this.accept = accept;
+	}
+
+	public Accept getAccept() {
+		return accept;
+	}
+
+	public Expires getExpires() {
+		return expires;
+	}
+
+	public void setExpires(Expires expires) {
+		this.expires = expires;
+	}
+
+	public void toSOAPEnvelope(SOAPEnvelope envelope) {
+		SOAPBody body = envelope.getBody();
+		
+		//detach if already exist.
+		OMElement elem = body.getFirstChildWithName(new QName(rmNamespaceValue,
+				Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE_RESPONSE));
+		if (elem!=null)
+			elem.detach();
+		
+		toOMElement(body);
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}
\ No newline at end of file

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Expires.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Expires.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Expires.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Expires.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,105 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class Expires implements IOMRMElement {
+
+	private OMFactory defaultFactory;
+	
+	private String duration = null;
+	
+	private String namespaceValue = null;
+
+	public Expires(OMFactory factory,String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.namespaceValue = namespaceValue;
+	}
+
+	public Object fromOMElement(OMElement element) throws OMException {
+		OMElement expiresPart = element.getFirstChildWithName(new QName(
+				namespaceValue, Sandesha2Constants.WSRM_COMMON.EXPIRES));
+		if (expiresPart == null)
+			throw new OMException("Passed elemenet does not have a Expires part");
+		String expiresText = expiresPart.getText();
+		if (expiresText == null || expiresText == "")
+			throw new OMException("The duration value is not valid");
+
+		duration = expiresText;
+		return element;
+	}
+
+	public String getNamespaceValue() throws OMException {
+		// TODO Auto-generated method stub
+		return namespaceValue;
+	}
+
+	public OMElement toOMElement(OMElement element) throws OMException {
+
+		if (duration == null || duration == "")
+			throw new OMException("Cant set Expires. The duration value is not set");
+
+		OMFactory factory = element.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement expiresElement = factory.createOMElement(
+				Sandesha2Constants.WSRM_COMMON.EXPIRES, rmNamespace);
+		
+		expiresElement.setText(duration);
+		element.addChild(expiresElement);
+
+		return element;
+	}
+
+	public String getDuration() {
+		return duration;
+	}
+
+	public void setDuration(String duration) {
+		this.duration = duration;
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}
\ No newline at end of file

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/FaultCode.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/FaultCode.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/FaultCode.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/FaultCode.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,113 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class FaultCode implements IOMRMElement {
+
+	private String faultCode = null;
+	
+	private SOAPFactory defaultFactory;
+	
+	private String namespaceValue = null;
+	
+	public FaultCode(SOAPFactory factory, String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.namespaceValue = namespaceValue;
+	}
+
+	public String getNamespaceValue() {
+		return namespaceValue;
+	}
+
+	public Object fromOMElement(OMElement sequenceFault) throws OMException {
+
+		if (sequenceFault == null)
+			throw new OMException("Can't add Fault Code part since the passed element is null");
+
+		OMElement faultCodePart = sequenceFault
+				.getFirstChildWithName(new QName(namespaceValue,
+						Sandesha2Constants.WSRM_COMMON.FAULT_CODE));
+
+		if (faultCodePart == null)
+			throw new OMException("Passed element does not contain a Fauld Code part");
+
+		this.faultCode = faultCodePart.getText();
+
+		return sequenceFault;
+
+	}
+
+	public OMElement toOMElement(OMElement sequenceFault) throws OMException {
+
+		if (sequenceFault == null)
+			throw new OMException(
+					"Can't add Fault Code part since the passed element is null");
+
+		if (faultCode == null || faultCode == "")
+			throw new OMException(
+					"Cant add fault code since the the value is not set correctly.");
+
+		OMFactory factory = sequenceFault.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement faultCodeElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.FAULT_CODE,rmNamespace);
+
+		faultCodeElement.setText(faultCode);
+		sequenceFault.addChild(faultCodeElement);
+
+		return sequenceFault;
+	}
+    
+    public void setFaultCode(String faultCode) {
+        this.faultCode = faultCode;
+    }
+    
+    public String getFaultCode() {
+        return faultCode;
+    }
+
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/IOMRMElement.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/IOMRMElement.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/IOMRMElement.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/IOMRMElement.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * This is the base interface for all RM infoset objects.
+ * 
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+import org.apache.sandesha2.SandeshaException;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+
+public interface IOMRMElement {
+	public String getNamespaceValue();
+	public Object fromOMElement(OMElement element) throws OMException,SandeshaException ;
+	public OMElement toOMElement(OMElement element) throws OMException, SandeshaException ;
+	public boolean isNamespaceSupported (String namespaceName);
+}

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/IOMRMPart.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/IOMRMPart.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/IOMRMPart.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/IOMRMPart.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,34 @@
+/*
+ * 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.sandesha2.SandeshaException;
+import org.apache.axiom.soap.SOAPEnvelope;
+
+/**
+ * This is the base interface for RM infoset objects that are added directly so 
+ * SOAPBody or SOAPHeader (we call them MessageParts).
+ * 
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public interface IOMRMPart extends IOMRMElement {
+	public void toSOAPEnvelope (SOAPEnvelope envelope) throws SandeshaException;
+}

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Identifier.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Identifier.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Identifier.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Identifier.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,117 @@
+/*
+ * 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;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+import javax.xml.namespace.QName;
+
+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;
+
+public class Identifier implements Sandesha2Constants, IOMRMElement {
+
+	private String identifier = null;
+	
+	private OMFactory defaultFactory;
+	
+	private String namespaceValue = null;
+	
+	public Identifier(OMFactory defaultFactory, String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = defaultFactory;
+		this.namespaceValue = namespaceValue;
+	}
+
+	public void setIndentifer(String identifier) {
+		this.identifier = identifier;
+	}
+
+	public String getIdentifier() {
+		return identifier;
+	}
+
+	public String getNamespaceValue() throws OMException {
+		return namespaceValue;
+	}
+
+	public Object fromOMElement(OMElement element) throws OMException {
+		
+		OMFactory factory = element.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMElement identifierPart = element.getFirstChildWithName(new QName(
+				namespaceValue, Sandesha2Constants.WSRM_COMMON.IDENTIFIER));
+		if (identifierPart == null)
+			throw new OMException("The parsed element does not contain an identifier part");
+		
+		String identifierText = identifierPart.getText();
+		if (identifierText == null || identifierText == "")
+			throw new OMException("The identifier value is not valid");
+
+		identifier = identifierText;
+		return this;
+	}
+
+	public OMElement toOMElement(OMElement element) throws OMException {
+
+		if (identifier == null || identifier == "") {
+			throw new OMException("identifier is not set .. ");
+		}
+		
+		OMFactory factory = element.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+			
+		OMNamespace wsrmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement identifierElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.IDENTIFIER, wsrmNamespace);
+
+		identifierElement.setText(identifier);
+		element.addChild(identifierElement);
+
+		return element;
+	}
+
+	public String toString() {
+		return identifier;
+	}
+
+	public int hashCode() {
+		return identifier.hashCode();
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}
\ No newline at end of file

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/LastMessage.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/LastMessage.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/LastMessage.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/LastMessage.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,86 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class LastMessage implements IOMRMElement {
+
+	private SOAPFactory defaultFactory;
+	
+	private String namespaceValue = null;
+	
+	public LastMessage(SOAPFactory factory,String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.namespaceValue = namespaceValue;
+	}
+
+	public String getNamespaceValue () {
+		return namespaceValue;
+	}
+
+	public Object fromOMElement(OMElement element) throws OMException {
+		OMElement lastMessagePart = element.getFirstChildWithName(new QName(
+				namespaceValue, Sandesha2Constants.WSRM_COMMON.LAST_MSG));
+		if (lastMessagePart == null)
+			throw new OMException("The passed element does not contain a Last Message part");
+
+		return this;
+	}
+
+	public OMElement toOMElement(OMElement sequenceElement) throws OMException {
+
+		OMFactory factory = sequenceElement.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement lastMessageElement = factory.createOMElement(
+				Sandesha2Constants.WSRM_COMMON.LAST_MSG, rmNamespace);
+		
+		sequenceElement.addChild(lastMessageElement);
+		return sequenceElement;
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		//TODO is this optional or not required.
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}
\ No newline at end of file

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/MessageNumber.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/MessageNumber.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/MessageNumber.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/MessageNumber.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,99 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class MessageNumber implements IOMRMElement {
+	
+	private long messageNumber;
+	
+	private OMFactory defaultFactory;
+	
+	private String namespaceValue = null;
+	
+	public MessageNumber(OMFactory factory,String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.namespaceValue = namespaceValue;
+	}
+	
+	public long getMessageNumber(){
+		return messageNumber;
+	}
+	public void setMessageNumber(long messageNumber){
+		this.messageNumber = messageNumber;
+	}
+	
+	public Object fromOMElement(OMElement seqenceElement) throws OMException {
+		OMElement msgNumberPart = seqenceElement.getFirstChildWithName( 
+				new QName (namespaceValue,Sandesha2Constants.WSRM_COMMON.MSG_NUMBER));
+		if (msgNumberPart==null)
+			throw new OMException ("The passed sequnce element does not contain a message number part");
+		
+		String msgNoStr = msgNumberPart.getText();
+		messageNumber = Long.parseLong(msgNoStr);
+		return this;
+	}
+	
+	public OMElement toOMElement(OMElement element) throws OMException {
+		if (messageNumber <= 0 ){
+			throw new OMException("Set A Valid Message Number");
+		}
+		
+		OMFactory factory = element.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement messageNoElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.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_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+
+}

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Nack.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Nack.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Nack.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Nack.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,104 @@
+/*
+ * 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.axiom.soap.SOAPFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class Nack implements IOMRMElement {
+	
+	private long nackNumber;
+	
+	private SOAPFactory defaultFactory;
+	
+	private String namespaceValue = null;
+		
+	public Nack(SOAPFactory factory,String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.namespaceValue = namespaceValue;
+	}
+	
+	public String getNamespaceValue() {
+		return namespaceValue;
+	}
+	
+
+	public Object fromOMElement(OMElement nackElement) throws OMException{
+		
+		if (nackElement==null)
+			throw new OMException ("Passed seq ack element does not contain a nack part");
+		
+		try {
+			nackNumber = Long.parseLong(nackElement.getText());
+		}catch (Exception ex ) {
+			throw new OMException ("Nack element does not contain a valid long value");
+		}
+		
+		return this;
+	} 
+	
+	public OMElement toOMElement(OMElement sequenceAckElement) throws OMException {
+		if (sequenceAckElement==null)
+			throw new OMException ("Cant set the nack part since the seq ack element is null");
+		
+		if (nackNumber<=0)
+			throw new OMException ("Cant set the nack part since the nack number does not have a valid value");
+		
+		OMFactory factory = sequenceAckElement.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+		
+		OMNamespace rmNamespace = factory.createOMNamespace(namespaceValue,Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		OMElement nackElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.NACK,rmNamespace);
+		nackElement.setText(Long.toString(nackNumber));
+		sequenceAckElement.addChild(nackElement);
+		
+		return sequenceAckElement;
+	}
+
+	public long getNackNumber() {
+		return nackNumber;
+	}
+
+	public void setNackNumber(long nackNumber) {
+		this.nackNumber = nackNumber;
+	}
+
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+}

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/RMElements.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/RMElements.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/RMElements.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/RMElements.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,347 @@
+/*
+ * 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 java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.util.SOAPAbstractFactory;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class RMElements {
+
+	private Sequence sequence = null;
+	private SequenceAcknowledgement sequenceAcknowledgement = null;
+	private CreateSequence createSequence = null;
+	private CreateSequenceResponse createSequenceResponse = null;
+	private TerminateSequence terminateSequence = null;
+	private TerminateSequenceResponse terminateSequenceResponse = null;
+	private CloseSequence closeSequence = null;
+	private CloseSequenceResponse closeSequenceResponse = null;
+	private AckRequested ackRequested = null;
+	private SOAPFactory factory = null;
+	private String rmNamespaceValue = null;
+	private String addressingNamespaceValue = null;
+	
+	public RMElements () {
+		
+	}
+	
+	public RMElements (String addressingNamespace) {
+		this.addressingNamespaceValue = addressingNamespace;
+	}
+	
+	public void fromSOAPEnvelope(SOAPEnvelope envelope, String action) throws SandeshaException {
+
+		if (envelope == null)
+			throw new OMException("The passed envelope is null");
+
+		SOAPFactory factory;
+
+		//Yep, I know. Could hv done it directly :D (just to make it consistent)
+		if (envelope.getNamespace().getName().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI))
+			factory = SOAPAbstractFactory.getSOAPFactory(Sandesha2Constants.SOAPVersion.v1_1);
+		else
+			factory = SOAPAbstractFactory.getSOAPFactory(Sandesha2Constants.SOAPVersion.v1_2);
+			
+		
+		//finding out the rm version.
+		rmNamespaceValue = getRMNamespaceValue (envelope,action);
+		if (rmNamespaceValue==null) {
+			return;
+		}
+		
+		String addressingNamespaceTmp = getAddressingNamespaceValue (envelope,action);
+		if (addressingNamespaceTmp!=null) {
+			addressingNamespaceValue = addressingNamespaceTmp;
+		}
+		
+		if (addressingNamespaceValue==null) {
+			String message = "Cant find the addressing version";
+			throw new SandeshaException (message);
+//			return;
+		}
+		
+//		if (addressingNamespaceValue==null)
+//			addressingNamespaceValue = AddressingConstants.Final.WSA_NAMESPACE;   //Final is the default version for addressing
+	
+		OMElement sequenceElement = envelope.getHeader().getFirstChildWithName(
+				new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.SEQUENCE));
+		if (sequenceElement != null) {
+			sequence = new Sequence(factory,rmNamespaceValue);
+			sequence.fromOMElement(envelope.getHeader());
+		}
+
+		OMElement sequenceAckElement = envelope.getHeader()
+				.getFirstChildWithName(
+						new QName(rmNamespaceValue,
+								Sandesha2Constants.WSRM_COMMON.SEQUENCE_ACK));
+		if (sequenceAckElement != null) {
+			sequenceAcknowledgement = new SequenceAcknowledgement(factory,rmNamespaceValue);
+			sequenceAcknowledgement.fromOMElement(envelope.getHeader());
+		}
+
+		OMElement createSeqElement = envelope.getBody().getFirstChildWithName(
+				new QName(rmNamespaceValue,
+						Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE));
+		
+		if (createSeqElement != null) {
+			createSequence = new CreateSequence(factory,rmNamespaceValue,addressingNamespaceValue);
+			createSequence.fromOMElement(envelope.getBody());
+		}
+
+		OMElement createSeqResElement = envelope.getBody()
+				.getFirstChildWithName(
+						new QName(rmNamespaceValue,
+								Sandesha2Constants.WSRM_COMMON.CREATE_SEQUENCE_RESPONSE));
+		if (createSeqResElement != null) {
+			createSequenceResponse = new CreateSequenceResponse(factory,rmNamespaceValue,addressingNamespaceValue);
+			createSequenceResponse.fromOMElement(envelope.getBody());
+		}
+
+		OMElement terminateSeqElement = envelope.getBody()
+				.getFirstChildWithName(
+						new QName(rmNamespaceValue,
+								Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE));
+		if (terminateSeqElement != null) {
+			terminateSequence = new TerminateSequence(factory,rmNamespaceValue);
+			terminateSequence.fromOMElement(envelope.getBody());
+		}
+		
+		OMElement terminateSeqResponseElement = envelope.getBody()
+				.getFirstChildWithName(
+						new QName(rmNamespaceValue,
+								Sandesha2Constants.WSRM_COMMON.TERMINATE_SEQUENCE_RESPONSE));
+		if (terminateSeqResponseElement != null) {
+				terminateSequenceResponse = new TerminateSequenceResponse (factory,rmNamespaceValue);
+				terminateSequenceResponse.fromOMElement(envelope.getBody());
+		}
+
+		OMElement ackRequestedElement = envelope.getHeader()
+				.getFirstChildWithName(
+						new QName(rmNamespaceValue,
+								Sandesha2Constants.WSRM_COMMON.ACK_REQUESTED));
+		if (ackRequestedElement != null) {
+			ackRequested = new AckRequested(factory,rmNamespaceValue);
+			ackRequested.fromOMElement(envelope.getHeader());
+		}
+		
+		OMElement closeSequenceElement = envelope.getBody()
+			.getFirstChildWithName(
+				new QName(rmNamespaceValue,
+						Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE));
+		if (closeSequenceElement != null) {
+			closeSequence = new CloseSequence (factory,rmNamespaceValue);
+			closeSequence.fromOMElement(envelope.getBody());
+		}
+
+		OMElement closeSequenceResponseElement = envelope.getBody()
+			.getFirstChildWithName(
+					new QName(rmNamespaceValue,
+							Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE_RESPONSE));
+		if (closeSequenceResponseElement != null) {
+			closeSequenceResponse = new CloseSequenceResponse  (factory,rmNamespaceValue);
+			closeSequenceResponse.fromOMElement(envelope.getBody());
+		}
+	}
+
+	public SOAPEnvelope toSOAPEnvelope(SOAPEnvelope envelope) throws SandeshaException  {
+		if (sequence != null) {
+			sequence.toOMElement(envelope.getHeader());
+		}
+		if (sequenceAcknowledgement != null) {
+			sequenceAcknowledgement.toOMElement(envelope.getHeader());
+		}
+		if (createSequence != null) {
+			createSequence.toOMElement(envelope.getBody());
+		}
+		if (createSequenceResponse != null) {
+			createSequenceResponse.toOMElement(envelope.getBody());
+		}
+		if (terminateSequence != null) {
+			terminateSequence.toOMElement(envelope.getBody());
+		}
+		if (ackRequested != null) {
+			ackRequested.toOMElement(envelope.getBody());
+		}
+		
+		if (terminateSequenceResponse != null) {
+			terminateSequenceResponse.toOMElement(envelope.getBody());
+		}
+		
+		if (closeSequence != null) {
+			closeSequence.toOMElement(envelope.getBody());
+		}
+		
+		if (closeSequenceResponse != null) {
+			closeSequenceResponse.toOMElement(envelope.getBody());
+		}
+		
+		return envelope;
+	}
+
+	public CreateSequence getCreateSequence() {
+		return createSequence;
+	}
+
+	public CreateSequenceResponse getCreateSequenceResponse() {
+		return createSequenceResponse;
+	}
+
+	public Sequence getSequence() {
+		return sequence;
+	}
+
+	public SequenceAcknowledgement getSequenceAcknowledgement() {
+		return sequenceAcknowledgement;
+	}
+
+	public TerminateSequence getTerminateSequence() {
+		return terminateSequence;
+	}
+	
+	public TerminateSequenceResponse getTerminateSequenceResponse() {
+		return terminateSequenceResponse;
+	}
+
+	public void setCreateSequence(CreateSequence createSequence) {
+		this.createSequence = createSequence;
+	}
+
+	public void setCreateSequenceResponse(
+			CreateSequenceResponse createSequenceResponse) {
+		this.createSequenceResponse = createSequenceResponse;
+	}
+
+	public void setSequence(Sequence sequence) {
+		this.sequence = sequence;
+	}
+
+	public void setSequenceAcknowledgement(
+			SequenceAcknowledgement sequenceAcknowledgement) {
+		this.sequenceAcknowledgement = sequenceAcknowledgement;
+	}
+
+	public void setTerminateSequence(TerminateSequence terminateSequence) {
+		this.terminateSequence = terminateSequence;
+	}
+	
+	public void setTerminateSequenceResponse(TerminateSequenceResponse terminateSequenceResponse) {
+		this.terminateSequenceResponse = terminateSequenceResponse;
+	}
+
+	public AckRequested getAckRequested() {
+		return ackRequested;
+	}
+
+	public void setAckRequested(AckRequested ackRequested) {
+		this.ackRequested = ackRequested;
+	}
+	
+	private String getRMNamespaceValue (SOAPEnvelope envelope, String action) {
+		SOAPHeader header = envelope.getHeader();
+		if (header!=null) {
+			ArrayList headers = header.getHeaderBlocksWithNSURI(Sandesha2Constants.SPEC_2005_02.NS_URI);
+			if (headers!=null && headers.size()>0)
+				return Sandesha2Constants.SPEC_2005_02.NS_URI;
+			
+			headers = header.getHeaderBlocksWithNSURI(Sandesha2Constants.SPEC_2005_10.NS_URI);
+			if (headers!=null && headers.size()>0)
+				return Sandesha2Constants.SPEC_2005_10.NS_URI;
+		}
+		
+		//rm control messages with parts in the body will be identified by the wsa:action.
+		if (action==null)
+			return null;
+		
+		if (action.equals(Sandesha2Constants.SPEC_2005_02.Actions.ACTION_CREATE_SEQUENCE))
+			return Sandesha2Constants.SPEC_2005_02.NS_URI;
+		if (action.equals(Sandesha2Constants.SPEC_2005_02.Actions.ACTION_CREATE_SEQUENCE_RESPONSE))
+			return Sandesha2Constants.SPEC_2005_02.NS_URI;
+		if (action.equals(Sandesha2Constants.SPEC_2005_02.Actions.ACTION_SEQUENCE_ACKNOWLEDGEMENT))
+			return Sandesha2Constants.SPEC_2005_02.NS_URI;
+		if (action.equals(Sandesha2Constants.SPEC_2005_02.Actions.ACTION_TERMINATE_SEQUENCE))
+			return Sandesha2Constants.SPEC_2005_02.NS_URI;
+		
+		if (action.equals(Sandesha2Constants.SPEC_2005_10.Actions.ACTION_CREATE_SEQUENCE))
+			return Sandesha2Constants.SPEC_2005_10.NS_URI;
+		if (action.equals(Sandesha2Constants.SPEC_2005_10.Actions.ACTION_CREATE_SEQUENCE_RESPONSE))
+			return Sandesha2Constants.SPEC_2005_10.NS_URI;
+		if (action.equals(Sandesha2Constants.SPEC_2005_10.Actions.ACTION_SEQUENCE_ACKNOWLEDGEMENT))
+			return Sandesha2Constants.SPEC_2005_10.NS_URI;
+		if (action.equals(Sandesha2Constants.SPEC_2005_10.Actions.ACTION_TERMINATE_SEQUENCE))
+			return Sandesha2Constants.SPEC_2005_10.NS_URI;
+		if (action.equals(Sandesha2Constants.SPEC_2005_10.Actions.ACTION_CLOSE_SEQUENCE))
+			return Sandesha2Constants.SPEC_2005_10.NS_URI;
+		if (action.equals(Sandesha2Constants.SPEC_2005_10.Actions.ACTION_TERMINATE_SEQUENCE_RESPONSE))
+			return Sandesha2Constants.SPEC_2005_10.NS_URI;
+		if (action.equals(Sandesha2Constants.SPEC_2005_10.Actions.ACTION_CLOSE_SEQUENCE_RESPONSE))
+			return Sandesha2Constants.SPEC_2005_10.NS_URI;
+		
+		return null;   //a version could not be found
+	}
+	
+	private String getAddressingNamespaceValue (SOAPEnvelope envelope, String action) {
+		SOAPHeader header = envelope.getHeader();
+		if (header!=null) {
+			ArrayList headers = header.getHeaderBlocksWithNSURI(AddressingConstants.Submission.WSA_NAMESPACE);
+			if (headers!=null && headers.size()>0)
+				return AddressingConstants.Submission.WSA_NAMESPACE;
+			
+			headers = header.getHeaderBlocksWithNSURI(AddressingConstants.Final.WSA_NAMESPACE);
+			if (headers!=null && headers.size()>0)
+				return AddressingConstants.Final.WSA_NAMESPACE;
+		}
+		
+		return null;   //a version could not be found
+	}
+
+	public CloseSequence getCloseSequence() {
+		return closeSequence;
+	}
+
+	public void setCloseSequence(CloseSequence closeSequence) {
+		this.closeSequence = closeSequence;
+	}
+
+	public CloseSequenceResponse getCloseSequenceResponse() {
+		return closeSequenceResponse;
+	}
+
+	public void setCloseSequenceResponse(CloseSequenceResponse closeSequenceResponse) {
+		this.closeSequenceResponse = closeSequenceResponse;
+	}
+
+	public String getAddressingNamespaceValue() {
+		return addressingNamespaceValue;
+	}
+}
\ No newline at end of file

Added: webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Sequence.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Sequence.java?rev=414476&view=auto
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Sequence.java (added)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/wsrm/Sequence.java Wed Jun 14 22:51:15 2006
@@ -0,0 +1,171 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+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.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ * @author Sanka Samaranayaka <ss...@gmail.com>
+ * @author Saminda Abeyruwan  <sa...@opensource.lk>
+ */
+
+public class Sequence implements IOMRMPart {
+
+	private Identifier identifier;
+	private MessageNumber messageNumber;
+	private LastMessage lastMessage = null;
+	private SOAPFactory defaultFactory;
+	private boolean mustUnderstand = true;
+	private String namespaceValue = null;
+	
+	public Sequence(SOAPFactory factory,String namespaceValue) throws SandeshaException {
+		if (!isNamespaceSupported(namespaceValue))
+			throw new SandeshaException ("Unsupported namespace");
+		
+		this.defaultFactory = factory;
+		this.namespaceValue = namespaceValue;
+	}
+
+	public String getNamespaceValue() {
+		return namespaceValue;
+	}
+
+	public Object fromOMElement(OMElement headerElement) throws OMException,SandeshaException {
+
+		SOAPHeader header = (SOAPHeader) headerElement;
+		if (header == null)
+			throw new OMException(
+					"Sequence element cannot be added to non-header element");
+
+		OMElement sequencePart = headerElement.getFirstChildWithName(new QName(namespaceValue,
+						Sandesha2Constants.WSRM_COMMON.SEQUENCE));
+		if (sequencePart == null)
+			throw new OMException("Cannot find Sequence element in the given element");
+
+		identifier = new Identifier(defaultFactory,namespaceValue);
+		messageNumber = new MessageNumber(defaultFactory,namespaceValue);
+		identifier.fromOMElement(sequencePart);
+		messageNumber.fromOMElement(sequencePart);
+
+		OMElement lastMessageElement = sequencePart
+				.getFirstChildWithName(new QName(namespaceValue,Sandesha2Constants.WSRM_COMMON.LAST_MSG));
+
+		if (lastMessageElement != null) {
+			lastMessage = new LastMessage(defaultFactory,namespaceValue);
+			lastMessage.fromOMElement(sequencePart);
+		}
+
+		return this;
+	}
+
+	public OMElement toOMElement(OMElement headerElement) throws OMException {
+
+		if (headerElement == null || !(headerElement instanceof SOAPHeader))
+			throw new OMException("Cant add Sequence Part to a non-header element");
+
+		SOAPHeader soapHeader = (SOAPHeader) headerElement;
+
+		if (identifier == null)
+			throw new OMException("Cant add Sequence part since identifier is null");
+		if (messageNumber == null)
+			throw new OMException("Cant add Sequence part since MessageNumber is null");
+
+		OMFactory factory = headerElement.getOMFactory();
+		if (factory==null)
+			factory = defaultFactory;
+
+		OMNamespace rmNamespace = factory.createOMNamespace(
+				namespaceValue, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+		SOAPHeaderBlock sequenceHeaderBlock = soapHeader.addHeaderBlock(
+				Sandesha2Constants.WSRM_COMMON.SEQUENCE, rmNamespace);
+		
+		sequenceHeaderBlock.setMustUnderstand(isMustUnderstand());
+		identifier.toOMElement(sequenceHeaderBlock);
+		messageNumber.toOMElement(sequenceHeaderBlock);
+		if (lastMessage != null)
+			lastMessage.toOMElement(sequenceHeaderBlock);
+
+		return headerElement;
+	}
+
+	public Identifier getIdentifier() {
+		return identifier;
+	}
+
+	public LastMessage getLastMessage() {
+		return lastMessage;
+	}
+
+	public MessageNumber getMessageNumber() {
+		return messageNumber;
+	}
+
+	public void setIdentifier(Identifier identifier) {
+		this.identifier = identifier;
+	}
+
+	public void setLastMessage(LastMessage lastMessage) {
+		this.lastMessage = lastMessage;
+	}
+
+	public void setMessageNumber(MessageNumber messageNumber) {
+		this.messageNumber = messageNumber;
+	}
+
+	public void toSOAPEnvelope(SOAPEnvelope envelope) {
+		SOAPHeader header = envelope.getHeader();
+		
+		//detach if already exist.
+		OMElement elem = header.getFirstChildWithName(new QName(namespaceValue,
+				Sandesha2Constants.WSRM_COMMON.SEQUENCE));
+		if (elem!=null)
+			elem.detach();
+		
+		toOMElement(header);
+	}
+
+	public boolean isMustUnderstand() {
+		return mustUnderstand;
+	}
+
+	public void setMustUnderstand(boolean mustUnderstand) {
+		this.mustUnderstand = mustUnderstand;
+	}
+	
+	public boolean isNamespaceSupported (String namespaceName) {
+		if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+			return true;
+		
+		if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+			return true;
+		
+		return false;
+	}
+
+}
\ No newline at end of file



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