cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r695970 - in /cxf/branches/2.0.x-fixes: ./ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/ systests/src/test/java/org/apache/cxf/systest/mtom/
Date Tue, 16 Sep 2008 16:36:34 GMT
Author: dkulp
Date: Tue Sep 16 09:36:33 2008
New Revision: 695970

URL: http://svn.apache.org/viewvc?rev=695970&view=rev
Log:
Merged revisions 695940 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.1.x-fixes

................
  r695940 | dkulp | 2008-09-16 11:33:53 -0400 (Tue, 16 Sep 2008) | 10 lines
  
  Merged revisions 695935 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r695935 | dkulp | 2008-09-16 11:19:19 -0400 (Tue, 16 Sep 2008) | 3 lines
    
    [CXF-1194] Ignore the validation errors caused by mtom attachments.
    Also add the ability to register your own custom validation handlers
  ........
................

Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
    cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 16 09:36:33 2008
@@ -1,3 +1,3 @@
-/cxf/branches/2.1.x-fixes:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891,678893,679248,679597,680435,681060,681165,681813,681816,682902,682951,683089,683290,683318,684099,684790-684793,684842,684862,684895-684918,685205,685253,686237,686283,686299,686333-686364,686765,686827,687097,687464-687465,689109,689112,689122,691316,691357,691491,691711,691715,691745,692162-692163,692468,692500,694466-694469,694472,694717,694748-694749,694870,695503,695509,695553,695555,695563,695875-695877
-/cxf/trunk:651669-686342,686344-686363,686764,686820,687096,687387,687463,688086,688102,688735,691271,691355,691488,691602,691706,691728,692116,692157,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694869,695396,695484,695537,695552,695561,695619,695684,695835
+/cxf/branches/2.1.x-fixes:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891,678893,679248,679597,680435,681060,681165,681813,681816,682902,682951,683089,683290,683318,684099,684790-684793,684842,684862,684895-684918,685205,685253,686237,686283,686299,686333-686364,686765,686827,687097,687464-687465,689109,689112,689122,691316,691357,691491,691711,691715,691745,692162-692163,692468,692500,694466-694469,694472,694717,694748-694749,694870,695503,695509,695553,695555,695563,695875-695877,695940
+/cxf/trunk:651669-686342,686344-686363,686764,686820,687096,687387,687463,688086,688102,688735,691271,691355,691488,691602,691706,691728,692116,692157,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694869,695396,695484,695537,695552,695561,695619,695684,695835,695935
 /incubator/cxf/trunk:434594-651668

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=695970&r1=695969&r2=695970&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Tue Sep 16 09:36:33 2008
@@ -45,6 +45,8 @@
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.PropertyException;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.ValidationEvent;
+import javax.xml.bind.ValidationEventHandler;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
@@ -67,6 +69,7 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxb.attachment.JAXBAttachmentMarshaller;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -109,6 +112,29 @@
         return jm;
     }
 
+    private static class MtomValidationHandler implements ValidationEventHandler {
+        ValidationEventHandler origHandler;
+        JAXBAttachmentMarshaller marshaller;
+        public MtomValidationHandler(ValidationEventHandler v,
+                                     JAXBAttachmentMarshaller m) {
+            origHandler = v;
+            marshaller = m;
+        }
+        
+        public boolean handleEvent(ValidationEvent event) {
+            String msg = event.getMessage();
+            if (msg.startsWith("cvc-type.3.1.2: ")
+                && msg.contains(marshaller.getLastMTOMElementName().getLocalPart()))
{
+                return true;
+            }
+            if (origHandler != null) {
+                return origHandler.handleEvent(event);
+            }
+            return false;
+        }
+        
+    }
+
     @SuppressWarnings("unchecked")
     public static void marshall(JAXBContext context, 
                                 Schema schema, 
@@ -148,6 +174,11 @@
             }
             u.setSchema(schema);
             if (am != null) {
+                if (am instanceof JAXBAttachmentMarshaller) {
+                    //we need a special even handler for XOP attachments 
+                    u.setEventHandler(new MtomValidationHandler(u.getEventHandler(),
+                                                                (JAXBAttachmentMarshaller)am));
+                }
                 u.setAttachmentMarshaller(am);
             }
 

Modified: cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java?rev=695970&r1=695969&r2=695970&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
Tue Sep 16 09:36:33 2008
@@ -29,6 +29,7 @@
 import javax.activation.DataSource;
 import javax.activation.FileDataSource;
 import javax.xml.bind.attachment.AttachmentMarshaller;
+import javax.xml.namespace.QName;
 
 import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.attachment.AttachmentUtil;
@@ -41,6 +42,7 @@
     private static final int THRESHOLD = 5 * 1024;
     private Collection<Attachment> atts;
     private boolean isXop;
+    private QName lastElementName;
 
     public JAXBAttachmentMarshaller(Collection<Attachment> attachments) {
         super();
@@ -48,6 +50,10 @@
         atts = attachments;
         isXop = attachments != null;
     }
+    
+    public QName getLastMTOMElementName() {
+        return lastElementName;
+    }
 
     public String addMtomAttachment(byte[] data, int offset, int length, String mimeType,
String elementNS,
                                     String elementLocalName) {
@@ -76,6 +82,7 @@
         att.setXOP(this.isXop);
         atts.add(att);
 
+        lastElementName = new QName(elementNS, elementLocalName);
         return "cid:" + id;
     }
 
@@ -117,6 +124,7 @@
         AttachmentImpl att = new AttachmentImpl(id, handler);
         att.setXOP(this.isXop);
         atts.add(att);
+        lastElementName = new QName(elementNS, elementLocalName);
 
         return "cid:" + id;
     }

Modified: cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java?rev=695970&r1=695969&r2=695970&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
(original)
+++ cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
Tue Sep 16 09:36:33 2008
@@ -114,6 +114,9 @@
                                                                                 fileSize);
             }
             
+            ((BindingProvider)mtomPort).getRequestContext().put("schema-validation-enabled",
+                                                                Boolean.TRUE);
+            
             param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
             Holder<String> name = new Holder<String>("call detail");
             mtomPort.testXop(name, param);



Mime
View raw message