Author: alessio.soldano(a)jboss.com
Date: 2008-05-02 13:52:44 -0400 (Fri, 02 May 2008)
New Revision: 6873
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPFactoryImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/xop/XOPContext.java
Log:
[JBWS-2014] Restore XOP Include & attachments after handlers execution (including
non-endpoint ones, WS-Security handlers for instance)
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java 2008-05-02
17:49:10 UTC (rev 6872)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/CommonClient.java 2008-05-02
17:52:44 UTC (rev 6873)
@@ -56,6 +56,7 @@
import org.jboss.ws.core.utils.HolderUtils;
import org.jboss.ws.extensions.addressing.AddressingConstantsImpl;
import org.jboss.ws.extensions.wsrm.RMConstant;
+import org.jboss.ws.extensions.xop.XOPContext;
import org.jboss.ws.metadata.umdm.ClientEndpointMetaData;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
@@ -297,6 +298,8 @@
boolean handlerPass = callRequestHandlerChain(portName, handlerType[0]);
handlerPass = handlerPass && callRequestHandlerChain(portName,
handlerType[1]);
handlerPass = handlerPass && callRequestHandlerChain(portName,
handlerType[2]);
+
+ XOPContext.visitAndRestoreXOPData();
// Handlers might have replaced the message
reqMessage = msgContext.getMessageAbstraction();
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java 2008-05-02
17:49:10 UTC (rev 6872)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerDelegateJAXWS.java 2008-05-02
17:52:44 UTC (rev 6873)
@@ -105,7 +105,7 @@
boolean status = (executor != null ? executor.handleMessage(msgContext) : true);
MessageAbstraction msg =
((CommonMessageContext)msgContext).getMessageAbstraction();
- if (type == HandlerType.ENDPOINT && (msg instanceof SOAPMessage))
+ if (msg instanceof SOAPMessage)
XOPContext.visitAndRestoreXOPData();
return status;
@@ -131,7 +131,7 @@
boolean status = (executor != null ? executor.handleFault(msgContext, ex) : true);
MessageAbstraction msg =
((CommonMessageContext)msgContext).getMessageAbstraction();
- if (type == HandlerType.ENDPOINT && (msg instanceof SOAPMessage))
+ if (msg instanceof SOAPMessage)
XOPContext.visitAndRestoreXOPData();
return status;
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java 2008-05-02
17:49:10 UTC (rev 6872)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/NodeImpl.java 2008-05-02
17:52:44 UTC (rev 6873)
@@ -22,8 +22,10 @@
package org.jboss.ws.core.soap;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
@@ -66,6 +68,8 @@
protected org.w3c.dom.Node domNode;
// A list of soap children
private List<NodeImpl> soapChildren = new ArrayList<NodeImpl>();
+ // A hash with the user data
+ private Map<String, Object> userData;
/** Construct the Node for a given org.w3c.dom.Node
*
@@ -613,8 +617,11 @@
public Object getUserData(String key)
{
- // FIXME getUserData
- throw new NotImplementedException("getUserData");
+ if (userData != null)
+ {
+ return userData.get(key);
+ }
+ return null;
}
public boolean isDefaultNamespace(String namespaceURI)
@@ -654,8 +661,11 @@
public Object setUserData(String key, Object data, UserDataHandler handler)
{
- // FIXME setUserData
- throw new NotImplementedException("setUserData");
+ if (userData == null)
+ {
+ userData = new HashMap<String, Object>();
+ }
+ return userData.put(key, data);
}
// END org.w3c.dom.Node DOM Level 3
*****************************************************************************
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPFactoryImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPFactoryImpl.java 2008-05-02
17:49:10 UTC (rev 6872)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPFactoryImpl.java 2008-05-02
17:52:44 UTC (rev 6873)
@@ -33,6 +33,8 @@
import javax.xml.soap.SOAPFault;
import org.jboss.logging.Logger;
+import org.jboss.ws.Constants;
+import org.jboss.ws.extensions.xop.XOPContext;
import org.jboss.wsf.common.DOMUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -136,6 +138,8 @@
{
SOAPElement soapChild = createElement((Element)child);
soapElement.addChildElement(soapChild);
+ if (Constants.NAME_XOP_INCLUDE.equals(soapChild.getElementQName()))
+ XOPContext.inlineXOPData(soapChild);
}
else if (nodeType == Node.TEXT_NODE)
{
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/xop/XOPContext.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/xop/XOPContext.java 2008-05-02
17:49:10 UTC (rev 6872)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/xop/XOPContext.java 2008-05-02
17:52:44 UTC (rev 6873)
@@ -72,6 +72,8 @@
private static final Logger log = Logger.getLogger(XOPContext.class);
private static final String NS_XOP_JBOSSWS = "http://org.jboss.ws/xop";
+
+ private static final String NS_XOP_JBOSSWS_CONTENT_TYPE = NS_XOP_JBOSSWS +
":content-type";
/**
* Check if the current soap message flagged as a XOP package.
@@ -258,11 +260,11 @@
*/
public static void restoreXOPDataDOM(SOAPElement xopElement)
{
- String contentType = xopElement.getAttributeNS(NS_XOP_JBOSSWS,
"content-type");
+ String contentType = (String)xopElement.getUserData(NS_XOP_JBOSSWS_CONTENT_TYPE);
if (contentType != null && contentType.length() > 0)
{
replaceBase64Representation(xopElement, contentType);
- xopElement.removeAttribute(new NameImpl(new QName(NS_XOP_JBOSSWS,
"content-type")));
+ xopElement.setUserData(NS_XOP_JBOSSWS_CONTENT_TYPE, null, null);
}
else
{
@@ -345,7 +347,7 @@
String base64 = SimpleTypeBindings.marshalBase64(data);
parent.removeChild(xopIncludeElement);
parent.setValue(base64);
- parent.setAttributeNS(NS_XOP_JBOSSWS, "content-type", contentType);
+ parent.setUserData(NS_XOP_JBOSSWS_CONTENT_TYPE, contentType, null);
if (log.isDebugEnabled())
log.debug("Created base64 representation for content-type " +
contentType);