axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidills...@apache.org
Subject svn commit: r430782 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/addressing/ addressing/src/org/apache/axis2/handlers/addressing/ addressing/test/org/apache/axis2/addressing/ core/src/org/apache/axis2/addressing/ core/tes...
Date Fri, 11 Aug 2006 13:03:14 GMT
Author: davidillsley
Date: Fri Aug 11 06:03:14 2006
New Revision: 430782

URL: http://svn.apache.org/viewvc?rev=430782&view=rev
Log:
Further work on AXIS2-948 including:
	refactor of the FinalFaults helper to the addressing module
	refactor of outbound addressing fault detail into the FinalFaultsHelper

Added:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/FinalFaultsHelper.java
    webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/
    webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/FinalFaultsTest.java
      - copied, changed from r430743, webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/FinalFaultsTest.java
Removed:
    webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/FinalFaultsTest.java
Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java

Added: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/FinalFaultsHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/FinalFaultsHelper.java?rev=430782&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/FinalFaultsHelper.java
(added)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/FinalFaultsHelper.java
Fri Aug 11 06:03:14 2006
@@ -0,0 +1,142 @@
+/**
+ * 
+ */
+package org.apache.axis2.addressing;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAPFaultSubCode;
+import org.apache.axiom.soap.SOAPFaultValue;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class FinalFaultsHelper{
+    
+    private static final Log log = LogFactory.getLog(FinalFaultsHelper.class);
+    
+    //    wsa:InvalidAddressingHeader [Reason] the string: "A header representing a Message
Addressing Property is not valid and the message cannot be processed"
+    //      wsa:InvalidAddress
+    //      wsa:InvalidEPR
+    //      wsa:InvalidCardinality
+    public static void triggerInvalidCardinalityFault(MessageContext messageContext, String
incorrectHeaderName) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerInvalidCardinalityFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
+        }
+        triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME, AddressingConstants.WSA_DEFAULT_PREFIX
+ ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER, "InvalidCardinality", Final.FAULT_INVALID_HEADER_REASON);
+    }
+
+    //      wsa:MissingAddressInEPR
+    //      wsa:DuplicateMessageID
+    //      wsa:ActionMismatch
+    public static void triggerActionMismatchFault(MessageContext messageContext) throws AxisFault
{
+        if(log.isDebugEnabled()){
+            log.debug("triggerActionMismatchFault: messageContext: "+messageContext);
+        }
+        triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME, AddressingConstants.WSA_DEFAULT_PREFIX
+ ":"+"Action", Final.FAULT_INVALID_HEADER, "ActionMismatch", Final.FAULT_INVALID_HEADER_REASON);
+    }
+
+    //      wsa:OnlyAnonymousAddressSupported
+    public static void triggerOnlyAnonymousAddressSupportedFault(MessageContext messageContext,
String incorrectHeaderName) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerOnlyAnonymousAddressSupportedFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
+        }
+        triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME, AddressingConstants.WSA_DEFAULT_PREFIX
+ ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER, Final.FAULT_ONLY_ANONYMOUS_ADDRESS_SUPPORTED,
Final.FAULT_INVALID_HEADER_REASON);
+    }
+
+    //      wsa:OnlyNonAnonymousAddressSupported
+    public static void triggerOnlyNonAnonymousAddressSupportedFault(MessageContext messageContext,
String incorrectHeaderName) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerOnlyNonAnonymousAddressSupportedFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
+        }
+        triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME, AddressingConstants.WSA_DEFAULT_PREFIX
+ ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER, Final.FAULT_ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED,
Final.FAULT_INVALID_HEADER_REASON);
+    }
+
+    //    wsa:MessageAddressingHeaderRequired [Reason] the string: "A required header representing
a Message Addressing Property is not present"
+    public static void triggerMessageAddressingRequiredFault(MessageContext messageContext,
String missingHeaderName) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerMessageAddressingRequiredFault: messageContext: "+messageContext+"
missingHeaderName: "+missingHeaderName);
+        }
+        triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME, AddressingConstants.WSA_DEFAULT_PREFIX
+ ":" + missingHeaderName, Final.FAULT_ADDRESSING_HEADER_REQUIRED, null, Final.FAULT_ADDRESSING_HEADER_REQUIRED_REASON);
+    }
+
+    //    wsa:ActionNotSupported [Reason] the string: "The [action] cannot be processed at
the receiver"
+    public static void triggerActionNotSupportedFault(MessageContext messageContext, String
problemAction) throws AxisFault {
+        if(log.isDebugEnabled()){
+            log.debug("triggerActionNotSupportedFault: messageContext: "+messageContext+"
problemAction: "+problemAction);
+        }
+        triggerAddressingFault(messageContext, AddressingConstants.Final.FAULT_PROBLEM_ACTION_NAME,
problemAction, Final.FAULT_ACTION_NOT_SUPPORTED, null, Final.FAULT_ACTION_NOT_SUPPORTED_REASON);
+    }
+    //    wsa:EndpointUnavailable [Reason] the string "The endpoint is unable to process
the message at this time"
+
+    private static void triggerAddressingFault(MessageContext messageContext, String faultInformationKey,
Object faultInformationValue, String faultcode, String faultSubcode, String faultReason) throws
AxisFault{
+        Map faultInformation = (Map) messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
+        if (faultInformation == null) {
+            faultInformation = new HashMap();
+            messageContext.setProperty(Constants.FAULT_INFORMATION_FOR_HEADERS, faultInformation);
+        }
+
+        if(messageContext.getMessageID() != null) {
+            faultInformation.put(AddressingConstants.WSA_RELATES_TO,messageContext.getMessageID());
+        }
+
+        faultInformation.put(Final.WSA_FAULT_ACTION, Final.WSA_FAULT_ACTION);
+        faultInformation.put(faultInformationKey, faultInformationValue);
+
+        if (!messageContext.isSOAP11()) {
+            setFaultCode(messageContext, faultcode, faultSubcode);
+        }
+
+        messageContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
Boolean.FALSE);
+        AxisFault fault = new AxisFault(faultReason, new QName(AddressingConstants.Final.WSA_NAMESPACE,faultcode));
+        throw fault;
+    }
+
+    private static void setFaultCode(MessageContext messageContext, String faultCode, String
faultSubCode) {
+        SOAPFactory soapFac = OMAbstractFactory.getSOAP12Factory();
+        SOAPFaultCode soapFaultCode = soapFac.createSOAPFaultCode();
+        SOAPFaultValue soapFaultValue = soapFac.createSOAPFaultValue(soapFaultCode);
+        soapFaultValue.setText(SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX + ":" + SOAP12Constants.FAULT_CODE_SENDER);
+        SOAPFaultSubCode soapFaultSubCode = soapFac.createSOAPFaultSubCode(soapFaultCode);
+        SOAPFaultValue soapFaultSubcodeValue = soapFac.createSOAPFaultValue(soapFaultSubCode);
+        soapFaultSubcodeValue.setText(AddressingConstants.WSA_DEFAULT_PREFIX + ":" + faultCode);
+        if (faultSubCode != null) {
+            SOAPFaultSubCode soapFaultSubCode2 = soapFac.createSOAPFaultSubCode(soapFaultSubCode);
+            SOAPFaultValue soapFaultSubcodeValue2 = soapFac.createSOAPFaultValue(soapFaultSubCode2);
+            soapFaultSubcodeValue2.setText(AddressingConstants.WSA_DEFAULT_PREFIX + ":" +
faultSubCode);
+        }
+        messageContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, soapFaultCode);
+    }
+    
+    public static OMElement getDetailElementForAddressingFault(MessageContext messageContext,
OMNamespace addressingNamespaceObject){
+        Map faultInfo = (Map) messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
+        OMElement probHeaderQName = null;
+        if (faultInfo != null) {
+            String faultyHeaderQName = (String) faultInfo.get(Final.FAULT_HEADER_PROB_HEADER_QNAME);
+            String faultyAction = (String) faultInfo.get(AddressingConstants.Final.FAULT_PROBLEM_ACTION_NAME);
+            if(faultyAction!=null && !"".equals(faultyAction)){
+                probHeaderQName = messageContext.getEnvelope().getOMFactory().createOMElement(AddressingConstants.Final.FAULT_PROBLEM_ACTION_NAME,
addressingNamespaceObject);
+                OMElement probH2 = messageContext.getEnvelope().getOMFactory().createOMElement(AddressingConstants.WSA_ACTION,
addressingNamespaceObject,probHeaderQName);
+                probH2.setText(faultyAction);
+                
+            }
+            if (faultyHeaderQName != null && !"".equals(faultyHeaderQName)) {
+                probHeaderQName = messageContext.getEnvelope().getOMFactory().createOMElement(Final.FAULT_HEADER_PROB_HEADER_QNAME,
addressingNamespaceObject);
+                probHeaderQName.setText(faultyHeaderQName);
+            }
+        }
+        return probHeaderQName;
+    }
+}
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java?rev=430782&r1=430781&r2=430782&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
Fri Aug 11 06:03:14 2006
@@ -7,7 +7,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.AddressingHelper.FinalFaults;
+import org.apache.axis2.addressing.FinalFaultsHelper;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisEngine;
@@ -97,7 +97,7 @@
     
     protected void checkForMandatoryHeaders(ArrayList alreadyFoundAddrHeader, MessageContext
messageContext) throws AxisFault {
         if (!alreadyFoundAddrHeader.contains(WSA_ACTION)) {
-            FinalFaults.triggerMessageAddressingRequiredFault(messageContext, WSA_ACTION);
+            FinalFaultsHelper.triggerMessageAddressingRequiredFault(messageContext, WSA_ACTION);
         } 
     }
     

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java?rev=430782&r1=430781&r2=430782&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
Fri Aug 11 06:03:14 2006
@@ -26,8 +26,8 @@
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.FinalFaultsHelper;
 import org.apache.axis2.addressing.RelatesTo;
