You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by hi...@apache.org on 2013/09/07 21:43:04 UTC

svn commit: r1520794 - in /synapse/trunk/java/modules: core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java integration/src/test/java/org/apache/synapse/samples/framework/tests/message/Sample7.java

Author: hiranya
Date: Sat Sep  7 19:43:04 2013
New Revision: 1520794

URL: http://svn.apache.org/r1520794
Log:
Fixing a bug in validate mediator. Patch applied from SYNAPSE-976

Modified:
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java
    synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/message/Sample7.java

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java?rev=1520794&r1=1520793&r2=1520794&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java Sat Sep  7 19:43:04 2013
@@ -144,14 +144,13 @@ public class ValidateMediator extends Ab
                 }
                 // load the UserDefined SchemaURIResolver implementations
                 try {
-                	SynapseConfiguration synCfg = synCtx.getConfiguration();
-                	if(synCfg.getProperty(SynapseConstants.SYNAPSE_SCHEMA_RESOLVER) !=null){
-                		setUserDefinedSchemaResourceResolver(synCtx);
-                	}
-                	else{
-                		factory.setResourceResolver(
-                		                            new SchemaResourceResolver(synCtx.getConfiguration(), resourceMap));
-                	}
+                    SynapseConfiguration synCfg = synCtx.getConfiguration();
+                    if (synCfg.getProperty(SynapseConstants.SYNAPSE_SCHEMA_RESOLVER) != null) {
+                        setUserDefinedSchemaResourceResolver(synCtx);
+                    } else {
+                        factory.setResourceResolver(
+                                new SchemaResourceResolver(synCtx.getConfiguration(), resourceMap));
+                    }
                     cachedSchema = factory.newSchema(sources);
                 } catch (SAXException e) {
                     handleException("Error creating a new schema objects for " +
@@ -183,9 +182,9 @@ public class ValidateMediator extends Ab
 
                 if (synLog.isTraceOrDebugEnabled()) {
                     String msg = "Validation of element returned by XPath : " + source +
-                        " failed against the given schema(s) " + schemaKeys +
-                        "with error : " + errorHandler.getSaxParseException().getMessage() +
-                        " Executing 'on-fail' sequence";
+                            " failed against the given schema(s) " + schemaKeys +
+                            "with error : " + errorHandler.getSaxParseException().getMessage() +
+                            " Executing 'on-fail' sequence";
                     synLog.traceOrDebug(msg);
 
                     // write a warning to the service log
@@ -198,11 +197,11 @@ public class ValidateMediator extends Ab
 
                 // set error message and detail (stack trace) into the message context
                 synCtx.setProperty(SynapseConstants.ERROR_MESSAGE,
-                    errorHandler.getSaxParseException().getMessage());
+                        errorHandler.getSaxParseException().getMessage());
                 synCtx.setProperty(SynapseConstants.ERROR_EXCEPTION,
-                    errorHandler.getSaxParseException());
+                        errorHandler.getSaxParseException());
                 synCtx.setProperty(SynapseConstants.ERROR_DETAIL,
-                    FaultHandler.getStackTrace(errorHandler.getSaxParseException()));
+                        FaultHandler.getStackTrace(errorHandler.getSaxParseException()));
 
                 // super.mediate() invokes the "on-fail" sequence of mediators
                 return super.mediate(synCtx);
@@ -215,7 +214,7 @@ public class ValidateMediator extends Ab
 
         if (synLog.isTraceOrDebugEnabled()) {
             synLog.traceOrDebug("Validation of element returned by the XPath expression : "
-                + source + " succeeded against the given schemas and the current message");
+                    + source + " succeeded against the given schemas and the current message");
             synLog.traceOrDebug("End : Validate mediator");
         }
 
@@ -224,7 +223,7 @@ public class ValidateMediator extends Ab
 
     /**
      * UserDefined schema resource resolver
-
+     *
      * @param synCtx message context
      */
     private void setUserDefinedSchemaResourceResolver(MessageContext synCtx) {
@@ -254,12 +253,12 @@ public class ValidateMediator extends Ab
             handleException(msg, e, synCtx);
         }
     }
