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/03/07 03:39:04 UTC
svn commit: r383751 [2/2] - in
/webservices/sandesha/trunk/src/org/apache/sandesha2: ./ client/ handlers/
msgprocessors/ util/ workers/ wsrm/
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/FaultManager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/FaultManager.java?rev=383751&r1=383750&r2=383751&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/FaultManager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/FaultManager.java Mon Mar 6 18:39:01 2006
@@ -43,8 +43,10 @@
import org.apache.sandesha2.SOAPFaultEnvelopeCreator;
import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.CreateSeqBean;
import org.apache.sandesha2.storage.beans.NextMsgBean;
import org.apache.sandesha2.storage.beans.SequencePropertyBean;
import org.apache.sandesha2.wsrm.AcknowledgementRange;
@@ -67,73 +69,6 @@
public FaultManager() {
}
- public RMMsgContext checkForPossibleFaults(MessageContext msgCtx)
- throws SandeshaException {
-
- //Cannot initialize message before checking for MsgNoRoleover - since
- // initialization will give an exception
- //for rolled over messages.
-
- SOAPEnvelope envelope = msgCtx.getEnvelope();
- if (envelope == null)
- throw new SandeshaException("SOAP Envelope is null");
-
- RMMsgContext faultMessageContext = null;
-
- SOAPHeader header = envelope.getHeader();
- if (header != null) {
- OMElement sequenceHeaderBlock = header
- .getFirstChildWithName(new QName(Sandesha2Constants.SPEC_2005_02.NS_URI,
- Sandesha2Constants.WSRM_COMMON.SEQUENCE));
- if (sequenceHeaderBlock != null) {
- faultMessageContext = checkForMessageNumberRoleover(msgCtx);
- if (faultMessageContext != null)
- return faultMessageContext;
- }
-
- //For the 200510 spec
- sequenceHeaderBlock = header
- .getFirstChildWithName(new QName(Sandesha2Constants.SPEC_2005_10.NS_URI,
- Sandesha2Constants.WSRM_COMMON.SEQUENCE));
- if (sequenceHeaderBlock != null) {
- faultMessageContext = checkForMessageNumberRoleover(msgCtx);
- if (faultMessageContext != null)
- return faultMessageContext;
- }
- }
-
- RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
- int msgType = rmMsgCtx.getMessageType();
-
- if (msgType == Sandesha2Constants.MessageTypes.APPLICATION
- || msgType == Sandesha2Constants.MessageTypes.TERMINATE_SEQ) {
- faultMessageContext = checkForUnknownSequence(msgCtx);
- if (faultMessageContext != null)
- return faultMessageContext;
-
- }
-
- if (msgType == Sandesha2Constants.MessageTypes.CREATE_SEQ) {
- faultMessageContext = checkForCreateSequenceRefused(msgCtx);
- if (faultMessageContext != null)
- return faultMessageContext;
- }
-
- if (msgType == Sandesha2Constants.MessageTypes.ACK) {
- faultMessageContext = checkForInvalidAcknowledgement(msgCtx);
- if (faultMessageContext != null)
- return faultMessageContext;
- }
-
- if (msgType == Sandesha2Constants.MessageTypes.APPLICATION) {
- faultMessageContext = checkForLastMsgNumberExceeded(msgCtx);
- if (faultMessageContext != null)
- return faultMessageContext;
- }
-
- return faultMessageContext;
-
- }
/**
* Check weather the CreateSequence should be refused and generate the fault if it should.
@@ -142,19 +77,19 @@
* @return
* @throws SandeshaException
*/
- private RMMsgContext checkForCreateSequenceRefused(
- MessageContext messageContext) throws SandeshaException {
+ public RMMsgContext checkForCreateSequenceRefused(
+ MessageContext createSequenceMessage) throws SandeshaException {
- RMMsgContext rmMsgCtx = MsgInitializer
- .initializeMessage(messageContext);
+ RMMsgContext createSequenceRMMsg = MsgInitializer
+ .initializeMessage(createSequenceMessage);
- CreateSequence createSequence = (CreateSequence) rmMsgCtx
+ CreateSequence createSequence = (CreateSequence) createSequenceRMMsg
.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
if (createSequence == null)
throw new SandeshaException(
- "CreateSequence message does not have a CreateSequence part");
+ "Passed message does not have a CreateSequence part");
- ConfigurationContext context = messageContext.getConfigurationContext();
+ ConfigurationContext context = createSequenceMessage.getConfigurationContext();
StorageManager storageManager = (StorageManager) SandeshaUtil
.getSandeshaStorageManager(context);
if (storageManager == null)
@@ -171,10 +106,6 @@
refuseSequence = true;
reason = "Offered sequenceId is invalid";
}
-
- if (!refuseSequence) {
- //TODO throw a fault if offered id contains an invalid char e.g.: [ ] ,
- }
if (!refuseSequence) {
NextMsgBeanMgr nextMsgBeanMgr = storageManager
@@ -183,30 +114,16 @@
Iterator it = collection.iterator();
while (it.hasNext()) {
- //checking weather a incoming sequence with the given id
- // exists.
- NextMsgBean nextMsgBean = (NextMsgBean) it.next();
- String sequenceId = nextMsgBean.getSequenceID();
- if (sequenceId.equals(offeredSequenceId)) {
- refuseSequence = true;
- reason = "A sequence with offered sequenceId, already axists";
- }
-
- //checking weather an outgoing sequence with the given id
- // exists.
- SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager
- .getSequencePropretyBeanMgr();
- SequencePropertyBean sequencePropertyBean = sequencePropertyBeanMgr
- .retrieve(
- sequenceId,
- Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
- if (sequencePropertyBean != null) {
- String outSequenceId = (String) sequencePropertyBean
- .getValue();
- if (outSequenceId != null
- && outSequenceId.equals(offeredSequenceId)) {
+ //checking weather an outgoing sequence with the given id exists.
+ SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager
+ .getSequencePropretyBeanMgr();
+ SequencePropertyBean sequencePropertyBean = sequencePropertyBeanMgr
+ .retrieve(offeredSequenceId,Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
+ if (sequencePropertyBean != null) {
+ String outSequenceId = (String) sequencePropertyBean.getValue();
+ if (outSequenceId != null && outSequenceId.equals(offeredSequenceId)) {
refuseSequence = true;
- reason = "A sequence with offered sequenceId, already axists";
+ reason = "An sequence with offered sequenceId has been already established";
}
}
@@ -215,25 +132,18 @@
}
- //TODO - if (securityTokenReference is present RefuseCreateSequence)
-
if (refuseSequence) {
-
FaultData data = new FaultData();
- data
- .setType(Sandesha2Constants.SOAPFaults.FaultType.CREATE_SEQUENCE_REFUSED);
-
- int SOAPVersion = SandeshaUtil.getSOAPVersion(rmMsgCtx
- .getSOAPEnvelope());
+ data.setType(Sandesha2Constants.SOAPFaults.FaultType.CREATE_SEQUENCE_REFUSED);
+ int SOAPVersion = SandeshaUtil.getSOAPVersion(createSequenceRMMsg.getSOAPEnvelope());
if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
data.setCode(SOAP11Constants.FAULT_CODE_SENDER);
else
data.setCode(SOAP12Constants.FAULT_CODE_SENDER);
- data
- .setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.CREATE_SEQUENCE_REFUSED);
+ data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.CREATE_SEQUENCE_REFUSED);
data.setReason(reason);
- return getFault(rmMsgCtx, data);
+ return getFault(createSequenceRMMsg, data);
}
return null;
@@ -246,11 +156,44 @@
* @param msgCtx
* @return
*/
- private RMMsgContext checkForLastMsgNumberExceeded(MessageContext msgCtx) {
- return null;
+ public RMMsgContext checkForLastMsgNumberExceeded(RMMsgContext applicationRMMessage) throws SandeshaException {
+ Sequence sequence = (Sequence) applicationRMMessage.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
+ long messageNumber = sequence.getMessageNumber().getMessageNumber();
+ String sequenceID = sequence.getIdentifier().getIdentifier();
+
+ ConfigurationContext configCtx = applicationRMMessage.getMessageContext().getConfigurationContext();
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx);
+ SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
+
+ boolean lastMessageNumberExceeded = false;
+ String reason = null;
+ SequencePropertyBean lastMessageBean = seqPropMgr.retrieve(sequenceID,Sandesha2Constants.SequenceProperties.LAST_MESSAGE);
+ if (lastMessageBean!=null) {
+ long lastMessageNo = Long.parseLong(lastMessageBean.getValue());
+ if (messageNumber>lastMessageNo) {
+ lastMessageNumberExceeded = true;
+ reason = "The message number of the message '" + messageNumber + "' exceeded the last message number '" + lastMessageNo + "'"+
+ "which was mentioned as last message in a previosly received application message";
+ }
+ }
+
+ if (lastMessageNumberExceeded) {
+ FaultData faultData = new FaultData ();
+ faultData.setType(Sandesha2Constants.SOAPFaults.FaultType.LAST_MESSAGE_NO_EXCEEDED);
+ int SOAPVersion = SandeshaUtil.getSOAPVersion(applicationRMMessage.getSOAPEnvelope());
+ if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
+ faultData.setCode(SOAP11Constants.FAULT_CODE_SENDER);
+ else
+ faultData.setCode(SOAP12Constants.FAULT_CODE_SENDER);
+
+ faultData.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.LAST_MESSAGE_NO_EXCEEDED);
+ faultData.setReason(reason);
+ return getFault(applicationRMMessage, faultData);
+ } else
+ return null;
}
- private RMMsgContext checkForMessageNumberRoleover(
+ public RMMsgContext checkForMessageNumberRoleover(
MessageContext messageContext) {
return null;
}
@@ -264,61 +207,55 @@
* @return @throws
* SandeshaException
*/
- public RMMsgContext checkForUnknownSequence(MessageContext messageContext)
+ public RMMsgContext checkForUnknownSequence(RMMsgContext rmMessageContext, String sequenceID)
throws SandeshaException {
- RMMsgContext rmMsgCtx = MsgInitializer
- .initializeMessage(messageContext);
- String sequenceId = null;
-
- if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
- Sequence sequence = (Sequence) rmMsgCtx
- .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
- if (sequence == null)
- throw new SandeshaException(
- "Sequence part not found in the application message");
-
- sequenceId = sequence.getIdentifier().getIdentifier();
-
- } else if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.ACK) {
- SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) rmMsgCtx
- .getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
- sequenceId = sequenceAcknowledgement.getIdentifier()
- .getIdentifier();
- } else if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.TERMINATE_SEQ) {
- TerminateSequence terminateSequence = (TerminateSequence) rmMsgCtx
- .getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ);
- sequenceId = terminateSequence.getIdentifier().getIdentifier();
- } else {
- //sequenceId not found.
- return null;
- }
-
- StorageManager storageManager = SandeshaUtil
- .getSandeshaStorageManager(messageContext.getConfigurationContext());
-
- NextMsgBeanMgr mgr = storageManager.getNextMsgBeanMgr();
- SOAPEnvelope envelope = messageContext.getEnvelope();
-
- Collection coll = mgr.retrieveAll();
- Iterator it = coll.iterator();
+ MessageContext messageContext = rmMessageContext.getMessageContext();
+ ConfigurationContext configCtx = messageContext.getConfigurationContext();
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx);
+
+ CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
+ int type = rmMessageContext.getMessageType();
+
boolean validSequence = false;
-
- while (it.hasNext()) {
- NextMsgBean nextMsgBean = (NextMsgBean) it.next();
- String tempId = nextMsgBean.getSequenceID();
- if (tempId.equals(sequenceId)) {
+ String reason = null;
+
+ if (type==Sandesha2Constants.MessageTypes.ACK ||
+ type==Sandesha2Constants.MessageTypes.CREATE_SEQ_RESPONSE ||
+ type==Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE ||
+ type==Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE_RESPONSE) {
+
+ CreateSeqBean createSeqFindBean = new CreateSeqBean ();
+ createSeqFindBean.setSequenceID(sequenceID);
+
+ Collection coll = createSeqMgr.find(createSeqFindBean);
+ if (coll.size()==0) {
validSequence = true;
- break;
+ }
+
+ } else {
+ NextMsgBeanMgr mgr = storageManager.getNextMsgBeanMgr();
+ SOAPEnvelope envelope = messageContext.getEnvelope();
+
+ Collection coll = mgr.retrieveAll();
+ Iterator it = coll.iterator();
+
+ while (it.hasNext()) {
+ NextMsgBean nextMsgBean = (NextMsgBean) it.next();
+ String tempId = nextMsgBean.getSequenceID();
+ if (tempId.equals(sequenceID)) {
+ validSequence = true;
+ break;
+ }
}
}
- String rmNamespaceValue = rmMsgCtx.getRMNamespaceValue();
+ String rmNamespaceValue = rmMessageContext.getRMNamespaceValue();
if (!validSequence) {
//Return an UnknownSequence error
- int SOAPVersion = SandeshaUtil.getSOAPVersion(envelope);
+ int SOAPVersion = SandeshaUtil.getSOAPVersion(messageContext.getEnvelope());
FaultData data = new FaultData();
if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
@@ -328,17 +265,14 @@
data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.UNKNOWN_SEQUENCE);
- SOAPFactory factory = SOAPAbstractFactory
- .getSOAPFactory(SOAPVersion);
+ SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SOAPVersion);
Identifier identifier = new Identifier(factory,rmNamespaceValue);
- identifier.setIndentifer(sequenceId);
+ identifier.setIndentifer(sequenceID);
OMElement identifierOMElem = identifier.getOMElement();
data.setDetail(identifierOMElem);
- data
- .setReason("The value of wsrm:Identifier is not a known Sequence identifier");
-
- return getFault(rmMsgCtx, data);
+ data.setReason("A sequence with the given sequenceID has NOT been established");
+ return getFault(rmMessageContext, data);
}
return null;
@@ -351,16 +285,19 @@
* @return @throws
* SandeshaException
*/
- public RMMsgContext checkForInvalidAcknowledgement(MessageContext msgCtx)
+ public RMMsgContext checkForInvalidAcknowledgement(RMMsgContext ackRMMessageContext)
throws SandeshaException {
//check lower<=upper
//TODO acked for not-send message
- RMMsgContext rmMsgContext = new RMMsgContext();
- if (rmMsgContext.getMessageType() != Sandesha2Constants.MessageTypes.ACK)
+
+ MessageContext ackMessageContext = ackRMMessageContext.getMessageContext();
+ if (ackRMMessageContext.getMessageType() != Sandesha2Constants.MessageTypes.ACK)
return null;
- SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) rmMsgContext
+ boolean invalidAck = false;
+ String reason = null;
+ SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) ackRMMessageContext
.getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
List sequenceAckList = sequenceAcknowledgement
.getAcknowledgementRanges();
@@ -373,26 +310,61 @@
long lower = acknowledgementRange.getLowerValue();
if (lower > upper) {
- //Invalid ack
- FaultData data = new FaultData();
- int SOAPVersion = SandeshaUtil.getSOAPVersion(msgCtx
- .getEnvelope());
- if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
- data.setCode(SOAP11Constants.FAULT_CODE_SENDER);
- else
- data.setCode(SOAP12Constants.FAULT_CODE_SENDER);
-
- data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.INVALID_ACKNOWLEDGEMENT);
- data.setSubcode("The SequenceAcknowledgement is invalid. Lower value is larger than upper value");
- data.setDetail(sequenceAcknowledgement.getOMElement());
+ invalidAck = true;
+ reason = "The SequenceAcknowledgement is invalid. Lower value is larger than upper value";
- return getFault(rmMsgContext, data);
}
}
+
+ if (invalidAck) {
+ FaultData data = new FaultData();
+ int SOAPVersion = SandeshaUtil.getSOAPVersion(ackMessageContext.getEnvelope());
+ if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
+ data.setCode(SOAP11Constants.FAULT_CODE_SENDER);
+ else
+ data.setCode(SOAP12Constants.FAULT_CODE_SENDER);
+
+ data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.INVALID_ACKNOWLEDGEMENT);
+ data.setReason(reason);
+ data.setDetail(sequenceAcknowledgement.getOMElement());
+
+ return getFault(ackRMMessageContext, data);
+ }
return null;
}
+ public RMMsgContext checkForSequenceClosed ( RMMsgContext referenceRMMessage, String sequenceID) throws SandeshaException {
+ MessageContext referenceMessage = referenceRMMessage.getMessageContext();
+ ConfigurationContext configCtx = referenceMessage.getConfigurationContext();
+
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx);
+ SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
+
+ boolean sequenceClosed = false;
+ String reason = null;
+ SequencePropertyBean sequenceClosedBean = seqPropMgr.retrieve(sequenceID,Sandesha2Constants.SequenceProperties.SEQUENCE_CLOSED);
+ if (sequenceClosedBean!=null && Sandesha2Constants.VALUE_TRUE.equals(sequenceClosedBean.getValue())) {
+ sequenceClosed = true;
+ reason = "The sequence with the id " + sequenceID + " was closed previously. Cannot accept this message";
+ }
+
+ if (sequenceClosed) {
+ FaultData data = new FaultData();
+ int SOAPVersion = SandeshaUtil.getSOAPVersion(referenceMessage.getEnvelope());
+ if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
+ data.setCode(SOAP11Constants.FAULT_CODE_SENDER);
+ else
+ data.setCode(SOAP12Constants.FAULT_CODE_SENDER);
+
+ data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.SEQUENCE_CLOSED);
+ data.setReason(reason);
+
+ return getFault(referenceRMMessage, data);
+ }
+ return null;
+
+ }
/**
* Returns a RMMessageContext for the fault message. Data for generating the fault is given in the data parameter.
@@ -486,8 +458,7 @@
SOAPFaultEnvelopeCreator.addSOAPFaultEnvelope(faultMsgContext,
SOAPVersion, data,referenceRMMsgContext.getRMNamespaceValue());
- RMMsgContext faultRMMsgCtx = MsgInitializer
- .initializeMessage(faultMsgContext);
+ RMMsgContext faultRMMsgCtx = MsgInitializer.initializeMessage(faultMsgContext);
return faultRMMsgCtx;
@@ -496,4 +467,7 @@
}
}
+
+
+
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java?rev=383751&r1=383750&r2=383751&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java Mon Mar 6 18:39:01 2006
@@ -67,6 +67,16 @@
SandeshaPropertyBean propertyBean = (SandeshaPropertyBean) parameter.getValue();
+
+ //TODO make MaxRetransmissionCount a policy
+ int maxRetransmissionCount = Sandesha2Constants.Properties.DefaultValues.RetransmissionCount;
+ if (retransmitterBean.getSentCount()>maxRetransmissionCount) {
+ log.debug("Stopping retransmission since maximum retransmission was exceeded");
+ retransmitterBean.setSend(false);
+
+ //TODO do reporting and cleaning since this sequence will not work correctly after this.
+ }
+
retransmitterBean.setSentCount(retransmitterBean.getSentCount() + 1);
adjustNextRetransmissionTime(retransmitterBean, propertyBean);
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgInitializer.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgInitializer.java?rev=383751&r1=383750&r2=383751&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgInitializer.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgInitializer.java Mon Mar 6 18:39:01 2006
@@ -26,6 +26,9 @@
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.wsrm.AckRequested;
+import org.apache.sandesha2.wsrm.CloseSequence;
+import org.apache.sandesha2.wsrm.CloseSequenceResponse;
import org.apache.sandesha2.wsrm.CreateSequence;
import org.apache.sandesha2.wsrm.CreateSequenceResponse;
import org.apache.sandesha2.wsrm.RMElements;
@@ -122,6 +125,18 @@
rmNamespace = elements.getAckRequested().getOMElement().getNamespace().getName();
}
+ if (elements.getCloseSequence() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE,
+ elements.getCloseSequence());
+ rmNamespace = elements.getCloseSequence().getOMElement().getNamespace().getName();
+ }
+
+ if (elements.getCloseSequenceResponse() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE,
+ elements.getCloseSequenceResponse());
+ rmNamespace = elements.getCloseSequenceResponse().getOMElement().getNamespace().getName();
+ }
+
rmMsgContext.setRMNamespaceValue(rmNamespace);
}
@@ -150,6 +165,9 @@
TerminateSequenceResponse terminateSequenceResponse = (TerminateSequenceResponse) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE);
SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
+ AckRequested ackRequest = (AckRequested) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST);
+ CloseSequence closeSequence = (CloseSequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
+ CloseSequenceResponse closeSequenceResponse = (CloseSequenceResponse) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE);
//Setting message type.
if (createSequence != null) {
@@ -169,6 +187,15 @@
} else if (sequenceAcknowledgement != null) {
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK);
sequenceID = sequenceAcknowledgement.getIdentifier().getIdentifier();
+ } else if (ackRequest != null) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK_REQUEST);
+ sequenceID = ackRequest.getIdentifier().getIdentifier();
+ } else if (closeSequence != null) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE);
+ sequenceID = closeSequence.getIdentifier().getIdentifier();
+ } else if (closeSequenceResponse != null) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE_RESPONSE);
+ sequenceID = closeSequenceResponse.getIdentifier().getIdentifier();
} else
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.UNKNOWN);
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java?rev=383751&r1=383750&r2=383751&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java Mon Mar 6 18:39:01 2006
@@ -32,7 +32,6 @@
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisOperationFactory;
import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.sandesha2.RMMsgContext;
@@ -45,9 +44,12 @@
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
import org.apache.sandesha2.storage.beans.SequencePropertyBean;
import org.apache.sandesha2.wsrm.Accept;
+import org.apache.sandesha2.wsrm.AckFinal;
import org.apache.sandesha2.wsrm.AcknowledgementRange;
import org.apache.sandesha2.wsrm.AcksTo;
import org.apache.sandesha2.wsrm.Address;
+import org.apache.sandesha2.wsrm.CloseSequence;
+import org.apache.sandesha2.wsrm.CloseSequenceResponse;
import org.apache.sandesha2.wsrm.CreateSequence;
import org.apache.sandesha2.wsrm.CreateSequenceResponse;
import org.apache.sandesha2.wsrm.IOMRMElement;
@@ -109,7 +111,7 @@
Iterator iter = axisOpParams.iterator();
while (iter.hasNext()) {
Parameter nextParam = (Parameter) iter.next();
- Parameter newParam = new ParameterImpl();
+ Parameter newParam = new Parameter();
newParam.setName(nextParam.getName());
newParam.setValue(nextParam.getValue());
@@ -539,8 +541,8 @@
terminateSeqResponseRMMsg.setSOAPEnvelop(envelope);
terminateSeqResponseRMMsg.setMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE,terminateSequenceResponse);
- outMessage.setWSAAction(SpecSpecificConstants.getCreateSequenceResponseAction(SandeshaUtil.getRMVersion(sequenceID,configurationContext)));
- outMessage.setSoapAction(SpecSpecificConstants.getCreateSequenceResponseSOAPAction(SandeshaUtil.getRMVersion(sequenceID,configurationContext)));
+ outMessage.setWSAAction(SpecSpecificConstants.getTerminateSequenceAction(SandeshaUtil.getRMVersion(sequenceID,configurationContext)));
+ outMessage.setSoapAction(SpecSpecificConstants.getTerminateSequenceAction(SandeshaUtil.getRMVersion(sequenceID,configurationContext)));
initializeCreation(terminateSeqRMMsg.getMessageContext(),outMessage);
@@ -551,6 +553,44 @@
return terminateSeqResponseRMMsg;
}
+
+
+ public static RMMsgContext createCloseSeqResponseMsg (RMMsgContext closeSeqRMMsg, MessageContext outMessage) throws SandeshaException {
+
+ RMMsgContext closeSeqResponseRMMsg = new RMMsgContext (outMessage);
+ ConfigurationContext configurationContext = closeSeqRMMsg.getMessageContext().getConfigurationContext();
+
+ SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
+ .getSOAPVersion(closeSeqRMMsg.getSOAPEnvelope()));
+
+ CloseSequence closeSequence = (CloseSequence) closeSeqRMMsg.getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
+ String sequenceID = closeSequence.getIdentifier().getIdentifier();
+
+ String namespace = closeSeqRMMsg.getRMNamespaceValue();
+ closeSeqResponseRMMsg.setRMNamespaceValue(namespace);
+
+ CloseSequenceResponse closeSequenceResponse = new CloseSequenceResponse (factory,namespace);
+ Identifier identifier = new Identifier (factory,namespace);
+ identifier.setIndentifer(sequenceID);
+ closeSequenceResponse.setIdentifier(identifier);
+
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ closeSeqResponseRMMsg.setSOAPEnvelop(envelope);
+ closeSeqResponseRMMsg.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE,closeSequenceResponse);
+
+ outMessage.setWSAAction(SpecSpecificConstants.getCloseSequenceAction(SandeshaUtil.getRMVersion(sequenceID,configurationContext)));
+ outMessage.setSoapAction(SpecSpecificConstants.getCloseSequenceAction(SandeshaUtil.getRMVersion(sequenceID,configurationContext)));
+
+ initializeCreation(closeSeqRMMsg.getMessageContext(),outMessage);
+
+ closeSeqResponseRMMsg.addSOAPEnvelope();
+
+
+ finalizeCreation(closeSeqRMMsg.getMessageContext(), outMessage);
+
+ return closeSeqResponseRMMsg;
+ }
+
/**
* Adds an ack message to the given application message.
@@ -605,7 +645,20 @@
.next();
sequenceAck.addAcknowledgementRanges(ackRange);
}
+
+
+ SequencePropertyBean sequenceClosedBean = seqPropMgr.retrieve(sequenceId,Sandesha2Constants.SequenceProperties.SEQUENCE_CLOSED );
+
+ if (sequenceClosedBean!=null && Sandesha2Constants.VALUE_TRUE.equals(sequenceClosedBean.getValue())) {
+ //sequence is closed. so add the 'Final' part.
+ if (SpecSpecificConstants.isAckFinalAllowed(rmVersion)) {
+ AckFinal ackFinal = new AckFinal (factory,rmNamespaceValue);
+ sequenceAck.setAckFinal(ackFinal);
+ }
+ }
+ applicationMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT,sequenceAck);
+
sequenceAck.toOMElement(envelope.getHeader());
applicationMsg
.setAction(SpecSpecificConstants.getSequenceAcknowledgementAction(SandeshaUtil.getRMVersion(sequenceId,ctx)));
Modified: 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=383751&r1=383750&r2=383751&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java Mon Mar 6 18:39:01 2006
@@ -86,7 +86,9 @@
* @return
*/
public static String getUUID() {
- String uuid = "uuid:" + UUIDGenerator.getUUID();
+ //String uuid = "uuid:" + UUIDGenerator.getUUID();
+ String uuid = UUIDGenerator.getUUID();
+
return uuid;
}
@@ -335,6 +337,14 @@
return "Application";
case Sandesha2Constants.MessageTypes.TERMINATE_SEQ:
return "TerminateSequence";
+ case Sandesha2Constants.MessageTypes.ACK_REQUEST:
+ return "AckRequest";
+ case Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE:
+ return "CloseSequence";
+ case Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE_RESPONSE:
+ return "CloseSequenceResponse";
+ case Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE:
+ return "TerminateSequenceResponse";
case Sandesha2Constants.MessageTypes.UNKNOWN:
return "Unknown";
default:
@@ -457,6 +467,8 @@
return false;
}
+ //TODO make this spec indipendent
+
OMElement sequenceElem = null;
if (header != null)
sequenceElem = header.getFirstChildWithName(new QName(
@@ -472,17 +484,26 @@
if (Sandesha2Constants.SPEC_2005_02.Actions.ACTION_SEQUENCE_ACKNOWLEDGEMENT
.equals(action))
rmGlobalMsg = true;
+
+ if (Sandesha2Constants.SPEC_2005_02.Actions.ACTION_CREATE_SEQUENCE_RESPONSE.equals(action))
+ rmGlobalMsg = true;
if (Sandesha2Constants.SPEC_2005_02.Actions.ACTION_TERMINATE_SEQUENCE.equals(action))
rmGlobalMsg = true;
+
+
if (Sandesha2Constants.SPEC_2005_10.Actions.ACTION_SEQUENCE_ACKNOWLEDGEMENT
.equals(action))
rmGlobalMsg = true;
if (Sandesha2Constants.SPEC_2005_10.Actions.ACTION_TERMINATE_SEQUENCE.equals(action))
rmGlobalMsg = true;
+
+ if (Sandesha2Constants.SPEC_2005_10.Actions.ACTION_CREATE_SEQUENCE_RESPONSE.equals(action))
+ rmGlobalMsg = true;
+
return rmGlobalMsg;
}
@@ -602,7 +623,7 @@
public static ArrayList getArrayListFromString (String str) throws SandeshaException {
- if (str==null)
+ if (str==null || "".equals(str))
return new ArrayList ();
if (str.length()<2) {
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java?rev=383751&r1=383750&r2=383751&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java Mon Mar 6 18:39:01 2006
@@ -221,6 +221,13 @@
acksToEPR.getAddress());
}
+ SequencePropertyBean msgsBean = new SequencePropertyBean();
+ msgsBean.setSequenceID(internalSequenceId);
+ msgsBean.setName(Sandesha2Constants.SequenceProperties.CLIENT_COMPLETED_MESSAGES);
+ msgsBean.setValue("");
+
+ seqPropMgr.insert(msgsBean);
+
seqPropMgr.insert(toBean);
if (acksToBean!=null)
seqPropMgr.insert(acksToBean);
@@ -276,7 +283,7 @@
try {
if ((startListnerForAsyncAcks || startListnerForAsyncControlMsgs) && transportInProtocol==null)
- throw new SandeshaException ("Cant start the listner since the TransportInProtocol is null");
+ throw new SandeshaException ("Cant start the listner since the TransportInProtocol is not set.");
// if (startListnerForAsyncAcks)
// ListenerManager.makeSureStarted(messageContext.getOptions().getTransportInProtocol(),messageContext.getConfigurationContext());
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java?rev=383751&r1=383750&r2=383751&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java Mon Mar 6 18:39:01 2006
@@ -188,6 +188,7 @@
preSendTransaction.commit();
+ //sending the message
TransportOutDescription transportOutDescription = msgCtx
.getTransportOut();
TransportSender transportSender = transportOutDescription
@@ -196,6 +197,9 @@
transportSender.invoke(msgCtx);
}
+
+
+
Transaction postSendTransaction = storageManager.getTransaction();
MessageRetransmissionAdjuster retransmitterAdjuster = new MessageRetransmissionAdjuster();
@@ -254,9 +258,7 @@
} catch (AxisFault e) {
String message = "An Exception was throws in sending";
- System.out.println(message);
log.error(e.getMessage());
- e.printStackTrace();
// TODO : when this is the client side throw the exception to
// the client when necessary.
Added: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckFinal.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckFinal.java?rev=383751&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckFinal.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckFinal.java Mon Mar 6 18:39:01 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.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMException;
+import org.apache.ws.commons.om.OMNamespace;
+import org.apache.ws.commons.soap.SOAPFactory;
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ *
+ * This represent the wsrm:final element that may be present withing a sequence acknowledgement.
+ */
+public class AckFinal {
+
+ private OMElement finalElement = null;
+ OMNamespace rmNamespace = null;
+ SOAPFactory factory;
+ String namespaceValue = null;
+
+ public AckFinal(SOAPFactory factory,String namespaceValue) throws SandeshaException {
+ if (!isNamespaceSupported(namespaceValue))
+ throw new SandeshaException ("Unsupported namespace");
+
+ this.factory = factory;
+ this.namespaceValue = namespaceValue;
+ rmNamespace = factory.createOMNamespace(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+ finalElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.FINAL, rmNamespace);
+ }
+
+ public OMElement getOMElement() throws OMException {
+ return finalElement;
+ }
+
+ public Object fromOMElement(OMElement element) throws OMException {
+ OMElement nonePart = element.getFirstChildWithName(new QName(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.FINAL));
+ if (nonePart == null)
+ throw new OMException(
+ "The passed element does not contain a 'Final' part");
+
+ finalElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.FINAL, rmNamespace);
+
+ return this;
+ }
+
+ public OMElement toOMElement(OMElement sequenceAckElement) throws OMException {
+ //soapheaderblock element will be given
+ if (finalElement == null)
+ throw new OMException("Cant set 'Final' element. It is null");
+
+ sequenceAckElement.addChild(finalElement);
+
+ finalElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.FINAL, rmNamespace);
+
+ return sequenceAckElement;
+ }
+
+ public void setLastMessageElement(OMElement noneElement) {
+ this.finalElement = noneElement;
+ }
+
+ public OMElement getLastMessageElement() {
+ return finalElement;
+ }
+
+ public boolean isPresent() {
+ return (finalElement != null) ? true : false;
+ }
+
+ //this element is only supported in 2005_05_10 spec.
+ public boolean isNamespaceSupported (String namespaceName) {
+ if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+ return false;
+
+ if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+ return true;
+
+ return false;
+ }
+}
Added: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckNone.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckNone.java?rev=383751&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckNone.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckNone.java Mon Mar 6 18:39:01 2006
@@ -0,0 +1,106 @@
+/*
+ * 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.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMException;
+import org.apache.ws.commons.om.OMNamespace;
+import org.apache.ws.commons.soap.SOAPFactory;
+
+
+/**
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ *
+ * This represent the wsrm:none element that may be present withing a sequence acknowledgement.
+ */
+public class AckNone {
+
+ private OMElement noneElement = null;
+ OMNamespace rmNamespace = null;
+ SOAPFactory factory;
+ String namespaceValue = null;
+
+ public AckNone(SOAPFactory factory,String namespaceValue) throws SandeshaException {
+ if (!isNamespaceSupported(namespaceValue))
+ throw new SandeshaException ("Unsupported namespace");
+
+ this.factory = factory;
+ this.namespaceValue = namespaceValue;
+ rmNamespace = factory.createOMNamespace(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+ noneElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.NONE, rmNamespace);
+ }
+
+ public OMElement getOMElement() throws OMException {
+ return noneElement;
+ }
+
+ public Object fromOMElement(OMElement element) throws OMException {
+ OMElement nonePart = element.getFirstChildWithName(new QName(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.NONE));
+ if (nonePart == null)
+ throw new OMException(
+ "The passed element does not contain a 'None' part");
+
+ noneElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.NONE, rmNamespace);
+
+ return this;
+ }
+
+ public OMElement toOMElement(OMElement sequenceAckElement) throws OMException {
+ //soapheaderblock element will be given
+ if (noneElement == null)
+ throw new OMException("Cant set 'None' element. It is null");
+
+ sequenceAckElement.addChild(noneElement);
+
+ noneElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.NONE, rmNamespace);
+
+ return sequenceAckElement;
+ }
+
+ public void setLastMessageElement(OMElement noneElement) {
+ this.noneElement = noneElement;
+ }
+
+ public OMElement getLastMessageElement() {
+ return noneElement;
+ }
+
+ public boolean isPresent() {
+ return (noneElement != null) ? true : false;
+ }
+
+ //this element is only supported in 2005_05_10 spec.
+ public boolean isNamespaceSupported (String namespaceName) {
+ if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceName))
+ return false;
+
+ if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceName))
+ return true;
+
+ return false;
+ }
+}
Added: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CloseSequence.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CloseSequence.java?rev=383751&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CloseSequence.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CloseSequence.java Mon Mar 6 18:39:01 2006
@@ -0,0 +1,135 @@
+/*
+ * 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.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMException;
+import org.apache.ws.commons.om.OMNamespace;
+import org.apache.ws.commons.soap.SOAPBody;
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.apache.ws.commons.soap.SOAPFactory;
+
+/**
+ * Adds the Close Sequence body part.
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+
+public class CloseSequence implements IOMRMPart {
+
+ private OMElement closeSequenceElement;
+ private Identifier identifier;
+ OMNamespace rmNameSpace = null;
+ SOAPFactory factory;
+ String namespaceValue = null;
+
+ public CloseSequence(SOAPFactory factory, String namespaceValue) throws SandeshaException {
+ if (!isNamespaceSupported(namespaceValue))
+ throw new SandeshaException ("Unsupported namespace");
+
+ this.factory = factory;
+ this.namespaceValue = namespaceValue;
+ rmNameSpace = factory.createOMNamespace(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+ closeSequenceElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE, rmNameSpace);
+ }
+
+ public OMElement getOMElement() throws OMException {
+ return closeSequenceElement;
+ }
+
+ public Object fromOMElement(OMElement body) throws OMException,SandeshaException {
+
+ if (!(body instanceof SOAPBody))
+ throw new OMException(
+ "Cant add 'close sequence' to 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(factory,namespaceValue);
+ identifier.fromOMElement(closeSeqPart);
+
+ closeSequenceElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE, rmNameSpace);
+
+ 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 (closeSequenceElement == null)
+ throw new OMException(
+ "Cant add close sequnce since the internal element is null");
+
+ if (identifier == null)
+ throw new OMException(
+ "Cant add close sequence since identifier is not set");
+
+ identifier.toOMElement(closeSequenceElement);
+ body.addChild(closeSequenceElement);
+
+ closeSequenceElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE, rmNameSpace);
+
+ 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/src/org/apache/sandesha2/wsrm/CloseSequenceResponse.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CloseSequenceResponse.java?rev=383751&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CloseSequenceResponse.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CloseSequenceResponse.java Mon Mar 6 18:39:01 2006
@@ -0,0 +1,136 @@
+/*
+ * 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.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMException;
+import org.apache.ws.commons.om.OMNamespace;
+import org.apache.ws.commons.soap.SOAPBody;
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.apache.ws.commons.soap.SOAPFactory;
+
+/**
+ * Adds the Close Sequence Response body part.
+ *
+ * @author Chamikara Jayalath <ch...@gmail.com>
+ */
+public class CloseSequenceResponse implements IOMRMPart {
+
+ private OMElement closeSequenceResponseElement;
+ private Identifier identifier;
+ OMNamespace rmNameSpace = null;
+ SOAPFactory factory;
+ String namespaceValue = null;
+
+ public CloseSequenceResponse(SOAPFactory factory, String namespaceValue) throws SandeshaException {
+ if (!isNamespaceSupported(namespaceValue))
+ throw new SandeshaException ("Unsupported namespace");
+
+ this.factory = factory;
+ this.namespaceValue = namespaceValue;
+ rmNameSpace = factory.createOMNamespace(
+ namespaceValue, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
+ closeSequenceResponseElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE_RESPONSE, rmNameSpace);
+ }
+
+ public OMElement getOMElement() throws OMException {
+ return closeSequenceResponseElement;
+ }
+
+ 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(factory,namespaceValue);
+ identifier.fromOMElement(closeSeqResponsePart);
+
+ closeSequenceResponseElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE_RESPONSE, rmNameSpace);
+
+ 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 (closeSequenceResponseElement == null)
+ throw new OMException(
+ "Cant add close sequnce response since the internal element is null");
+
+ if (identifier == null)
+ throw new OMException(
+ "Cant add close sequence response since identifier is not set");
+
+ identifier.toOMElement(closeSequenceResponseElement);
+ body.addChild(closeSequenceResponseElement);
+
+ closeSequenceResponseElement = factory.createOMElement(
+ Sandesha2Constants.WSRM_COMMON.CLOSE_SEQUENCE_RESPONSE, rmNameSpace);
+
+ 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;
+ }
+
+
+}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/IOMRMPart.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/IOMRMPart.java?rev=383751&r1=383750&r2=383751&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/IOMRMPart.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/IOMRMPart.java Mon Mar 6 18:39:01 2006
@@ -17,6 +17,7 @@
package org.apache.sandesha2.wsrm;
+import org.apache.sandesha2.SandeshaException;
import org.apache.ws.commons.soap.SOAPEnvelope;
/**
@@ -29,5 +30,5 @@
*/
public interface IOMRMPart extends IOMRMElement {
- public void toSOAPEnvelope (SOAPEnvelope envelope);
+ public void toSOAPEnvelope (SOAPEnvelope envelope) throws SandeshaException;
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/RMElements.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/RMElements.java?rev=383751&r1=383750&r2=383751&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/RMElements.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/RMElements.java Mon Mar 6 18:39:01 2006
@@ -44,6 +44,8 @@
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;
String rmNamespaceValue = null;
@@ -127,9 +129,27 @@
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) {
+ public SOAPEnvelope toSOAPEnvelope(SOAPEnvelope envelope) throws SandeshaException {
if (sequence != null) {
sequence.toOMElement(envelope.getHeader());
}
@@ -148,6 +168,19 @@
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;
}
@@ -242,7 +275,29 @@
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
+ }
+
+ 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;
}
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/SequenceAcknowledgement.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/SequenceAcknowledgement.java?rev=383751&r1=383750&r2=383751&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/SequenceAcknowledgement.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/SequenceAcknowledgement.java Mon Mar 6 18:39:01 2006
@@ -31,6 +31,7 @@
import org.apache.ws.commons.soap.SOAPHeaderBlock;
import org.apache.sandesha2.Sandesha2Constants;
import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.SpecSpecificConstants;
/**
* Adds the SequenceAcknowledgement header block.
@@ -50,6 +51,8 @@
SOAPFactory factory;
String namespaceValue = null;
private boolean mustUnderstand = true;
+ private AckNone ackNone = null;
+ private AckFinal ackFinal = null;
public SequenceAcknowledgement(SOAPFactory factory,String namespaceValue) throws SandeshaException {
if (!isNamespaceSupported(namespaceValue))
@@ -107,13 +110,32 @@
nackList.add(nack);
}
+ String rmSpecVersion = SpecSpecificConstants.getSpecVersionString (namespaceValue);
+
+ if (SpecSpecificConstants.isAckFinalAllowed(rmSpecVersion)) {
+ OMElement ackFinalPart = sequenceAckPart.getFirstChildWithName(new QName (namespaceValue,Sandesha2Constants.WSRM_COMMON.FINAL));
+ if (ackFinalPart!=null) {
+ ackFinal = new AckFinal (factory,namespaceValue);
+ ackFinal.fromOMElement(sequenceAckPart);
+ }
+ }
+
+ if (SpecSpecificConstants.isAckNoneAllowed(rmSpecVersion)) {
+ OMElement ackNonePart = sequenceAckPart.getFirstChildWithName(new QName (namespaceValue,Sandesha2Constants.WSRM_COMMON.NONE));
+ if (ackNonePart!=null) {
+ ackNone = new AckNone (factory,namespaceValue);
+ ackNone.fromOMElement(sequenceAckPart);
+ }
+ }
+
sequenceAcknowledgementElement = factory.createOMElement(
Sandesha2Constants.WSRM_COMMON.SEQUENCE_ACK, rmNamespace);
+
return this;
}
- public OMElement toOMElement(OMElement header) throws OMException {
+ public OMElement toOMElement(OMElement header) throws OMException,SandeshaException {
if (header == null || !(header instanceof SOAPHeader))
throw new OMException();
@@ -146,8 +168,44 @@
Nack nack = (Nack) nackIt.next();
nack.toOMElement(sequenceAcknowledgementHeaderBlock);
}
+
+ String rmSpecVersion = SpecSpecificConstants.getSpecVersionString(namespaceValue);
+ //setting a 'None' when nothing is there (for the correct RM version)
+ if (ackNone==null && acknowledgementRangeList.size()==0 && nackList.size()==0 && SpecSpecificConstants.isAckNoneAllowed(rmSpecVersion)) {
+ ackNone = new AckNone (factory,namespaceValue);
+ }
+
+ if (ackNone!=null) {
+ if (!SpecSpecificConstants.isAckNoneAllowed(rmSpecVersion)) {
+ throw new SandeshaException ("The given namespace does not allow the 'None' part to be added to the sequenceAcknowledgement element");
+ }
+
+ if (acknowledgementRangeList.size()>0) {
+ throw new SandeshaException ("The 'None' element cannot be present when there are acknowledgement range elements under the sequenceAcknowledgement");
+ }
+
+ if (nackList.size()>0) {
+ throw new SandeshaException ("The 'None' element cannot be present when there are Nack elements under the sequenceAcknowledgement");
+ }
+
+ ackNone.toOMElement(sequenceAcknowledgementHeaderBlock);
+ }
+
+ if (ackFinal!=null) {
+ if (!SpecSpecificConstants.isAckFinalAllowed(rmSpecVersion)) {
+ throw new SandeshaException ("The given namespace does not allow the 'Final' part to be added to the sequenceAcknowledgement element");
+ }
+
+ if (nackList.size()>0) {
+ throw new SandeshaException ("The 'Final' element cannot be present when there are Nack elements under the sequenceAcknowledgement");
+ }
+
+ ackFinal.toOMElement(sequenceAcknowledgementHeaderBlock);
+ }
+
SOAPHeader.addChild(sequenceAcknowledgementHeaderBlock);
+
sequenceAcknowledgementElement = factory.createOMElement(
Sandesha2Constants.WSRM_COMMON.SEQUENCE_ACK, rmNamespace);
@@ -190,7 +248,7 @@
acknowledgementRangeList.add(element);
}
- public void toSOAPEnvelope(SOAPEnvelope envelope) {
+ public void toSOAPEnvelope(SOAPEnvelope envelope) throws SandeshaException {
SOAPHeader header = envelope.getHeader();
//detach if already exist.
@@ -218,5 +276,21 @@
return true;
return false;
+ }
+
+ public AckFinal getAckFinal() {
+ return ackFinal;
+ }
+
+ public void setAckFinal(AckFinal ackFinal) {
+ this.ackFinal = ackFinal;
+ }
+
+ public AckNone getAckNone() {
+ return ackNone;
+ }
+
+ public void setAckNone(AckNone ackNone) {
+ this.ackNone = ackNone;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org