-import org.apache.axis2.addressing.AddressingHelper.FinalFaults;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.util.Utils;
@@ -155,7 +155,7 @@
         // This means that if for example there are multiple MessageIDs and a FaultTo, the
FaultTo will be respected.
         if(!duplicateHeaderNames.isEmpty()){
         	// Simply choose the first problem header we came across as we can only fault for
one of them.
-            FinalFaults.triggerInvalidCardinalityFault(messageContext, (String)duplicateHeaderNames.get(0));
+            FinalFaultsHelper.triggerInvalidCardinalityFault(messageContext, (String)duplicateHeaderNames.get(0));
         }
         
         // check for the presence of madatory addressing headers
@@ -261,7 +261,7 @@
         
         if (soapAction != null && !"".equals(soapAction)) {
             if (!soapAction.equals(soapHeaderBlock.getText())) {
-                FinalFaults.triggerActionMismatchFault(messageContext);
+                FinalFaultsHelper.triggerActionMismatchFault(messageContext);
             }
         }
         else {

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java?rev=430782&r1=430781&r2=430782&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
Fri Aug 11 06:03:14 2006
@@ -30,6 +30,7 @@
 import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.FinalFaultsHelper;
 import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
@@ -158,30 +159,19 @@
     }
 
     private void processFaultsInfoIfPresent(SOAPEnvelope envelope, MessageContext msgContext,
OMNamespace addressingNamespaceObject, boolean replaceHeaders) {
-        Map faultInfo = (Map) msgContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
-        if (faultInfo != null) {
-            String faultyHeaderQName = (String) faultInfo.get(Final.FAULT_HEADER_PROB_HEADER_QNAME);
-            if (faultyHeaderQName != null && !"".equals(faultyHeaderQName)) {
-                // add to header
+        OMElement detailElement = FinalFaultsHelper.getDetailElementForAddressingFault(msgContext,
addressingNamespaceObject);
+        if(detailElement != null){
+            if(msgContext.isSOAP11()){ // This difference is explained in the WS-Addressing
SOAP Binding Spec.
+                // Add detail as a wsa:FaultDetail header
                 SOAPHeaderBlock faultDetail = envelope.getHeader().addHeaderBlock(Final.FAULT_HEADER_DETAIL,
addressingNamespaceObject);
-                OMElement probHeaderQName = envelope.getOMFactory().createOMElement(Final.FAULT_HEADER_PROB_HEADER_QNAME,
addressingNamespaceObject, faultDetail);
-                probHeaderQName.setText(faultyHeaderQName);
-
-                String messageID = (String) faultInfo.get(AddressingConstants.WSA_RELATES_TO);
-                if (messageID != null) {
-                    SOAPHeaderBlock relatesTo = envelope.getHeader().addHeaderBlock(AddressingConstants.WSA_RELATES_TO,
addressingNamespaceObject);
-                    relatesTo.setText(messageID);
-                }
-
-                // add to header
+                faultDetail.addChild(detailElement);
+            }else{
+                // Add detail to the Fault in the SOAP Body
                 SOAPFault fault = envelope.getBody().getFault();
                 if (fault != null && fault.getDetail() != null) {
-                    OMElement probHeaderQName2 = envelope.getOMFactory().createOMElement(Final.FAULT_HEADER_PROB_HEADER_QNAME,
addressingNamespaceObject, fault.getDetail());
-                    probHeaderQName2.setText(faultyHeaderQName);
+                    fault.getDetail().addDetailEntry(detailElement);
                 }
-
             }
-
         }
     }
 

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java?rev=430782&r1=430781&r2=430782&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
Fri Aug 11 06:03:14 2006
@@ -7,8 +7,8 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.FinalFaultsHelper;
 import org.apache.axis2.addressing.AddressingConstants.Final;
-import org.apache.axis2.addressing.AddressingHelper.FinalFaults;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
 import org.apache.commons.logging.Log;
@@ -99,18 +99,18 @@
     protected void checkForMandatoryHeaders(ArrayList alreadyFoundAddrHeader, MessageContext
messageContext) throws AxisFault {
         if (!alreadyFoundAddrHeader.contains(WSA_TO)) {
             // Should write a new SubmissionFaults class but for the moment use the FinalFaults
-            FinalFaults.triggerMessageAddressingRequiredFault(messageContext, WSA_TO);
+            FinalFaultsHelper.triggerMessageAddressingRequiredFault(messageContext, WSA_TO);
         }
         
         if (!alreadyFoundAddrHeader.contains(WSA_ACTION)) {
-            FinalFaults.triggerMessageAddressingRequiredFault(messageContext, WSA_ACTION);
+            FinalFaultsHelper.triggerMessageAddressingRequiredFault(messageContext, WSA_ACTION);
         }
         
         if (alreadyFoundAddrHeader.contains(WSA_REPLY_TO) ||
             alreadyFoundAddrHeader.contains(WSA_FAULT_TO)) {
             
             if (!alreadyFoundAddrHeader.contains(WSA_MESSAGE_ID)) {
-                FinalFaults.triggerMessageAddressingRequiredFault(messageContext, WSA_MESSAGE_ID);
+                FinalFaultsHelper.triggerMessageAddressingRequiredFault(messageContext, WSA_MESSAGE_ID);
             }
         }
     }

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java?rev=430782&r1=430781&r2=430782&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingWSDLValidationHandler.java
Fri Aug 11 06:03:14 2006
@@ -19,10 +19,9 @@
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.AddressingHelper;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.AddressingHelper.FinalFaults;
+import org.apache.axis2.addressing.FinalFaultsHelper;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -58,7 +57,7 @@
             if (log.isTraceEnabled())
                 log.trace("checkUsingAddressing: WS_ADDRESSING_VERSION=" + flag);
             if (flag == null) {
-                FinalFaults.triggerMessageAddressingRequiredFault(msgContext,AddressingConstants.WSA_ACTION);
+                FinalFaultsHelper.triggerMessageAddressingRequiredFault(msgContext,AddressingConstants.WSA_ACTION);
             }
         }
     }