-    
+
     /**
      * Get the validation Source for the message context
      *
      * @param synCtx the current message to validate
-     * @param synLog  SynapseLog instance
+     * @param synLog SynapseLog instance
      * @return the validation Source for the current message
      */
     private Source getValidationSource(MessageContext synCtx, SynapseLog synLog) {
@@ -309,7 +308,8 @@ public class ValidateMediator extends Ab
 
         /**
          * To set explicitly validation error condition
-         * @param validationError  is occur validation error?
+         *
+         * @param validationError is occur validation error?
          */
         public void setValidationError(boolean validationError) {
             this.validationError = validationError;
@@ -337,12 +337,12 @@ public class ValidateMediator extends Ab
     /**
      * add a feature which need to set for the Schema Factory
      *
-     * @param  featureName The name of the feature
+     * @param featureName     The name of the feature
      * @param isFeatureEnable should this feature enable?(true|false)
-     * @see #getFeature(String)
      * @throws SAXException on an unknown feature
+     * @see #getFeature(String)
      */
-   public void addFeature(String featureName, boolean isFeatureEnable) throws SAXException {
+    public void addFeature(String featureName, boolean isFeatureEnable) throws SAXException {
         MediatorProperty mp = new MediatorProperty();
         mp.setName(featureName);
         if (isFeatureEnable) {
@@ -366,15 +366,17 @@ public class ValidateMediator extends Ab
 
     /**
      * Set the given XPath as the source XPath
+     *
      * @param source an XPath to be set as the source
      */
     public void setSource(SynapseXPath source) {
-       this.source.setXPath(source);
+        this.source.setXPath(source);
     }
 
     /**
      * Set the External Schema ResourceMap that will required for schema validation
-     * @param resourceMap  the ResourceMap which contains external schema resources
+     *
+     * @param resourceMap the ResourceMap which contains external schema resources
      */
     public void setResourceMap(ResourceMap resourceMap) {
         this.resourceMap = resourceMap;
@@ -382,6 +384,7 @@ public class ValidateMediator extends Ab
 
     /**
      * Get the source XPath which yields the source element for validation
+     *
      * @return the XPath which yields the source element for validation
      */
     public SynapseXPath getSource() {
@@ -390,6 +393,7 @@ public class ValidateMediator extends Ab
 
     /**
      * The keys for the schema resources used for validation
+     *
      * @return schema registry keys
      */
     public List<Value> getSchemaKeys() {
@@ -398,18 +402,24 @@ public class ValidateMediator extends Ab
 
     /**
      * Features for the actual Xerces validator
-     * @return explicityFeatures to be passed to the Xerces validator
+     *
+     * @return explicit Features to be passed to the Xerces validator
      */
     public List<MediatorProperty> getFeatures() {
         return explicityFeatures;
     }
 
     /**
-     *ResourceMap for the external schema resources to be used for the validation
+     * ResourceMap for the external schema resources to be used for the validation
+     *
      * @return the ResourceMap with external schema resources
      */
     public ResourceMap getResourceMap() {
         return resourceMap;
     }
 
+    @Override
+    public boolean isContentAware() {
+        return true;
+    }
 }

Modified: synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/message/Sample7.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/message/Sample7.java?rev=1520794&r1=1520793&r2=1520794&view=diff
==============================================================================
--- synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/message/Sample7.java (original)
+++ synapse/trunk/java/modules/integration/src/test/java/org/apache/synapse/samples/framework/tests/message/Sample7.java Sat Sep  7 19:43:04 2013
@@ -30,7 +30,6 @@ public class Sample7 extends SynapseTest
         super(7);
     }
 
-
     public void testLocalRegEntriesAndSchemaValidation() {
         String addUrl = "http://localhost:9000/services/SimpleStockQuoteService";
         String trpUrl = "http://localhost:8280";