cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [2/3] cxf git commit: [CXF-7469] Update DocLiteralInInterceptor to make sure @SchemaValidation on the operation level can be used
Date Fri, 11 Aug 2017 20:41:14 GMT
[CXF-7469] Update DocLiteralInInterceptor to make sure @SchemaValidation on the operation level
can be used


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/74e2b090
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/74e2b090
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/74e2b090

Branch: refs/heads/master
Commit: 74e2b090c612b4b83e17c3122dbe8b5bd3383785
Parents: 38c08dd
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Aug 11 15:00:04 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Aug 11 16:41:02 2017 -0400

----------------------------------------------------------------------
 .../validation/DefaultSchemaValidationTypeProvider.java |  6 +++++-
 .../main/java/org/apache/cxf/helpers/ServiceUtils.java  | 12 ++++++++++--
 .../java/org/apache/cxf/service/model/SchemaInfo.java   |  2 +-
 .../cxf/wsdl/interceptors/DocLiteralInInterceptor.java  |  2 +-
 .../schemavalidation/JavaFirstSchemaValidationTest.java | 11 +++++++++--
 5 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/74e2b090/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java
b/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java
index 8490c56..7f8a157 100644
--- a/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java
+++ b/core/src/main/java/org/apache/cxf/feature/validation/DefaultSchemaValidationTypeProvider.java
@@ -39,6 +39,10 @@ public class DefaultSchemaValidationTypeProvider implements SchemaValidationType
 
     @Override
     public SchemaValidationType getSchemaValidationType(OperationInfo info) {
-        return operationMap.get(info.getName().getLocalPart());
+        SchemaValidationType t = operationMap.get(info.getName().getLocalPart());
+        if (t == null) {
+            t = operationMap.get("*");
+        }
+        return t;
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/74e2b090/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java b/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
index 1946082..a4537a2 100644
--- a/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
@@ -81,7 +81,12 @@ public final class ServiceUtils {
         if (validationType == null) {
             validationType = getSchemaValidationTypeFromModel(message);
         }
-
+        if (validationType == null) {
+            Object obj = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
+            if (obj != null) {
+                validationType = getSchemaValidationType(obj);
+            }
+        }
         if (validationType == null) {
             validationType = SchemaValidationType.NONE;
         }
@@ -90,7 +95,10 @@ public final class ServiceUtils {
     }
 
     private static SchemaValidationType getOverrideSchemaValidationType(Message message)
{
-        Object obj = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
+        Object obj = message.get(Message.SCHEMA_VALIDATION_ENABLED);
+        if (obj == null && message.getExchange() != null) {
+            obj = message.getExchange().get(Message.SCHEMA_VALIDATION_ENABLED);
+        }
         if (obj != null) {
             // this method will transform the legacy enabled as well
             return getSchemaValidationType(obj);

http://git-wip-us.apache.org/repos/asf/cxf/blob/74e2b090/core/src/main/java/org/apache/cxf/service/model/SchemaInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/service/model/SchemaInfo.java b/core/src/main/java/org/apache/cxf/service/model/SchemaInfo.java
index d67ab8d..7d604bf 100644
--- a/core/src/main/java/org/apache/cxf/service/model/SchemaInfo.java
+++ b/core/src/main/java/org/apache/cxf/service/model/SchemaInfo.java
@@ -112,7 +112,7 @@ public final class SchemaInfo extends AbstractPropertiesHolder {
             element = serializedSchema.getDocumentElement();
             cachedElement = new SoftReference<Element>(element);
         }
-        // XXX A problem can occur with the ibm jdk when the XmlSchema
+        // A problem can occur with the ibm jdk when the XmlSchema
         // object is serialized. The xmlns declaration gets incorrectly
         // set to the same value as the targetNamespace attribute.
         // The aegis databinding tests demonstrate this particularly.

http://git-wip-us.apache.org/repos/asf/cxf/blob/74e2b090/rt/wsdl/src/main/java/org/apache/cxf/wsdl/interceptors/DocLiteralInInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/interceptors/DocLiteralInInterceptor.java
b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/interceptors/DocLiteralInInterceptor.java
index 60f406f..1df918d 100644
--- a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/interceptors/DocLiteralInInterceptor.java
+++ b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/interceptors/DocLiteralInInterceptor.java
@@ -69,7 +69,6 @@ public class DocLiteralInInterceptor extends AbstractInDatabindingInterceptor
{
         }
 
         DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
-        DataReader<XMLStreamReader> dr = getDataReader(message);
         MessageContentsList parameters = new MessageContentsList();
 
         Exchange exchange = message.getExchange();
@@ -90,6 +89,7 @@ public class DocLiteralInInterceptor extends AbstractInDatabindingInterceptor
{
         if (bop != null && bop.getBinding() != null) {
             forceDocLitBare = Boolean.TRUE.equals(bop.getBinding().getService().getProperty("soap.force.doclit.bare"));
         }
+        DataReader<XMLStreamReader> dr = getDataReader(message);
 
         try {
             if (!forceDocLitBare && bop != null && bop.isUnwrappedCapable())
{

http://git-wip-us.apache.org/repos/asf/cxf/blob/74e2b090/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
index b2bfd96..84394e6 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
@@ -66,7 +66,8 @@ public class JavaFirstSchemaValidationTest extends Assert {
         createServer(PORT, PersonService.class, new PersonServiceImpl(), null, createSchemaValidationFeature());
 
         createServer(PORT2, PersonServiceWithRequestResponseAnns.class,
-                new PersonServiceWithRequestResponseAnnsImpl(), SchemaValidationType.NONE);
+                new PersonServiceWithRequestResponseAnnsImpl(), SchemaValidationType.NONE,
+                    createNoSchemaValidationFeature());
 
         createServer(PORT, PersonServiceAnnotated.class, new PersonServiceAnnotatedImpl(),
null);
 
@@ -94,6 +95,12 @@ public class JavaFirstSchemaValidationTest extends Assert {
         DefaultSchemaValidationTypeProvider provider = new DefaultSchemaValidationTypeProvider(operationMap);
         return new SchemaValidationFeature(provider);
     }
+    private static SchemaValidationFeature createNoSchemaValidationFeature() {
+        Map<String, SchemaValidationType> operationMap = new HashMap<>();
+        operationMap.put("*", SchemaValidationType.NONE);
+        DefaultSchemaValidationTypeProvider provider = new DefaultSchemaValidationTypeProvider(operationMap);
+        return new SchemaValidationFeature(provider);
+    }
 
     @AfterClass
     public static void cleanup() throws Exception {
@@ -319,7 +326,7 @@ public class JavaFirstSchemaValidationTest extends Assert {
             noValidationServerClient.saveValidateIn(person);
             fail("Expected exception");
         } catch (SOAPFaultException e) {
-            assertTrue(e.getMessage().contains("Unmarshalling Error"));
+            assertTrue(e.getMessage(), e.getMessage().contains("Unmarshalling Error"));
         }
 
         person.setFirstName(""); // empty string is valid


Mime
View raw message