@@ -68,7 +67,7 @@
      * ReplyTo+FaultTo are valid and fault if not.
      */
     private void checkAnonymous(MessageContext msgContext) throws AxisFault {
-        String anonymous = Utils.getParameterValue(msgContext.getAxisOperation().getParameter(AddressingConstants.WSAW_ANONYMOUS_PARAMETER_NAME));
+        String anonymous = AddressingHelper.getAnonymousParameterValue(msgContext.getAxisOperation());
         if (log.isTraceEnabled())
             log.trace("checkAnonymous: Anonymous=" + anonymous);
         if("required".equals(anonymous)){
@@ -76,20 +75,20 @@
                 EndpointReference anonEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
                 msgContext.setReplyTo(anonEPR);
                 msgContext.setFaultTo(anonEPR);
-                FinalFaults.triggerOnlyAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_REPLY_TO);
+                FinalFaultsHelper.triggerOnlyAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_REPLY_TO);
             }
             if(AddressingHelper.isFaultRedirected(msgContext)){
                 EndpointReference anonEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
                 msgContext.setReplyTo(anonEPR);
                 msgContext.setFaultTo(anonEPR);
-                FinalFaults.triggerOnlyAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_FAULT_TO);
+                FinalFaultsHelper.triggerOnlyAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_FAULT_TO);
             }
         }else if("prohibited".equals(anonymous)){
             if(!AddressingHelper.isReplyRedirected(msgContext)){
-                FinalFaults.triggerOnlyNonAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_REPLY_TO);
+                FinalFaultsHelper.triggerOnlyNonAnonymousAddressSupportedFault(msgContext,
AddressingConstants.WSA_REPLY_TO);
             }
             if(!AddressingHelper.isFaultRedirected(msgContext)){
-                FinalFaults.triggerOnlyNonAnonymousAddressSupportedFault(msgContext, AddressingConstants.WSA_FAULT_TO);
+                FinalFaultsHelper.triggerOnlyNonAnonymousAddressSupportedFault(msgContext,
AddressingConstants.WSA_FAULT_TO);
             }
         }
     }
