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 2005/09/05 11:56:00 UTC
svn commit: r278707 [1/2] - in
/webservices/sandesha/trunk/src/org/apache/sandesha2: ./ handlers/
msgprocessors/ msgreceivers/ storage/ util/ wsrm/
Author: chamikara
Date: Mon Sep 5 02:54:38 2005
New Revision: 278707
URL: http://svn.apache.org/viewcvs?rev=278707&view=rev
Log:
Re created the RM model elements. Added SOAPAbstract factory to easily switch b/w SOAP versions. SandeshaUtil currently wraps a UUID generator.
Added:
webservices/sandesha/trunk/src/org/apache/sandesha2/SOAPAbstractFactory.java
webservices/sandesha/trunk/src/org/apache/sandesha2/util/
webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Address.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Expires.java
Modified:
webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
webservices/sandesha/trunk/src/org/apache/sandesha2/MsgInitializer.java
webservices/sandesha/trunk/src/org/apache/sandesha2/MsgValidator.java
webservices/sandesha/trunk/src/org/apache/sandesha2/RMHeaders.java
webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java
webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java
webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java
webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java
webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java
webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
webservices/sandesha/trunk/src/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/PermanentStorageMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Accept.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckRequested.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcksTo.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequence.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequenceResponse.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/FaultCode.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/IOMRMElement.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Identifier.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/LastMessage.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/MessageNumber.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Nack.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/RMElements.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Sequence.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/SequenceAcknowledgement.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/SequenceFault.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/SequenceOffer.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/TerminateSequence.java
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java Mon Sep 5 02:54:38 2005
@@ -18,9 +18,11 @@
package org.apache.sandesha2;
/**
- * @author
+ * @author chamikara
+ * @author sanka
*/
+
public interface Constants {
public interface WSRM {
@@ -30,7 +32,7 @@
String NS_URI_CREATE_SEQ_RESPONSE = "http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse";
- String MSG_NUMBER = "MessageaNumber";
+ String MSG_NUMBER = "MessageNumber";
String LAST_MSG = "LastMessage";
@@ -45,6 +47,8 @@
String SEQUENCE_FAULT = "SequenceFault";
String ACKS_TO = "AcksTo";
+
+ String EXPIRES = "Expires";
String CREATE_SEQUENCE = "CreateSequence";
@@ -69,7 +73,12 @@
public interface WSA {
String NS_URI_ANONYMOUS = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous";
- String NS_ADDRESSING = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
+
+ String NS_URI_ADDRESSING = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
+
+ String NS_PREFIX_ADDRESSING = "wsa";
+
+ String ADDRESS = "Address";
}
String RM_HEADERS = "rmHeaders";
@@ -119,7 +128,21 @@
int MESSAGE_PART_CREATE_SEQ_RESPONSE = 5;
int MESSAGE_PART_TERMINATE_SEQ = 6;
+
+ int MESSAGE_PART_ACK_REQUEST = 7;
int MAX_MSG_PART_ID = 6;
+
+ int STORAGE_TYPE_IN_MEMORY = 1;
+
+ int STORAGE_TYPE_PERSISTANCE = 2;
+
+ String SEQ_PROPERTY_RECEIVED_MSG_LIST = "SeqMsgList";
+
+ int SOAP_1_1 = 1;
+
+ int SOAP_1_2 = 2;
+
+ int DEFAULT_SOAP_VERSION = SOAP_1_2;
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/MsgInitializer.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/MsgInitializer.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/MsgInitializer.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/MsgInitializer.java Mon Sep 5 02:54:38 2005
@@ -17,15 +17,20 @@
package org.apache.sandesha2;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
import org.apache.axis2.addressing.om.AddressingHeaders;
import org.apache.axis2.context.MessageContext;
import org.apache.sandesha2.wsrm.RMElements;
/**
- *@ author
+ * @author chamikara
+ * @author sanka
*/
+
public class MsgInitializer {
public static RMMsgContext initializeMessage (MessageContext ctx) {
@@ -40,19 +45,23 @@
RMElements elements = new RMElements ();
elements.fromSOAPEnvelope(msgCtx.getEnvelope());
- String acksTo = elements.getCreateSequence().getAcksTo().getEndPointReference().getAddress();
- boolean acksToPresent = (acksTo!=null)&&(!acksTo.equals(""));
-
- if(acksToPresent){
- System.out.println("AcksTo:" + elements.getCreateSequence().getAcksTo().getEndPointReference().getAddress());
+ if (elements.getCreateSequence()!=null)
rmMsgContext.setMessagePart(Constants.MESSAGE_PART_CREATE_SEQ,elements.getCreateSequence());
- }
- //TODO do similar checks to other parts too.
- rmMsgContext.setMessagePart(Constants.MESSAGE_PART_CREATE_SEQ_RESPONSE,elements.getCreateSequenceResponse());
- rmMsgContext.setMessagePart(Constants.MESSAGE_PART_SEQUENCE ,elements.getSequence());
- rmMsgContext.setMessagePart(Constants.MESSAGE_PART_SEQ_ACKNOWLEDGEMENT,elements.getSequenceAcknowledgement());
- rmMsgContext.setMessagePart(Constants.MESSAGE_PART_TERMINATE_SEQ,elements.getTerminateSequence());
+ if(elements.getCreateSequenceResponse()!=null)
+ rmMsgContext.setMessagePart(Constants.MESSAGE_PART_CREATE_SEQ_RESPONSE,elements.getCreateSequenceResponse());
+
+ if (elements.getSequence()!=null)
+ rmMsgContext.setMessagePart(Constants.MESSAGE_PART_SEQUENCE ,elements.getSequence());
+
+ if (elements.getSequenceAcknowledgement()!=null)
+ rmMsgContext.setMessagePart(Constants.MESSAGE_PART_SEQ_ACKNOWLEDGEMENT,elements.getSequenceAcknowledgement());
+
+ if (elements.getTerminateSequence()!=null)
+ rmMsgContext.setMessagePart(Constants.MESSAGE_PART_TERMINATE_SEQ,elements.getTerminateSequence());
+
+ if (elements.getAckRequested()!=null)
+ rmMsgContext.setMessagePart(Constants.MESSAGE_PART_ACK_REQUEST,elements.getAckRequested());
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/MsgValidator.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/MsgValidator.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/MsgValidator.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/MsgValidator.java Mon Sep 5 02:54:38 2005
@@ -21,8 +21,10 @@
import org.apache.axis2.context.MessageContext;
/**
- * @author
+ * @author chamikara
+ * @author sanka
*/
+
public class MsgValidator {
public static void validateMessage(RMMsgContext rmMsgCtx) throws AxisFault{
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/RMHeaders.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/RMHeaders.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/RMHeaders.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/RMHeaders.java Mon Sep 5 02:54:38 2005
@@ -17,8 +17,10 @@
package org.apache.sandesha2;
/**
- * @author
+ * @author chamikara
+ * @author sanka
*/
+
public class RMHeaders {
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java Mon Sep 5 02:54:38 2005
@@ -33,8 +33,10 @@
import org.apache.sandesha2.wsrm.TerminateSequence;
/**
- * @author
+ * @author chamikara
+ * @author sanka
*/
+
public class RMMsgContext {
private MessageContext msgContext;
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java Mon Sep 5 02:54:38 2005
@@ -25,13 +25,15 @@
import org.apache.axis2.addressing.om.AddressingHeaders;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.impl.MIMEOutputUtils;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.axis2.soap.SOAPFactory;
-import org.apache.axis2.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.sandesha2.util.SandeshaUtil;
import org.apache.sandesha2.wsrm.Accept;
import org.apache.sandesha2.wsrm.AckRequested;
import org.apache.sandesha2.wsrm.AcknowledgementRange;
import org.apache.sandesha2.wsrm.AcksTo;
+import org.apache.sandesha2.wsrm.Address;
import org.apache.sandesha2.wsrm.CreateSequence;
import org.apache.sandesha2.wsrm.CreateSequenceResponse;
import org.apache.sandesha2.wsrm.IOMRMElement;
@@ -39,8 +41,10 @@
import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
/**
- * @author
+ * @author chamikara
+ * @author sanka
*/
+
public class RMMsgCreator {
public static RMMsgContext createCreateSeqResponseMsg (RMMsgContext createSeqMessage, MessageContext outMessage) throws AxisFault {
@@ -52,54 +56,37 @@
CreateSequenceResponse response = new CreateSequenceResponse();
Identifier identifier = new Identifier();
- // TODO : set the an appropriate id
+ String newSequenceID = SandeshaUtil.getUUID();
+ identifier.setIndentifer(newSequenceID);
- identifier.setIndentifer("uuid:temp-id-of-sandesha");
response.setIdentifier(identifier);
+
Accept accept = new Accept();
EndpointReference acksToEPR = createSeqMessage.getTo();
- AcksTo acksTo = new AcksTo(acksToEPR);
+ AcksTo acksTo = new AcksTo();
+ Address address = new Address ();
+ address.setEpr(acksToEPR);
+ acksTo.setAddress(address);
accept.setAcksTo(acksTo);
response.setAccept(accept);
- SOAPEnvelope envolope1 = outMessage.getEnvelope();
-
- /*try {
- XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
- envolope1.serialize(writer);
- }catch (Exception ex){
- ex.printStackTrace();
- }*/
-
- SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
- //envelope.getBody().getFirstChild().detach();
-
- response.toSOAPEnvelope(envelope);
- // EndpointReference fromEPR= createSeqMessage.getTo(); //new EndpointReference("http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous");
- //EndpointReference toEPR = createSeqMessage.getFrom();
- // outMessage.setFrom(fromEPR);
- //outMessage.setTo(toEPR);
- // outMessage.setFaultTo(fromEPR);
+ SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).getDefaultEnvelope();
+ response.toOMElement(envelope.getBody());
outMessage.setWSAAction(Constants.WSRM.NS_URI_CREATE_SEQ_RESPONSE);
- outMessage.setMessageID("uuid:msg-id-of-create-seq-res-msg");
- //outMessage.setF
- /* try {
- XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
- envelope.serialize(writer);
- }catch (Exception ex){
- ex.printStackTrace();
- }*/
+ String newMessageId = SandeshaUtil.getUUID();
+ outMessage.setMessageID(newMessageId);
outMessage.setEnvelope(envelope);
- RMMsgContext createSeqResponse = new RMMsgContext(outMessage);
+ RMMsgContext createSeqResponse = MsgInitializer.initializeMessage(outMessage);
+ MsgValidator.validateMessage(createSeqResponse);
return createSeqResponse;
}
public static void createAckMessage (RMMsgContext applicationMsg) throws AxisFault {
- SOAPEnvelope envelope = applicationMsg.getSOAPEnvelope();
+ /*SOAPEnvelope envelope = applicationMsg.getSOAPEnvelope();
if(envelope==null) {
- SOAPEnvelope newEnvelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+ SOAPEnvelope newEnvelope = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).getDefaultEnvelope();
applicationMsg.setSOAPEnvelop(envelope);
}
@@ -114,8 +101,7 @@
sequenceAck.addAcknowledgementRanges(range);
sequenceAck.toSOAPEnvelope(envelope);
applicationMsg.setAction("http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement");
- applicationMsg.setMessageId("uuid:msg-id-of-first-ack");
-
+ applicationMsg.setMessageId("uuid:msg-id-of-first-ack"); */
}
}
Added: webservices/sandesha/trunk/src/org/apache/sandesha2/SOAPAbstractFactory.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/SOAPAbstractFactory.java?rev=278707&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SOAPAbstractFactory.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SOAPAbstractFactory.java Mon Sep 5 02:54:38 2005
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.soap.SOAPFactory;
+
+/**
+ * @author chamikara
+ * @author sanka
+ */
+
+
+public class SOAPAbstractFactory {
+
+ public static SOAPFactory getSOAPFactory (int SOAPVersion) {
+ if (SOAPVersion==Constants.SOAP_1_1)
+ return OMAbstractFactory.getSOAP11Factory();
+ else if(SOAPVersion==Constants.SOAP_1_2)
+ return OMAbstractFactory.getSOAP12Factory();
+ else
+ return null;
+ }
+}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java Mon Sep 5 02:54:38 2005
@@ -21,6 +21,11 @@
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.modules.Module;
+/**
+ * @author chamikara
+ * @author sanka
+ */
+
public class SandeshaModule implements Module{
// initialize the module
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java Mon Sep 5 02:54:38 2005
@@ -17,6 +17,8 @@
package org.apache.sandesha2.handlers;
+import java.util.ArrayList;
+
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.MessageInformationHeaders;
import org.apache.axis2.context.MessageContext;
@@ -27,6 +29,7 @@
import org.apache.sandesha2.msgprocessors.MsgProcessor;
import org.apache.sandesha2.msgprocessors.MsgProcessorException;
import org.apache.sandesha2.msgprocessors.MsgProcessorFactory;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
/**
* @author
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java Mon Sep 5 02:54:38 2005
@@ -50,8 +50,7 @@
if(requestRMMsgCtx.getMessageType()!=Constants.MESSAGE_TYPE_CREATE_SEQ){
//set acknowledgement
- RMMsgCreator.createAckMessage (rmMsgCtx);
-
+ RMMsgCreator.createAckMessage (rmMsgCtx);
}
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java Mon Sep 5 02:54:38 2005
@@ -6,7 +6,15 @@
*/
package org.apache.sandesha2.msgprocessors;
+import java.util.ArrayList;
+
+import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.MsgInitializer;
+import org.apache.sandesha2.MsgValidator;
import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.wsrm.Sequence;
/**
* @author
@@ -17,9 +25,16 @@
public void processMessage(RMMsgContext rmMsgCtx)
throws MsgProcessorException {
- //rmMsgCtx.
System.out.println ("Application msg processor called");
-
+ //setting ack range
+ Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_SEQUENCE);
+ String sequenceId = sequence.getIdentifier().getIdentifier();
+ SequencePropertyBeanMgr mgr = new SequencePropertyBeanMgr (Constants.STORAGE_TYPE_IN_MEMORY);
+ SequencePropertyBean bean = (SequencePropertyBean) mgr.retrieve( sequenceId,Constants.SEQ_PROPERTY_RECEIVED_MSG_LIST);
+ System.out.println ("get --" + sequenceId + "--" + Constants.SEQ_PROPERTY_RECEIVED_MSG_LIST);
+ int i = 1;
+ ArrayList list = (ArrayList) bean.getValue();
+ System.out.println ("aaa is:" + list.get(0));
}
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java Mon Sep 5 02:54:38 2005
@@ -17,6 +17,11 @@
package org.apache.sandesha2.msgreceivers;
+import java.util.ArrayList;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
@@ -28,8 +33,11 @@
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMFactory;
import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.receivers.AbstractInMessageReceiver;
+import org.apache.axis2.receivers.AbstractInOutAsyncMessageReceiver;
import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
import org.apache.axis2.receivers.AbstractMessageReceiver;
+import org.apache.axis2.receivers.ServerCallback;
import org.apache.axis2.soap.SOAP11Constants;
import org.apache.axis2.soap.SOAP12Constants;
import org.apache.axis2.soap.SOAPEnvelope;
@@ -40,6 +48,12 @@
import org.apache.sandesha2.MsgValidator;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.RMMsgCreator;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.wsrm.CreateSequence;
+import org.apache.sandesha2.wsrm.CreateSequenceResponse;
+
+import com.bea.xml.stream.XMLWriterBase;
/**
* @author
@@ -47,7 +61,8 @@
public class RMMessageReceiver extends AbstractMessageReceiver {
- public void invokeBusinessLogic(MessageContext inMessage,
+
+ public void setCreateSequence(MessageContext inMessage,
MessageContext outMessage) throws AxisFault {
System.out.println("RM Msg Receiver was called");
@@ -58,8 +73,25 @@
RMMsgContext createSeqResponse = RMMsgCreator
.createCreateSeqResponseMsg(rmMsgCtx, outMessage);
+
+ CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse.
+ getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ_RESPONSE);
+
+ String newSequenceId = createSeqResPart.getIdentifier().getIdentifier();
+
+ if (newSequenceId==null)
+ throw new AxisFault ("Internal error - Generated sequence id is null");
+
+
+ //TODO: put below to SequenceManager.setUpNewSequence ();
+ ArrayList arr;
+ SequencePropertyBean seqPropBean = new SequencePropertyBean (newSequenceId,Constants.SEQ_PROPERTY_RECEIVED_MSG_LIST,arr = new ArrayList());
+ SequencePropertyBeanMgr beanMgr = new SequencePropertyBeanMgr (Constants.STORAGE_TYPE_IN_MEMORY);
+ System.out.println ("put --" + newSequenceId + "--" + Constants.SEQ_PROPERTY_RECEIVED_MSG_LIST);
+ beanMgr.create(seqPropBean);
+
+ arr.add("bbb");
- //createSeqResponse.serializeSOAPEnvelop();
outMessage.setResponseWritten(true);
} else {
outMessage.setResponseWritten(true);
@@ -69,55 +101,32 @@
public final void receive(MessageContext messgeCtx) throws AxisFault {
+ System.out.println ("within RM Msg receiver");
RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(messgeCtx);
MsgValidator.validateMessage(rmMsgCtx);
+ AbstractMessageReceiver msgReceiver = null;
if (rmMsgCtx.getMessageType() == Constants.MESSAGE_TYPE_CREATE_SEQ) {
- MessageContext newmsgCtx = new MessageContext(messgeCtx
- .getSystemContext(), messgeCtx.getSessionContext(),
- messgeCtx.getTransportIn(), messgeCtx.getTransportOut());
-
- newmsgCtx
- .setMessageInformationHeaders(new MessageInformationHeaders());
- MessageInformationHeaders oldMessageInfoHeaders = messgeCtx
- .getMessageInformationHeaders();
- MessageInformationHeaders messageInformationHeaders = new MessageInformationHeaders();
- messageInformationHeaders.setTo(oldMessageInfoHeaders.getReplyTo());
- messageInformationHeaders.setFaultTo(oldMessageInfoHeaders
- .getFaultTo());
- messageInformationHeaders.setFrom(oldMessageInfoHeaders.getTo());
- messageInformationHeaders
- .setRelatesTo(new RelatesTo(
- oldMessageInfoHeaders.getMessageId(),
- AddressingConstants.Submission.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE));
- newmsgCtx.setMessageInformationHeaders(messageInformationHeaders);
- newmsgCtx.setOperationContext(messgeCtx.getOperationContext());
- newmsgCtx.setServiceContext(messgeCtx.getServiceContext());
- newmsgCtx.setProperty(MessageContext.TRANSPORT_OUT, messgeCtx
- .getProperty(MessageContext.TRANSPORT_OUT));
- newmsgCtx.setProperty(HTTPConstants.HTTPOutTransportInfo, messgeCtx
- .getProperty(HTTPConstants.HTTPOutTransportInfo));
-
- //Setting the charater set encoding
- newmsgCtx
- .setProperty(
- MessageContext.CHARACTER_SET_ENCODING,
- messgeCtx
- .getProperty(MessageContext.CHARACTER_SET_ENCODING));
-
- newmsgCtx.setDoingREST(messgeCtx.isDoingREST());
- newmsgCtx.setDoingMTOM(messgeCtx.isDoingMTOM());
- newmsgCtx.setServerSide(messgeCtx.isServerSide());
-
- invokeBusinessLogic(messgeCtx, newmsgCtx);
-
- AxisEngine engine = new AxisEngine(messgeCtx.getOperationContext()
- .getServiceContext().getEngineContext());
- engine.send(newmsgCtx);
+
+ CreateSequence createSeqPart = (CreateSequence) rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ);
+ if (createSeqPart==null)
+ throw new AxisFault ("No create sequence part in create sequence message");
+
+ //String acksTo = createSeqPart.getAcksTo().getEndPointReference().toString();
+ String from = messgeCtx.getFrom().getAddress();
+ if(from.equals(Constants.WSA.NS_URI_ANONYMOUS)) {
+ msgReceiver = new RMInOutSyncMsgReceiver ();
+ } else {
+ msgReceiver = new RMInOutAsyncMsgReceiver ();
+ }
+
} else {
//TODO: Check weather terminate
-
- //TODO: Do terminate processing
+ msgReceiver = new RMInMsgReceiver ();
+ }
+
+ if(msgReceiver!=null) {
+ msgReceiver.receive(messgeCtx);
}
}
@@ -133,6 +142,49 @@
"Unknown SOAP Version. Current Axis handles only SOAP 1.1 and SOAP 1.2 messages");
}
return fac;
+ }
+
+ private class RMInMsgReceiver extends AbstractInMessageReceiver {
+
+ public void invokeBusinessLogic(MessageContext inMessage) throws AxisFault {
+ RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(inMessage);
+ MsgValidator.validateMessage(rmMsgCtx);
+
+ //TODO check for terminate sequence.
+ //TODO handle terminate sequence.
+
+
+ }
+ }
+
+ private class RMInOutSyncMsgReceiver extends AbstractInOutSyncMessageReceiver {
+
+ public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
+
+ RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(inMessage);
+ MsgValidator.validateMessage(rmMsgCtx);
+
+ if (rmMsgCtx.getMessageType()==Constants.MESSAGE_TYPE_CREATE_SEQ) {
+ //TODO handle sync create seq.
+ setCreateSequence(inMessage,outMessage);
+ }
+
+ }
+}
+
+ private class RMInOutAsyncMsgReceiver extends AbstractInOutAsyncMessageReceiver {
+
+ public void invokeBusinessLogic(MessageContext inMessage,
+ MessageContext outMessage, ServerCallback callback) throws AxisFault {
+
+ RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(inMessage);
+ MsgValidator.validateMessage(rmMsgCtx);
+
+ if (rmMsgCtx.getMessageType()==Constants.MESSAGE_TYPE_CREATE_SEQ) {
+ //TODO handle async create seq.
+ setCreateSequence(inMessage,outMessage);
+ }
+ }
}
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/storage/PermanentStorageMgr.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/storage/PermanentStorageMgr.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/storage/PermanentStorageMgr.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/storage/PermanentStorageMgr.java Mon Sep 5 02:54:38 2005
@@ -419,98 +419,4 @@
throw new RuntimeException(ex.getMessage());
}
}
-
- public static void main(String[] args) {
- PermanentStorageMgr mgr = PermanentStorageMgr.getInstance();
-// CreateSeqBean bean = new CreateSeqBean();
-// bean.setCreateSeqMsgId("101010");
-// bean.setSequenceId("232323");
-// mgr.createCreateSeq(bean);
-
-// NextMsgBean bean = new NextMsgBean();
-// bean.setSequenceId("10");
-// bean.setNextMsgNoToProcess("20");
-// mgr.createNextMsg(bean);
-//
-// NextMsgBean bean3 = new NextMsgBean();
-// bean3.setSequenceId("10");
-// bean3.setNextMsgNoToProcess("30");
-// mgr.updateNextMsgBean(bean3);
-// NextMsgBean bean2 = mgr.retrieveNextMsgBean("10");
-// System.out.println(bean2.getSequenceId() + " " + bean2.getNextMsgNoToProcess());
-
-// RetransmitterBean bean = new RetransmitterBean();
-// bean.setKey("1010");
-// bean.setCreateSeqMsgId("seqMsgId");
-// bean.setLastSentTime(Long.parseLong("10000"));
-// bean.setMessageId("msgId");
-// bean.setSend(true);
-//
-// mgr.createRetransmitterBean(bean);
- // mgr.deleteRetransmitterBean("1010");
-
-// RetransmitterBean bean3 = new RetransmitterBean();
-// bean3.setCreateSeqMsgId("setMsgIdUpdate");
-// bean3.setKey("1010");
-// bean3.setLastSentTime(Long.parseLong("20000"));
-// bean3.setMessageId("msgIdUpdated");
-// bean.setSend(false);
-// mgr.updateRetransmitterBean(bean3);
-//
-//
-// RetransmitterBean bean2 = mgr.retrieveRetransmitterBean("1010");
-// System.out.println(bean2.getCreateSeqMsgId() + "," + bean2.getKey()
-// + "," + bean2.getLastSentTime() + ","
-// + bean2.getMessageId()+ ",'"
-// + bean2.isSend());
-
-
-
-
-
-// CreateSeqBean bean2 = mgr.retrieveCreateSeq("101010");
-// System.out.println(bean2.getCreateSeqMsgId() + " " + bean2.getSequenceId());
-// System.out.println("done");
-// CreateSeqBean bean2 = new CreateSeqBean();
-// bean2.setCreateSeqMsgId("101010");
-// bean2.setSequenceId("454545");
-// mgr.updateCreateSeq(bean2);
-//
-// mgr.deleteCreateSeq("101010");
-// CreateSeqBean bean3 = mgr.retrieveCreateSeq("101010");
-// System.out.println(bean3.getSequenceId());
-//
-
- //mgr.createCreateSeq()
-
-// StorageMapBean bean = new StorageMapBean();
-// bean.setKey("1010");
-// bean.setMsgNo(Integer.parseInt("1"));
-// bean.setSequenceId("seqId");
-// mgr.createStorageMapBean(bean);
-//
-// StorageMapBean bean2 = new StorageMapBean();
-// bean2.setKey("1010");
-// bean2.setMsgNo(2);
-// bean2.setSequenceId("seqIdUpdated");
-// mgr.updateStorageMapBean(bean2);
-//
-// StorageMapBean retrieveStorageMapBean = mgr.retrieveStorageMapBean("1010");
-// System.out.println(retrieveStorageMapBean.getKey()+ "," + retrieveStorageMapBean.getMsgNo()+ "," + retrieveStorageMapBean.getSequenceId());
-//
- SequencePropertyBean bean = new SequencePropertyBean();
- bean.setName("name");
- bean.setValue("value");
- bean.setSequenceId("10");
- mgr.createSequencePropertyBean(bean);
-
- bean.setName("nameUpdated");
- bean.setValue("valueUpdate");
- mgr.updateSequencePropertyBean(bean);
- //mgr.deleteSequencePropertyBean("10");
-
- SequencePropertyBean retrieveSequencePropertyBean = mgr.retrieveSequencePropertyBean("10");
- System.out.println(retrieveSequencePropertyBean.getSequenceId()+ "," + retrieveSequencePropertyBean.getName() + "," + retrieveSequencePropertyBean.getValue());
-
- }
}
Added: webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java?rev=278707&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java Mon Sep 5 02:54:38 2005
@@ -0,0 +1,32 @@
+/*
+ * 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.util;
+
+import org.apache.axis2.om.impl.MIMEOutputUtils;
+
+/**
+ * @author chamikara
+ * @author sanka
+ */
+
+public class SandeshaUtil {
+
+ public static String getUUID () {
+ String newSequenceID = "uuid:" + MIMEOutputUtils.getRandomStringOf18Characters();
+ return newSequenceID;
+ }
+}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Accept.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Accept.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Accept.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Accept.java Mon Sep 5 02:54:38 2005
@@ -16,6 +16,10 @@
*/
package org.apache.sandesha2.wsrm;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
@@ -23,37 +27,62 @@
import org.apache.axis2.om.OMNamespace;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
/**
* @author Saminda
+ * @author chamikara
+ * @author sanka
*/
+
public class Accept implements IOMRMElement {
private OMElement acceptElement;
private AcksTo acksTo;
- OMNamespace acceptNamespace =
- OMAbstractFactory.getSOAP11Factory().createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+
+ OMNamespace rmNamespace =
+ SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+
public Accept(){
- acceptElement = OMAbstractFactory.getSOAP11Factory().createOMElement(
- Constants.WSRM.ACCEPT,acceptNamespace);
+ acceptElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACCEPT,rmNamespace);
}
- public OMElement getSOAPElement() throws OMException {
- acceptElement.addChild(acksTo.getSOAPElement());
+ public OMElement getOMElement() throws OMException {
return acceptElement;
}
- public Object fromSOAPEnvelope(SOAPEnvelope envelope) throws OMException {
- acksTo = new AcksTo(new EndpointReference(""));
- acksTo.fromSOAPEnvelope(envelope);
+ public Object fromOMElement(OMElement element) throws OMException {
+
+ OMElement acceptPart = element.getFirstChildWithName(
+ new QName (Constants.WSRM.NS_URI_RM,Constants.WSRM.ACCEPT));
+ if (acceptPart==null)
+ throw new OMException ("Passed element does not contain an Accept part");
+
+ acksTo = new AcksTo();
+ acksTo.fromOMElement(acceptPart);
+
+ acceptElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACCEPT,rmNamespace);
+
return this;
}
- public OMElement toSOAPEnvelope(OMElement messageElement) throws OMException {
- if (acksTo != null){
- acksTo.toSOAPEnvelope(acceptElement);
- }
- messageElement.addChild(acceptElement);
- return messageElement;
+ public OMElement toOMElement(OMElement element) throws OMException {
+
+ if (acceptElement==null)
+ throw new OMException ("Cant add Accept part since the internal element is null");
+
+ if (acksTo==null)
+ throw new OMException ("Cant add Accept part since AcksTo object is null");
+
+ acksTo.toOMElement(acceptElement);
+ element.addChild(acceptElement);
+
+ acceptElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACCEPT,rmNamespace);
+
+ return element;
}
+
public void setAcksTo(AcksTo acksTo){
this.acksTo = acksTo;
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckRequested.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckRequested.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckRequested.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckRequested.java Mon Sep 5 02:54:38 2005
@@ -16,6 +16,8 @@
*/
package org.apache.sandesha2.wsrm;
+import javax.xml.namespace.QName;
+
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
@@ -24,64 +26,99 @@
import org.apache.axis2.soap.SOAPHeader;
import org.apache.axis2.soap.SOAPHeaderBlock;
import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
/**
* @author Saminda
- *
+ * @author chamikara
+ * @author sanka
*/
+
public class AckRequested implements IOMRMElement {
private OMElement ackRequestedElement;
private Identifier identifier;
private MessageNumber messageNumber;
- OMNamespace ackReqNoNamespace =
- OMAbstractFactory.getSOAP11Factory().createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+
+ OMNamespace rmNamespace =
+ SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+
public AckRequested(){
- ackRequestedElement = OMAbstractFactory.getSOAP11Factory().createOMElement(
- Constants.WSRM.ACK_REQUESTED,ackReqNoNamespace);
+ ackRequestedElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACK_REQUESTED,rmNamespace);
}
- public OMElement getSOAPElement() throws OMException {
- ackRequestedElement.addChild(identifier.getSOAPElement());
- ackRequestedElement.addChild(messageNumber.getSOAPElement());
+
+ public OMElement getOMElement() throws OMException {
return ackRequestedElement;
}
- public Object fromSOAPEnvelope(SOAPEnvelope envelope) throws OMException {
+ public Object fromOMElement(OMElement header) throws OMException {
+
+ 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 (Constants.WSRM.NS_URI_RM,Constants.WSRM.ACK_REQUESTED));
+
+ if (ackReqPart==null)
+ throw new OMException ("the passed element does not contain an ack requested part");
+
identifier = new Identifier();
- messageNumber = new MessageNumber();
- identifier.fromSOAPEnvelope(envelope);
- messageNumber.fromSOAPEnvelope(envelope);
+ identifier.fromOMElement(ackReqPart);
+
+ OMElement msgNoPart = ackReqPart.getFirstChildWithName
+ (new QName (Constants.WSRM.NS_URI_RM,Constants.WSRM.MSG_NUMBER));
+
+ if (msgNoPart!=null){
+ messageNumber = new MessageNumber();
+ messageNumber.fromOMElement(ackReqPart);
+ }
+
+ ackRequestedElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACK_REQUESTED,rmNamespace);
+
return this;
}
- public OMElement toSOAPEnvelope(OMElement envelope) throws OMException {
- SOAPEnvelope soapEnvelope = (SOAPEnvelope)envelope;
- SOAPHeader soapHeader = soapEnvelope.getHeader();
- SOAPHeaderBlock soapHeaderBlock = soapHeader.addHeaderBlock(
- Constants.WSRM.ACK_REQUESTED,ackReqNoNamespace);
- soapHeaderBlock.setMustUnderstand(true);
- if( identifier != null){
- identifier.toSOAPEnvelope(soapHeaderBlock);
- }
+ 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");
+
+ SOAPHeader SOAPHdr = (SOAPHeader) header;
+ SOAPHeaderBlock ackReqHdrBlock = SOAPHdr.addHeaderBlock(
+ Constants.WSRM.ACK_REQUESTED,rmNamespace);
+ ackReqHdrBlock.setMustUnderstand(true);
+
+ identifier.toOMElement(ackReqHdrBlock);
+
if ( messageNumber != null){
- messageNumber.toSOAPEnvelope(soapHeaderBlock);
+ messageNumber.toOMElement(ackReqHdrBlock);
}
- return envelope;
+ ackRequestedElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACK_REQUESTED,rmNamespace);
+
+ 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 addChildElement(OMElement element){
- ackRequestedElement.addChild(element);
- }
+
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java Mon Sep 5 02:54:38 2005
@@ -18,101 +18,110 @@
import java.util.Iterator;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMAttribute;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.OMFactory;
import org.apache.axis2.om.OMNamespace;
import org.apache.axis2.om.OMNode;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
/**
* @author Saminda
+ * @author chamikara
+ * @author sanka
*/
+
public class AcknowledgementRange implements IOMRMElement {
private OMElement acknowledgementRangeElement;
- private long maxValue;
- private long minValue;
- OMNamespace ackRangeNamespace =
- OMAbstractFactory.getSOAP11Factory().createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+ private long upperValue;
+ private long lowerValue;
+
+ OMNamespace rmNamespace =
+ SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+
public AcknowledgementRange(){
- acknowledgementRangeElement = OMAbstractFactory.getSOAP11Factory().createOMElement(
- Constants.WSRM.ACK_RANGE,ackRangeNamespace);
+ acknowledgementRangeElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACK_RANGE,rmNamespace);
}
- public OMElement getSOAPElement() throws OMException {
- acknowledgementRangeElement.addAttribute(Constants.WSRM.LOWER,
- new Long(minValue).toString(),ackRangeNamespace);
- acknowledgementRangeElement.addAttribute(Constants.WSRM.UPPER,
- new Long(maxValue).toString(),ackRangeNamespace);
+
+ public OMElement getOMElement() throws OMException {
return acknowledgementRangeElement;
}
+
+ public Object fromOMElement(OMElement ackRangePart) throws OMException{
+
+ /*OMElement ackRangePart = sequenceAckElement.getFirstChildWithName(
+ new QName (Constants.WSRM.NS_URI_RM,Constants.WSRM.ACK_RANGE)); */
+
+ if (ackRangePart==null)
+ throw new OMException ("The passed element is null");
- private boolean readACKRangeElement(OMElement element){
- Iterator iterator = element.getChildren();
- while(iterator.hasNext()){
- OMNode omNode = (OMNode)iterator.next();
- if(omNode.getType() != OMNode.ELEMENT_NODE){
- continue;
- }
- OMElement childElement = (OMElement)omNode;
- if(childElement.getLocalName().equals(Constants.WSRM.ACK_RANGE)){
- Iterator ite = childElement.getAttributes();
- while(ite.hasNext()){
- OMAttribute attr = (OMAttribute)ite.next();
- if (attr.getLocalName().equals(Constants.WSRM.LOWER)){
- minValue = Long.parseLong(attr.getValue());
- }
- else{
- maxValue = Long.parseLong(attr.getValue());
- return true;
- }
- }
- }else{
- readACKRangeElement(childElement);
- }
- }
- return false;
- }
- //this fromSOAPEnvelope(OMElement element) for the purpose of making the coming iteration easier
- public Object fromSOAPEnvelope(OMElement element) throws OMException{
- Iterator iterator = element.getAttributes();
- while(iterator.hasNext()){
- OMAttribute attr = (OMAttribute)iterator.next();
- if (attr.getLocalName().equals(Constants.WSRM.LOWER)){
- minValue = Long.parseLong(attr.getValue());
- }
- else{
- maxValue = Long.parseLong(attr.getValue());
- }
+ OMAttribute lowerAttrib = ackRangePart.getAttribute(new QName (Constants.WSRM.LOWER));
+ OMAttribute upperAttrib = ackRangePart.getAttribute(new QName (Constants.WSRM.UPPER));
+
+ if (lowerAttrib==null || upperAttrib==null)
+ throw new OMException ("Passed element does not contain upper or lower attributes");
+
+ try{
+ long lower = Long.parseLong(lowerAttrib.getValue());
+ long upper = Long.parseLong(upperAttrib.getValue());
+ upperValue = upper;
+ lowerValue = lower;
+ }catch (Exception ex) {
+ throw new OMException ("The ack range does not have proper long values for Upper and Lower attributes");
}
+
+ acknowledgementRangeElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACK_RANGE,rmNamespace);
+
return this;
}
-
- public Object fromSOAPEnvelope(SOAPEnvelope envelope) throws OMException {
- readACKRangeElement(envelope);
- return this;
- }
- public OMElement toSOAPEnvelope(OMElement messageElement) throws OMException {
- acknowledgementRangeElement.addAttribute(Constants.WSRM.LOWER,
- new Long(minValue).toString(),ackRangeNamespace);
- acknowledgementRangeElement.addAttribute(Constants.WSRM.UPPER,
- new Long(maxValue).toString(),ackRangeNamespace);
- messageElement.addChild(acknowledgementRangeElement);
- return messageElement;
- }
- public void setMinValue(long minValue){
- this.minValue = minValue;
+ 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");
+
+ OMAttribute lowerAttrib = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMAttribute(
+ Constants.WSRM.LOWER,rmNamespace,Long.toString(lowerValue));
+ OMAttribute upperAttrib = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMAttribute(
+ Constants.WSRM.UPPER,rmNamespace,Long.toString(upperValue));
+
+ acknowledgementRangeElement.addAttribute(lowerAttrib);
+ acknowledgementRangeElement.addAttribute(upperAttrib);
+
+ sequenceAckElement.addChild(acknowledgementRangeElement);
+
+ acknowledgementRangeElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACK_RANGE,rmNamespace);
+
+ return sequenceAckElement;
}
- public void setMaxValue(long maxValue){
- this.maxValue = maxValue;
+
+ public long getLowerValue() {
+ return lowerValue;
}
- public long getMinValue(){
- return minValue;
+
+ public void setLowerValue(long lowerValue) {
+ this.lowerValue = lowerValue;
}
- public long getMaxValue(){
- return maxValue;
+
+ public long getUpperValue() {
+ return upperValue;
}
+ public void setUpperValue(long upperValue) {
+ this.upperValue = upperValue;
+ }
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcksTo.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcksTo.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcksTo.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcksTo.java Mon Sep 5 02:54:38 2005
@@ -19,6 +19,8 @@
import java.util.Iterator;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
@@ -29,74 +31,75 @@
import org.apache.axis2.om.OMNode;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
+
/**
* @author Saminda
- *
+ * @author chamikara
+ * @author sanka
*/
+
public class AcksTo implements IOMRMElement{
- private EndpointReference EPR;
+
+ private Address address;
private OMElement acksToElement;
//private OMElement addressElement;
- OMNamespace acksToNameSpace =
- OMAbstractFactory.getSOAP11Factory().createOMNamespace(
+ OMNamespace rmNamespace =
+ SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(
Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
- public AcksTo(EndpointReference EPR){
- acksToElement = OMAbstractFactory.getSOAP11Factory().createOMElement(
- Constants.WSRM.ACKS_TO,acksToNameSpace);
- //addressElement = acksToElement;
-
- this.EPR = EPR;
- }
- public OMElement getSOAPElement() throws OMException {
- OMElement addressElement = OMAbstractFactory.getSOAP11Factory().createOMElement(AddressingConstants.EPR_ADDRESS,
- Constants.WSA.NS_ADDRESSING,AddressingConstants.WSA_DEFAULT_PRFIX);
- addressElement.addChild(OMAbstractFactory.getSOAP11Factory()
- .createText(EPR.getAddress()));
- acksToElement.addChild(addressElement);
+
+ public AcksTo(){
+ acksToElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACKS_TO,rmNamespace);
+ }
+
+ public OMElement getOMElement() throws OMException {
return acksToElement;
}
+
+ public Object fromOMElement(OMElement element) throws OMException {
+ OMElement acksToPart = element.getFirstChildWithName( new QName (
+ Constants.WSRM.NS_URI_RM,Constants.WSRM.ACKS_TO));
+
- public boolean readEPRElement(OMElement element){
- Iterator iterator = element.getChildren();
- while(iterator.hasNext()){
- OMNode omNode = (OMNode)iterator.next();
- if(omNode.getType() != OMNode.ELEMENT_NODE){
- continue;
- }else{
- OMElement omElement = (OMElement)omNode;
- if (omElement.getLocalName().equals(Constants.WSRM.ACKS_TO)){
- OMElement addressElement = omElement.getFirstChildWithName(
- new QName(AddressingConstants.EPR_ADDRESS));
- String uri = addressElement.getText();
- EPR = new EndpointReference(uri);
- return true;
- }else{
- readEPRElement(omElement);
- }
- }
- }
- return false;
- }
- public Object fromSOAPEnvelope(SOAPEnvelope envelope) throws OMException {
- readEPRElement(envelope);
+
+ if (acksToPart==null)
+ throw new OMException ("Passed element does not contain an acksTo part");
+
+ address = new Address ();
+ address.fromOMElement(acksToPart);
+
+ acksToElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACKS_TO,rmNamespace);
+
return this;
}
- public OMElement toSOAPEnvelope(OMElement messageElement) throws OMException {
- OMElement addressElement = OMAbstractFactory.getSOAP11Factory().createOMElement(AddressingConstants.EPR_ADDRESS,
- Constants.WSA.NS_ADDRESSING,AddressingConstants.WSA_DEFAULT_PRFIX);
- addressElement.addChild(OMAbstractFactory.getSOAP11Factory().createText(
- EPR.getAddress()));
- acksToElement.addChild(addressElement);
+
+ public OMElement toOMElement(OMElement element) throws OMException {
+
+ if (acksToElement==null)
+ throw new OMException ("Cant set AcksTo. AcksTo element is null");
+ if (address==null)
+ throw new OMException ("Cant set AcksTo. Address is null");
+
+ OMElement acksToPart = element.getFirstChildWithName(
+ new QName (Constants.WSA.NS_URI_ADDRESSING,Constants.WSRM.ACKS_TO));
- messageElement.addChild(acksToElement);
- return messageElement;
+ address.toOMElement(acksToElement);
+ element.addChild(acksToElement);
+
+ acksToElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.ACKS_TO,rmNamespace);
+
+ return element;
}
- public EndpointReference getEndPointReference(){
- return EPR;
+
+ public Address getAddress() {
+ return address;
}
- public void setEndPointReference(EndpointReference EPR){
- this.EPR = EPR;
+
+ public void setAddress(Address address) {
+ this.address = address;
}
-
}
Added: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Address.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Address.java?rev=278707&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Address.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Address.java Mon Sep 5 02:54:38 2005
@@ -0,0 +1,87 @@
+/*
+ * 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 javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
+
+/**
+ * @author Saminda
+ * @author chamikara
+ * @author sanka
+ */
+
+public class Address implements IOMRMElement {
+
+ EndpointReference epr = null;
+ OMElement addressElement;
+
+ OMNamespace rmNamespace =
+ SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(
+ Constants.WSA.NS_URI_ADDRESSING, Constants.WSA.NS_PREFIX_ADDRESSING);
+
+ public Address (){
+ addressElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSA.ADDRESS,rmNamespace);
+ }
+
+ public Object fromOMElement(OMElement element) throws OMException {
+
+ OMElement addressPart = element.getFirstChildWithName( new QName (
+ Constants.WSA.NS_URI_ADDRESSING,Constants.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");
+
+ addressElement = addressPart;
+ epr = new EndpointReference (addressText);
+ addressElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSA.ADDRESS,rmNamespace);
+ return this;
+
+ }
+
+ public OMElement getOMElement() throws OMException {
+ return addressElement;
+ }
+
+ public OMElement toOMElement(OMElement element) throws OMException {
+ if (addressElement==null)
+ throw new OMException ("Cant set Address. The address element is null");
+
+ if (epr==null || epr.getAddress()==null || epr.getAddress()=="")
+ throw new OMException ("cant set the address. The address value is not valid");
+
+ addressElement.setText(epr.getAddress());
+ element.addChild(addressElement);
+
+
+ addressElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSA.ADDRESS,rmNamespace);
+
+ return element;
+ }
+
+ public EndpointReference getEpr() {
+ return epr;
+ }
+
+ public void setEpr(EndpointReference epr) {
+ this.epr = epr;
+ }
+}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequence.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequence.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequence.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequence.java Mon Sep 5 02:54:38 2005
@@ -16,6 +16,10 @@
*/
package org.apache.sandesha2.wsrm;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
@@ -24,48 +28,91 @@
import org.apache.axis2.soap.SOAPBody;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
/**
* @author Saminda
- *
+ * @author chamikara
+ * @author sanka
*/
+
+
public class CreateSequence implements IOMRMElement {
private OMElement createSequenceElement;
- private AcksTo acksTo;
- private SequenceOffer sequenceOffer;
- OMNamespace createSeqNoNamespace =
- OMAbstractFactory.getSOAP11Factory().createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+ private AcksTo acksTo=null;
+ private Expires expires=null;
+ private SequenceOffer sequenceOffer=null;
+ //private SequritytokenReference;
+
+ OMNamespace rmNamespace =
+ SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+
public CreateSequence(){
- createSequenceElement = OMAbstractFactory.getSOAP11Factory().createOMElement(Constants.WSRM.CREATE_SEQUENCE,
- createSeqNoNamespace);
+ createSequenceElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.CREATE_SEQUENCE,rmNamespace);
}
- public OMElement getSOAPElement() throws OMException {
- createSequenceElement.addChild(sequenceOffer.getSOAPElement());
- createSequenceElement.addChild(acksTo.getSOAPElement());
+
+ public OMElement getOMElement() throws OMException {
return createSequenceElement;
}
- public Object fromSOAPEnvelope(SOAPEnvelope envelope) throws OMException {
- sequenceOffer = new SequenceOffer();
- acksTo = new AcksTo(new EndpointReference(""));
- sequenceOffer.fromSOAPEnvelope(envelope);
- acksTo.fromSOAPEnvelope(envelope);
+ public Object fromOMElement(OMElement bodyElement) throws OMException {
+
+ OMElement createSequencePart = bodyElement.getFirstChildWithName(
+ new QName (Constants.WSRM.NS_URI_RM,Constants.WSRM.CREATE_SEQUENCE));
+ if (createSequencePart==null)
+ throw new OMException ("Create sequence is not present in the passed element");
+
+ createSequenceElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(Constants.WSRM.CREATE_SEQUENCE,
+ rmNamespace);
+
+ acksTo = new AcksTo();
+ acksTo.fromOMElement (createSequencePart);
+
+ OMElement offerPart = createSequencePart.getFirstChildWithName (
+ new QName (Constants.WSRM.NS_URI_RM,Constants.WSRM.SEQUENCE_OFFER));
+ if (offerPart!=null) {
+ sequenceOffer = new SequenceOffer();
+ sequenceOffer.fromOMElement(createSequencePart);
+ }
+
+ OMElement expiresPart = createSequenceElement.getFirstChildWithName (
+ new QName (Constants.WSRM.NS_URI_RM,Constants.WSRM.EXPIRES));
+ if (expiresPart!=null) {
+ expires = new Expires ();
+ expires.fromOMElement(createSequencePart);
+ }
+
return this;
}
- public OMElement toSOAPEnvelope(OMElement envelope) throws OMException {
- SOAPEnvelope soapEnvelope = (SOAPEnvelope)envelope;
- SOAPBody soapBody = soapEnvelope.getBody();
- soapBody.addChild(createSequenceElement);
+ 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;
+ acksTo.toOMElement(createSequenceElement);
+
if(sequenceOffer != null){
- sequenceOffer.toSOAPEnvelope(createSequenceElement);
+ sequenceOffer.toOMElement(createSequenceElement);
}
- if (acksTo != null){
- acksTo.toSOAPEnvelope(createSequenceElement);
+
+ if(expires!=null) {
+ expires.toOMElement(createSequenceElement);
}
- return envelope;
+
+ soapBody.addChild(createSequenceElement);
+
+ createSequenceElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.CREATE_SEQUENCE,rmNamespace);
+ return soapBody;
}
+
public void setAcksTo(AcksTo acksTo){
this.acksTo = acksTo;
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequenceResponse.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequenceResponse.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequenceResponse.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequenceResponse.java Mon Sep 5 02:54:38 2005
@@ -16,6 +16,8 @@
*/
package org.apache.sandesha2.wsrm;
+import javax.xml.namespace.QName;
+
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
@@ -23,48 +25,98 @@
import org.apache.axis2.soap.SOAPBody;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
/**
* @author Saminda
- *
+ * @author chamikara
+ * @author sanka
*/
+
public class CreateSequenceResponse implements IOMRMElement {
private OMElement createSequenceResponseElement;
private Identifier identifier;
private Accept accept;
+ private Expires expires;
+
OMNamespace createSeqResNoNamespace =
- OMAbstractFactory.getSOAP11Factory().createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+ SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+
public CreateSequenceResponse(){
- createSequenceResponseElement = OMAbstractFactory.getSOAP11Factory().createOMElement(
+ createSequenceResponseElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
Constants.WSRM.CREATE_SEQUENCE_RESPONSE,createSeqResNoNamespace);
}
- public OMElement getSOAPElement() throws OMException {
+
+ public OMElement getOMElement() throws OMException {
return createSequenceResponseElement;
}
- public Object fromSOAPEnvelope(SOAPEnvelope envelope) throws OMException {
+ public Object fromOMElement(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;
+
+ OMElement createSeqResponsePart = SOAPBody.getFirstChildWithName(
+ new QName (Constants.WSRM.NS_URI_RM, Constants.WSRM.CREATE_SEQUENCE_RESPONSE));
+ if(createSeqResponsePart==null)
+ throw new OMException ("The passed element does not contain a create seqence response part");
+
+ createSequenceResponseElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.CREATE_SEQUENCE_RESPONSE,createSeqResNoNamespace);
+
identifier = new Identifier();
- accept = new Accept();
- identifier.fromSOAPEnvelope(envelope);
- accept.fromSOAPEnvelope(envelope);
+ identifier.fromOMElement(createSeqResponsePart);
+
+ OMElement expiresPart = createSeqResponsePart.getFirstChildWithName(
+ new QName (Constants.WSRM.NS_URI_RM, Constants.WSRM.EXPIRES));
+ if (expiresPart!=null) {
+ expires = new Expires ();
+ expires.fromOMElement(createSeqResponsePart);
+ }
+
+ OMElement acceptPart = createSeqResponsePart.getFirstChildWithName(
+ new QName (Constants.WSRM.NS_URI_RM, Constants.WSRM.ACCEPT));
+ if (acceptPart!=null) {
+ accept = new Accept ();
+ accept.fromOMElement(createSeqResponsePart);
+ }
+
return this;
}
- public OMElement toSOAPEnvelope(OMElement envelope) throws OMException {
- SOAPEnvelope soapEnvelope = (SOAPEnvelope)envelope;
- SOAPBody soapBody = soapEnvelope.getBody();
- soapBody.addChild(createSequenceResponseElement);
- if( identifier != null ){
- identifier.toSOAPEnvelope(createSequenceResponseElement);
+ 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 (createSequenceResponseElement==null)
+ throw new OMException ("cant set create sequnce response since the internal element is not set");
+ if (identifier==null)
+ throw new OMException ("cant set create sequnce response since the Identifier is not set");
+
+ identifier.toOMElement(createSequenceResponseElement);
+
+ if (expires != null) {
+ expires.toOMElement(createSequenceResponseElement);
}
+
if( accept != null){
- accept.toSOAPEnvelope(createSequenceResponseElement);
+ accept.toOMElement(createSequenceResponseElement);
}
- return envelope;
- }
- public void addChildElement(OMElement element){
- createSequenceResponseElement.addChild(element);
+
+ SOAPBody.addChild(createSequenceResponseElement);
+
+ createSequenceResponseElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.CREATE_SEQUENCE_RESPONSE,createSeqResNoNamespace);
+
+ return SOAPBody;
}
+
public void setIdentifier(Identifier identifier){
this.identifier = identifier;
}
@@ -78,5 +130,12 @@
public Accept getAccept(){
return accept;
}
+
+ public Expires getExpires() {
+ return expires;
+ }
+ public void setExpires(Expires expires) {
+ this.expires = expires;
+ }
}
Added: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Expires.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Expires.java?rev=278707&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Expires.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Expires.java Mon Sep 5 02:54:38 2005
@@ -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.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
+
+/**
+ * @author Saminda
+ * @author chamikara
+ * @author sanka
+ */
+
+public class Expires implements IOMRMElement {
+
+ OMNamespace rmNamespace = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(
+ Constants.WSRM.NS_URI_RM,Constants.WSRM.NS_PREFIX_RM);
+
+ OMElement expiresElement=null;
+ String duration=null;
+
+ public Expires () {
+ expiresElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.EXPIRES , rmNamespace);
+ }
+
+ public Object fromOMElement(OMElement element) throws OMException {
+ OMElement expiresPart = element.getFirstChildWithName(new QName (
+ Constants.WSRM.NS_URI_RM,Constants.WSRM.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");
+
+ expiresElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.EXPIRES , rmNamespace);
+
+ duration = expiresText;
+ return element;
+ }
+
+ public OMElement getOMElement() throws OMException {
+ // TODO Auto-generated method stub
+ return expiresElement;
+ }
+
+ public OMElement toOMElement(OMElement element) throws OMException {
+ if (expiresElement==null)
+ throw new OMException ("Cant set Expires. It is null");
+ if (duration==null || duration=="")
+ throw new OMException ("Cant set Expires. The duration value is not set");
+
+ expiresElement.setText(duration);
+ element.addChild(expiresElement);
+
+ expiresElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.EXPIRES , rmNamespace);
+
+ return element;
+ }
+
+ public String getDuration() {
+ return duration;
+ }
+
+ public void setDuration(String duration) {
+ this.duration = duration;
+ }
+
+ public OMElement getExpiresElement() {
+ return expiresElement;
+ }
+
+ public void setExpiresElement(OMElement expiresElement) {
+ this.expiresElement = expiresElement;
+ }
+}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/FaultCode.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/FaultCode.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/FaultCode.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/FaultCode.java Mon Sep 5 02:54:38 2005
@@ -16,43 +16,77 @@
*/
package org.apache.sandesha2.wsrm;
+import javax.xml.namespace.QName;
+
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
import org.apache.axis2.om.OMNamespace;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
/**
* @author Saminda
- *
+ * @author chamikara
+ * @author sanka
*/
+
public class FaultCode implements IOMRMElement {
private OMElement faultCodeElement;
- OMNamespace faultCodeNameSpace =
- OMAbstractFactory.getSOAP11Factory().createOMNamespace(
+ String faultCode = null;
+
+ OMNamespace rmNameSpace =
+ SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(
Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+
+
public FaultCode(){
- faultCodeElement = OMAbstractFactory.getSOAP11Factory().createOMElement(
- Constants.WSRM.FAULT_CODE,faultCodeNameSpace);
+ faultCodeElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.FAULT_CODE,rmNameSpace);
}
- public OMElement getSOAPElement() throws OMException {
+
+ public OMElement getOMElement() throws OMException {
return faultCodeElement;
}
- public Object fromSOAPEnvelope(SOAPEnvelope envelope) throws OMException {
- return this;
+ 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 (Constants.WSRM.NS_PREFIX_RM,Constants.WSRM.FAULT_CODE));
+
+ if (faultCodePart==null)
+ throw new OMException ("Passed element does not contain a Fauld Code part");
+
+ this.faultCode = faultCodePart.getText();
+
+ faultCodeElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.FAULT_CODE,rmNameSpace);
+
+ return sequenceFault;
+
}
- public OMElement toSOAPEnvelope(OMElement messageElement) throws OMException {
- messageElement.addChild(faultCodeElement);
- return messageElement;
- }
- public void setFaultCode(OMElement faultCode){
- faultCodeElement = faultCode;
- }
- public OMElement getFaultCode(){
- return faultCodeElement;
+ 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.");
+
+ if (faultCodeElement==null)
+ throw new OMException ("Cant add the fault code since the internal element is null");
+
+ faultCodeElement.setText(faultCode);
+ sequenceFault.addChild(faultCodeElement);
+
+ return sequenceFault;
}
+
+
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/IOMRMElement.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/IOMRMElement.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/IOMRMElement.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/IOMRMElement.java Mon Sep 5 02:54:38 2005
@@ -18,15 +18,17 @@
/**
* @author Saminda
- *
+ * @author chamikara
+ * @author sanka
*/
+
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
import org.apache.axis2.soap.SOAPEnvelope;
public interface IOMRMElement {
- public OMElement getSOAPElement() throws OMException;
- public Object fromSOAPEnvelope(SOAPEnvelope envelope) throws OMException;
- public OMElement toSOAPEnvelope(OMElement messageElement) throws OMException;
+ public OMElement getOMElement() throws OMException;
+ public Object fromOMElement(OMElement element) throws OMException;
+ public OMElement toOMElement(OMElement element) throws OMException;
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Identifier.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Identifier.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Identifier.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Identifier.java Mon Sep 5 02:54:38 2005
@@ -18,10 +18,14 @@
/**
* @author Saminda
- *
+ * @author chamikara
+ * @author sanka
*/
+
import java.util.Iterator;
+import javax.xml.namespace.QName;
+
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
@@ -29,18 +33,18 @@
import org.apache.axis2.om.OMNode;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
public class Identifier implements Constants, IOMRMElement {
+
private OMElement identifierElement;
+ private String identifier=null;
- private String identifier;
-
- OMNamespace wsuNamespace = OMAbstractFactory.getSOAP11Factory().createOMNamespace(
+ OMNamespace wsuNamespace = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(
Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
public Identifier() {
-
- identifierElement = OMAbstractFactory.getSOAP11Factory().createOMElement(
+ identifierElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
Constants.WSRM.IDENTIFIER, wsuNamespace);
}
@@ -52,63 +56,44 @@
return identifier;
}
- public OMElement getSOAPElement() throws OMException {
- identifierElement.addChild(OMAbstractFactory.getSOAP11Factory().createText(
- identifier));
+ public OMElement getOMElement () throws OMException {
return identifierElement;
}
- private boolean readElement(OMElement element) {
- Iterator iterator = element.getChildren();
- while (iterator.hasNext()) {
- OMNode omnode = (OMNode)iterator.next();
- if(omnode.getType() != OMNode.ELEMENT_NODE){
- continue ;
- }
- OMElement childElement = (OMElement)omnode ;
- if (childElement.getLocalName().equals(Constants.WSRM.IDENTIFIER)) {
- identifier = childElement.getText();
- return true;
- }else {
- readElement(childElement);
- }
- }
- return false;
- }
-
- public Object fromSOAPEnvelope(SOAPEnvelope envelope) throws OMException {
- readElement(envelope);
+ public Object fromOMElement(OMElement element) throws OMException {
+ OMElement identifierPart = element.getFirstChildWithName(
+ new QName (Constants.WSRM.NS_URI_RM,Constants.WSRM.IDENTIFIER));
+ if (identifierPart==null)
+ throw new OMException ("The parsed element does not contain an identifier part");
+ identifierElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.IDENTIFIER, wsuNamespace);
+
+ String identifierText = identifierPart.getText();
+ if (identifierText==null || identifierText=="")
+ throw new OMException ("The identifier value is not valid");
+
+ identifier = identifierText;
return this;
}
- public OMElement toSOAPEnvelope(OMElement messageElement)
+ public OMElement toOMElement(OMElement element)
throws OMException {
- //soapheaderblock will be given or anyother block reference to the requirment
+
if (identifier == null || identifier == "") {
throw new OMException("identifier is not set .. ");
}
- identifierElement.addChild(OMAbstractFactory.getSOAP11Factory().createText(
- identifier));
- messageElement.addChild(identifierElement);
- return messageElement;
+
+ identifierElement.setText(identifier);
+ element.addChild(identifierElement);
+
+ identifierElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.IDENTIFIER, wsuNamespace);
+
+ return element;
}
public String toString() {
return identifier;
- }
-
- public boolean equals(Object obj) {
-
- if (obj instanceof Identifier) {
- if (this.identifier == ((String) (((Identifier) obj)
- .getIdentifier()))) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
}
public int hashCode() {
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/LastMessage.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/LastMessage.java?rev=278707&r1=278706&r2=278707&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/LastMessage.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/LastMessage.java Mon Sep 5 02:54:38 2005
@@ -18,6 +18,8 @@
import java.util.Iterator;
+import javax.xml.namespace.QName;
+
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
@@ -25,60 +27,64 @@
import org.apache.axis2.om.OMNode;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.SOAPAbstractFactory;
/**
* @author Saminda
- *
+ * @author chamikara
+ * @author sanka
*/
+
public class LastMessage implements IOMRMElement {
private OMElement lastMessageElement;
OMNamespace lastMsgNamespace =
- OMAbstractFactory.getSOAP11Factory().createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+ SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMNamespace(Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+
public LastMessage(){
- lastMessageElement = OMAbstractFactory.getSOAP11Factory().createOMElement(Constants.WSRM.LAST_MSG,lastMsgNamespace);
+ lastMessageElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.LAST_MSG,lastMsgNamespace);
}
- public OMElement getSOAPElement() throws OMException {
+
+ public OMElement getOMElement() throws OMException {
return lastMessageElement;
}
-
- private boolean readMNElement(OMElement element){
- Iterator iterator = element.getChildren();
- while(iterator.hasNext()){
- OMNode omNode = (OMNode)iterator.next();
- if( omNode.getType() != OMNode.ELEMENT_NODE){
- continue;
- }
- OMElement childElement = (OMElement)omNode;
- if (childElement.getLocalName().equals(Constants.WSRM.LAST_MSG)){
- lastMessageElement = childElement;
- return true;
- }else{
- readMNElement(childElement);
- }
- }
- return false;
- }
- public Object fromSOAPEnvelope(SOAPEnvelope envelope) throws OMException {
- readMNElement(envelope);
+
+ public Object fromOMElement(OMElement element) throws OMException {
+ OMElement lastMessagePart = element.getFirstChildWithName(
+ new QName (Constants.WSRM.NS_URI_RM,Constants.WSRM.LAST_MSG));
+ if (lastMessagePart==null)
+ throw new OMException ("The passed element does not contain a Last Message part");
+
+ lastMessageElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.LAST_MSG,lastMsgNamespace);
+
return this;
}
- public OMElement toSOAPEnvelope(OMElement messageElement) throws OMException {
+ public OMElement toOMElement(OMElement sequenceElement) throws OMException {
//soapheaderblock element will be given
- messageElement.addChild(lastMessageElement);
- return messageElement;
+ if(lastMessageElement==null)
+ throw new OMException ("Cant set last message element. It is null");
+
+ sequenceElement.addChild(lastMessageElement);
+
+ lastMessageElement = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).createOMElement(
+ Constants.WSRM.LAST_MSG,lastMsgNamespace);
+
+ return sequenceElement;
}
+
public void setLastMessageElement(OMElement lastMsgElement){
lastMessageElement = lastMsgElement;
}
+
public OMElement getLastMessageElement(){
return lastMessageElement;
}
+
public boolean isPresent(){
return (lastMessageElement != null) ? true:false;
}
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org