Author: richard.opalka(a)jboss.com
Date: 2008-02-29 09:33:21 -0500 (Fri, 29 Feb 2008)
New Revision: 5866
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMConstantsImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMSequenceFaultSerializer.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/RMConstants.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMSequenceFaultCode.java
Log:
implemented RMFault serialization
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java 2008-02-29
09:55:15 UTC (rev 5865)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java 2008-02-29
14:33:21 UTC (rev 5866)
@@ -82,7 +82,7 @@
@Override
public String getMessage()
{
- return faultCode.getSubcode() + ": " + faultCode.getReason();
+ return faultCode.getReason();
}
}
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMConstantsImpl.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMConstantsImpl.java 2008-02-29
09:55:15 UTC (rev 5865)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMConstantsImpl.java 2008-02-29
14:33:21 UTC (rev 5866)
@@ -55,6 +55,7 @@
private final QName lastMsgNumberQName;
private final QName lowerQName;
private final QName messageNumberQName;
+ private final QName maxMessageNumberQName;
private final QName nackQName;
private final QName noneQName;
private final QName offerQName;
@@ -89,6 +90,7 @@
this.lastMsgNumberQName = new QName(namespaceURI, "LastMsgNumber",
prefix);
this.lowerQName = new QName(null, "Lower", "");
this.messageNumberQName = new QName(namespaceURI, "MessageNumber",
prefix);
+ this.maxMessageNumberQName = new QName(namespaceURI, "MaxMessageNumber",
prefix);
this.nackQName = new QName(namespaceURI, "Nack", prefix);
this.noneQName = new QName(namespaceURI, "None", prefix);
this.offerQName = new QName(namespaceURI, "Offer", prefix);
@@ -277,6 +279,14 @@
}
/**
+ * @see org.jboss.ws.extensions.wsrm.spi.RMConstants#getMaxMessageNumberQName()
+ */
+ public final QName getMaxMessageNumberQName()
+ {
+ return this.maxMessageNumberQName;
+ }
+
+ /**
* @see org.jboss.ws.extensions.wsrm.spi.RMConstants#getNackQName()
*/
public final QName getNackQName()
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMSequenceFaultSerializer.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMSequenceFaultSerializer.java 2008-02-29
09:55:15 UTC (rev 5865)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMSequenceFaultSerializer.java 2008-02-29
14:33:21 UTC (rev 5866)
@@ -21,11 +21,24 @@
*/
package org.jboss.ws.extensions.wsrm.common.serialization;
+import java.util.Map;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.jboss.util.NotImplementedException;
+import org.jboss.ws.extensions.wsrm.RMFault;
+import org.jboss.ws.extensions.wsrm.RMFaultConstant;
import org.jboss.ws.extensions.wsrm.api.RMException;
+import org.jboss.ws.extensions.wsrm.spi.RMConstants;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
+import org.jboss.ws.extensions.wsrm.spi.protocol.RMSequenceAcknowledgement;
+import org.jboss.ws.extensions.wsrm.spi.protocol.RMSequenceFault;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMSerializable;
/**
@@ -48,10 +61,10 @@
}
/**
- * Deserialize <b>SequenceFault</b> using <b>provider</b> from
the <b>soapMessage</b>
- * @param object to be deserialized
- * @param provider wsrm provider to be used for deserialization process
- * @param soapMessage soap message from which object will be deserialized
+ * Serialize <b>SequenceFault</b> using <b>provider</b> to the
<b>soapMessage</b>
+ * @param object to be serialized
+ * @param provider wsrm provider to be used for serialization process
+ * @param soapMessage soap message to which object will be serialized
*/
public final void deserialize(RMSerializable object, RMProvider provider, SOAPMessage
soapMessage)
throws RMException
@@ -60,15 +73,85 @@
}
/**
- * Serialize <b>SequenceFault</b> using <b>provider</b> to the
<b>soapMessage</b>
- * @param object to be serialized
- * @param provider wsrm provider to be used for serialization process
- * @param soapMessage soap message to which object will be serialized
+ * Deserialize <b>SequenceFault</b> using <b>provider</b> from
the <b>soapMessage</b>
+ * @param object to be deserialized
+ * @param provider wsrm provider to be used for deserialization process
+ * @param soapMessage soap message from which object will be deserialized
*/
public final void serialize(RMSerializable object, RMProvider provider, SOAPMessage
soapMessage)
throws RMException
{
- throw new NotImplementedException();
+ RMSequenceFault o = (RMSequenceFault)object;
+ try
+ {
+ SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
+ boolean isSoap11 =
SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(soapEnvelope.getElementQName().getNamespaceURI());
+ if (false == isSoap11)
+ {
+ throw new NotImplementedException("TODO: implement SOAP 12
serialization");
+ }
+
+ RMConstants wsrmConstants = provider.getConstants();
+
+ // Add xmlns:wsrm declaration
+ soapEnvelope.addNamespaceDeclaration(wsrmConstants.getPrefix(),
wsrmConstants.getNamespaceURI());
+
+ // write required wsrm:SequenceFault element
+ QName sequenceFaultQName = wsrmConstants.getSequenceFaultQName();
+ SOAPElement sequenceFaultElement =
soapEnvelope.getHeader().addChildElement(sequenceFaultQName);
+
+ // write required wsrm:FaultCode element
+ RMFault rmFault = (RMFault)o.getDetail();
+ QName faultCodeQName = wsrmConstants.getFaultCodeQName();
+ String subcode = wsrmConstants.getPrefix() + ":" +
rmFault.getFaultCode().getSubcode().getValue();
+ sequenceFaultElement.addChildElement(faultCodeQName).setValue(subcode);
+
+ Map<String, Object> details = rmFault.getDetails();
+ if (details.size() > 0)
+ {
+ for (Iterator<String> i = details.keySet().iterator(); i.hasNext(); )
+ {
+ // write optional wsrm:Detail elements
+ QName detailQName = wsrmConstants.getDetailQName();
+ SOAPElement detailElement =
sequenceFaultElement.addChildElement(detailQName);
+
+ String key = i.next();
+ if (RMFaultConstant.IDENTIFIER.equals(key))
+ {
+ // write optional wsrm:Identifier element
+ String sequenceId = (String)details.get(key);
+ QName identifierQName = wsrmConstants.getIdentifierQName();
+ detailElement.addChildElement(identifierQName).setValue(sequenceId);
+ }
+ else if (RMFaultConstant.ACKNOWLEDGEMENT.equals(key))
+ {
+ // write optional wsrm:AcknowledgementRange element
+ RMSequenceAcknowledgement.RMAcknowledgementRange ackRange =
(RMSequenceAcknowledgement.RMAcknowledgementRange)details.get(key);
+ QName acknowledgementRangeQName =
wsrmConstants.getAcknowledgementRangeQName();
+ QName upperQName = wsrmConstants.getUpperQName();
+ QName lowerQName = wsrmConstants.getLowerQName();
+
+ SOAPElement acknowledgementRangeElement =
detailElement.addChildElement(acknowledgementRangeQName);
+ // write required wsrm:Lower attribute
+ acknowledgementRangeElement.addAttribute(lowerQName,
String.valueOf(ackRange.getLower()));
+ // write required wsrm:Upper attribute
+ acknowledgementRangeElement.addAttribute(upperQName,
String.valueOf(ackRange.getUpper()));
+ }
+ else if (RMFaultConstant.MAX_MESSAGE_NUMBER.equals(key))
+ {
+ // write optional wsrm:MaxMessageNumber element
+ Long maxMessageNumber = (Long)details.get(key);
+ QName maxMessageNumberQName =
wsrmConstants.getMaxMessageNumberQName();
+
detailElement.addChildElement(maxMessageNumberQName).setValue(maxMessageNumber.toString());
+ }
+ else throw new IllegalArgumentException("Can't serialize detail
with key " + key);
+ }
+ }
+ }
+ catch (SOAPException se)
+ {
+ throw new RMException("Unable to serialize RM message", se);
+ }
}
}
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java 2008-02-29
09:55:15 UTC (rev 5865)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java 2008-02-29
14:33:21 UTC (rev 5866)
@@ -305,6 +305,7 @@
protocolMessages.add(rmConstants.getSequenceFaultQName());
rmResponseContext.put(RMConstant.PROTOCOL_MESSAGES, protocolMessages);
rmResponseContext.put(RMConstant.FAULT_REFERENCE, fault);
+ rmResponseContext.put(RMConstant.ONE_WAY_OPERATION, false);
CommonMessageContext msgCtx = MessageContextAssociation.peekMessageContext();
msgCtx.put(RMConstant.RESPONSE_CONTEXT, rmResponseContext);
throw fault; // rethrow
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/RMConstants.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/RMConstants.java 2008-02-29
09:55:15 UTC (rev 5865)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/RMConstants.java 2008-02-29
14:33:21 UTC (rev 5866)
@@ -153,6 +153,12 @@
/**
* getter
+ * @return <b>MaxMessageNumber</b> QName
+ */
+ QName getMaxMessageNumberQName();
+
+ /**
+ * getter
* @return <b>AckRequested</b> QName
*/
QName getAckRequestedQName();
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMSequenceFaultCode.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMSequenceFaultCode.java 2008-02-29
09:55:15 UTC (rev 5865)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMSequenceFaultCode.java 2008-02-29
14:33:21 UTC (rev 5866)
@@ -29,43 +29,57 @@
*/
public enum RMSequenceFaultCode
{
+
/**
* Sequence terminated
*/
- SEQUENCE_TERMINATED,
+ SEQUENCE_TERMINATED("SequenceTerminated"),
/**
* Unknown sequence
*/
- UNKNOWN_SEQUENCE,
+ UNKNOWN_SEQUENCE("UnknownSequence"),
/**
* Invalid acknowledgement
*/
- INVALID_ACKNOWLEDGEMENT,
+ INVALID_ACKNOWLEDGEMENT("InvalidAcknowledgement"),
/**
* Message number rollover
*/
- MESSAGE_NUMBER_ROLLOVER,
+ MESSAGE_NUMBER_ROLLOVER("MessageNumberRollover"),
/**
* Create sequence refused
*/
- CREATE_SEQUENCE_REFUSED,
+ CREATE_SEQUENCE_REFUSED("CreateSequenceRefused"),
/**
* Sequence closed
*/
- SEQUENCE_CLOSED,
+ SEQUENCE_CLOSED("SequenceClosed"),
/**
* WSRM required
*/
- WSRM_REQUIRED,
+ WSRM_REQUIRED("WSRMRequired"),
/**
* Last message number exceeded
*/
- LAST_MESSAGE_NUMBER_EXCEEDED
+ LAST_MESSAGE_NUMBER_EXCEEDED("LastMessageNumberExceeded");
+
+ private final String value;
+
+ RMSequenceFaultCode(String value)
+ {
+ this.value = value;
+ }
+
+ public final String getValue()
+ {
+ return this.value;
+ }
+
}