@@ -102,7 +101,7 @@
     private void checkAction(MessageContext msgContext) throws AxisFault{
         if(msgContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION)!=null){
             if((msgContext.getAxisService() == null) || (msgContext.getAxisOperation() ==
null)){
-                FinalFaults.triggerActionNotSupportedFault(msgContext, msgContext.getWSAAction());
+                FinalFaultsHelper.triggerActionNotSupportedFault(msgContext, msgContext.getWSAAction());
             }
         }
     }

Copied: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/FinalFaultsTest.java
(from r430743, webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/FinalFaultsTest.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/FinalFaultsTest.java?p2=webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/FinalFaultsTest.java&p1=webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/FinalFaultsTest.java&r1=430743&r2=430782&rev=430782&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/FinalFaultsTest.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/FinalFaultsTest.java
Fri Aug 11 06:03:14 2006
@@ -29,12 +29,12 @@
 public class FinalFaultsTest extends TestCase {
 
     /**
-     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerInvalidCardinalityFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     * Test method for {@link org.apache.axis2.addressing.FinalFaultsHelper#triggerInvalidCardinalityFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
      */
     public void testTriggerInvalidCardinalityFault() {
         MessageContext messageContext = new MessageContext();
         try{
-            AddressingHelper.FinalFaults.triggerInvalidCardinalityFault(messageContext, "Action");
+            FinalFaultsHelper.triggerInvalidCardinalityFault(messageContext, "Action");
             fail("Should have thrown exception");
         }catch(AxisFault af){
             // Expected
@@ -46,12 +46,12 @@
     }
 
     /**
-     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerActionMismatchFault(org.apache.axis2.context.MessageContext)}.
+     * Test method for {@link org.apache.axis2.addressing.FinalFaultsHelper#triggerActionMismatchFault(org.apache.axis2.context.MessageContext)}.
      */
     public void testTriggerActionMismatchFault() {
         MessageContext messageContext = new MessageContext();
         try{
-            AddressingHelper.FinalFaults.triggerActionMismatchFault(messageContext);
+            FinalFaultsHelper.triggerActionMismatchFault(messageContext);
             fail("Should have thrown exception");
         }catch(AxisFault af){
             // Expected
@@ -63,12 +63,12 @@
     }
 
     /**
-     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerOnlyAnonymousAddressSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     * Test method for {@link org.apache.axis2.addressing.FinalFaultsHelper#triggerOnlyAnonymousAddressSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
      */
     public void testTriggerOnlyAnonymousAddressSupportedFault() {
         MessageContext messageContext = new MessageContext();
         try{
-            AddressingHelper.FinalFaults.triggerOnlyAnonymousAddressSupportedFault(messageContext,
"ReplyTo");
+            FinalFaultsHelper.triggerOnlyAnonymousAddressSupportedFault(messageContext, "ReplyTo");
             fail("Should have thrown exception");
         }catch(AxisFault af){
             // Expected
@@ -80,12 +80,12 @@
     }
 
     /**
-     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerOnlyNonAnonymousAddressSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     * Test method for {@link org.apache.axis2.addressing.FinalFaultsHelper#triggerOnlyNonAnonymousAddressSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
      */
     public void testTriggerOnlyNonAnonymousAddressSupportedFault() {
         MessageContext messageContext = new MessageContext();
         try{
-            AddressingHelper.FinalFaults.triggerOnlyNonAnonymousAddressSupportedFault(messageContext,
"ReplyTo");
+            FinalFaultsHelper.triggerOnlyNonAnonymousAddressSupportedFault(messageContext,
"ReplyTo");
             fail("Should have thrown exception");
         }catch(AxisFault af){
             // Expected
@@ -97,12 +97,12 @@
     }
 
     /**
-     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerMessageAddressingRequiredFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     * Test method for {@link org.apache.axis2.addressing.FinalFaultsHelper#triggerMessageAddressingRequiredFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
      */
     public void testTriggerMessageAddressingRequiredFault() {
         MessageContext messageContext = new MessageContext();
         try{
-            AddressingHelper.FinalFaults.triggerMessageAddressingRequiredFault(messageContext,
"Action");
+            FinalFaultsHelper.triggerMessageAddressingRequiredFault(messageContext, "Action");
             fail("Should have thrown exception");
         }catch(AxisFault af){
             // Expected
@@ -114,18 +114,18 @@
     }
 
     /**
-     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerActionNotSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     * Test method for {@link org.apache.axis2.addressing.FinalFaultsHelper#triggerActionNotSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
      */
     public void testTriggerActionNotSupportedFault() {
         MessageContext messageContext = new MessageContext();
         try{
-            AddressingHelper.FinalFaults.triggerActionNotSupportedFault(messageContext, "http://incorrect/action");
+            FinalFaultsHelper.triggerActionNotSupportedFault(messageContext, "http://incorrect/action");
             fail("Should have thrown exception");
         }catch(AxisFault af){
             // Expected
             assertEquals(Final.FAULT_ACTION_NOT_SUPPORTED_REASON, af.getMessage());
             assertEquals(new QName(Final.WSA_NAMESPACE,Final.FAULT_ACTION_NOT_SUPPORTED),
af.getFaultCode());
-            assertEquals("http://incorrect/action", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get("PROBLEM_ACTION"));
+            assertEquals("http://incorrect/action", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(AddressingConstants.Final.FAULT_PROBLEM_ACTION_NAME));
             assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
         }
     }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java?rev=430782&r1=430781&r2=430782&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
Fri Aug 11 06:03:14 2006
@@ -108,6 +108,7 @@
         public static final String FAULT_ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED = "OnlyNonAnonymousAddressSupported";
         public static final String FAULT_ACTION_NOT_SUPPORTED = "ActionNotSupported";
         public static final String FAULT_ACTION_NOT_SUPPORTED_REASON = "The [action] cannot
be processed at the receiver.";
+        public static final String FAULT_PROBLEM_ACTION_NAME = "ProblemAction";
 
         public static final QName WSAW_USING_ADDRESSING = new QName(WSAW_NAMESPACE,USING_ADDRESSING);
         public static final QName WSAW_ANONYMOUS = new QName(WSAW_NAMESPACE,USING_ADDRESSING);

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java?rev=430782&r1=430781&r2=430782&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java
Fri Aug 11 06:03:14 2006
@@ -15,20 +15,7 @@
 */
 package org.apache.axis2.addressing;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.SOAPFaultCode;
-import org.apache.axiom.soap.SOAPFaultSubCode;
-import org.apache.axiom.soap.SOAPFaultValue;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.AddressingConstants.Final;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.Parameter;
@@ -150,104 +137,6 @@
                     log.debug("setAnonymousParameterValue: addParameter failed: "+af.getMessage());
                 }
             }
-        }
-    }
-    
-    public static class FinalFaults{
-        
-        private static final Log log = LogFactory.getLog(FinalFaults.class);
-        
-        //    wsa:InvalidAddressingHeader [Reason] the string: "A header representing a Message
Addressing Property is not valid and the message cannot be processed"
-        //      wsa:InvalidAddress
-        //      wsa:InvalidEPR
-        //      wsa:InvalidCardinality
-        public static void triggerInvalidCardinalityFault(MessageContext messageContext,
String incorrectHeaderName) throws AxisFault {
-            if(log.isDebugEnabled()){
-                log.debug("triggerInvalidCardinalityFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
-            }
-            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER,
"InvalidCardinality", Final.FAULT_INVALID_HEADER_REASON);
-        }
-
-        //      wsa:MissingAddressInEPR
-        //      wsa:DuplicateMessageID
-        //      wsa:ActionMismatch
-        public static void triggerActionMismatchFault(MessageContext messageContext) throws
AxisFault {
-            if(log.isDebugEnabled()){
-                log.debug("triggerActionMismatchFault: messageContext: "+messageContext);
-            }
-            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":"+"Action", Final.FAULT_INVALID_HEADER, "ActionMismatch",
Final.FAULT_INVALID_HEADER_REASON);
-        }
-
-        //      wsa:OnlyAnonymousAddressSupported
-        public static void triggerOnlyAnonymousAddressSupportedFault(MessageContext messageContext,
String incorrectHeaderName) throws AxisFault {
-            if(log.isDebugEnabled()){
-                log.debug("triggerOnlyAnonymousAddressSupportedFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
-            }
-            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER,
Final.FAULT_ONLY_ANONYMOUS_ADDRESS_SUPPORTED, Final.FAULT_INVALID_HEADER_REASON);
-        }
-
-        //      wsa:OnlyNonAnonymousAddressSupported
-        public static void triggerOnlyNonAnonymousAddressSupportedFault(MessageContext messageContext,
String incorrectHeaderName) throws AxisFault {
-            if(log.isDebugEnabled()){
-                log.debug("triggerOnlyNonAnonymousAddressSupportedFault: messageContext:
"+messageContext+" incorrectHeaderName: "+incorrectHeaderName);
-            }
-            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER,
Final.FAULT_ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED, Final.FAULT_INVALID_HEADER_REASON);
-        }
-
-        //    wsa:MessageAddressingHeaderRequired [Reason] the string: "A required header
representing a Message Addressing Property is not present"
-        public static void triggerMessageAddressingRequiredFault(MessageContext messageContext,
String missingHeaderName) throws AxisFault {
-            if(log.isDebugEnabled()){
-                log.debug("triggerMessageAddressingRequiredFault: messageContext: "+messageContext+"
missingHeaderName: "+missingHeaderName);
-            }
-            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + missingHeaderName, Final.FAULT_ADDRESSING_HEADER_REQUIRED,
null, Final.FAULT_ADDRESSING_HEADER_REQUIRED_REASON);
-        }
-
-        //    wsa:ActionNotSupported [Reason] the string: "The [action] cannot be processed
at the receiver"
-        public static void triggerActionNotSupportedFault(MessageContext messageContext,
String problemAction) throws AxisFault {
-            if(log.isDebugEnabled()){
-                log.debug("triggerActionNotSupportedFault: messageContext: "+messageContext+"
problemAction: "+problemAction);
-            }
-            triggerAddressingFault(messageContext, "PROBLEM_ACTION", problemAction, Final.FAULT_ACTION_NOT_SUPPORTED,
null, Final.FAULT_ACTION_NOT_SUPPORTED_REASON);
-        }
-        //    wsa:EndpointUnavailable [Reason] the string "The endpoint is unable to process
the message at this time"
-
-        private static void triggerAddressingFault(MessageContext messageContext, String
faultInformationKey, Object faultInformationValue, String faultcode, String faultSubcode,
String faultReason) throws AxisFault{
-            Map faultInformation = (Map) messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
-            if (faultInformation == null) {
-                faultInformation = new HashMap();
-                messageContext.setProperty(Constants.FAULT_INFORMATION_FOR_HEADERS, faultInformation);
-            }
-
-            if(messageContext.getMessageID() != null) {
-                faultInformation.put(AddressingConstants.WSA_RELATES_TO,messageContext.getMessageID());
-            }
-
-            faultInformation.put(Final.WSA_FAULT_ACTION, Final.WSA_FAULT_ACTION);
-            faultInformation.put(faultInformationKey, faultInformationValue);
-
-            if (!messageContext.isSOAP11()) {
-                setFaultCode(messageContext, faultcode, faultSubcode);
-            }
-
-            messageContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
Boolean.FALSE);
-            AxisFault fault = new AxisFault(faultReason, new QName(AddressingConstants.Final.WSA_NAMESPACE,faultcode));
-            throw fault;
-        }
-
-        private static void setFaultCode(MessageContext messageContext, String faultCode,
String faultSubCode) {
-            SOAPFactory soapFac = OMAbstractFactory.getSOAP12Factory();
-            SOAPFaultCode soapFaultCode = soapFac.createSOAPFaultCode();
-            SOAPFaultValue soapFaultValue = soapFac.createSOAPFaultValue(soapFaultCode);
-            soapFaultValue.setText(SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX + ":" +
SOAP12Constants.FAULT_CODE_SENDER);
-            SOAPFaultSubCode soapFaultSubCode = soapFac.createSOAPFaultSubCode(soapFaultCode);
-            SOAPFaultValue soapFaultSubcodeValue = soapFac.createSOAPFaultValue(soapFaultSubCode);
-            soapFaultSubcodeValue.setText(AddressingConstants.WSA_DEFAULT_PREFIX + ":" +
faultCode);
-            if (faultSubCode != null) {
-                SOAPFaultSubCode soapFaultSubCode2 = soapFac.createSOAPFaultSubCode(soapFaultSubCode);
-                SOAPFaultValue soapFaultSubcodeValue2 = soapFac.createSOAPFaultValue(soapFaultSubCode2);
-                soapFaultSubcodeValue2.setText(AddressingConstants.WSA_DEFAULT_PREFIX + ":"
+ faultSubCode);
-            }
-            messageContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, soapFaultCode);
         }
     }
 }



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


Mime
View raw message