jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r935544 - in /jackrabbit/trunk: jackrabbit-jcr-server/pom.xml jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java jackrabbit-parent/pom.xml jackrabbit-spi2dav/pom.xml
Date Mon, 19 Apr 2010 12:47:53 GMT
Author: jukka
Date: Mon Apr 19 12:47:52 2010
New Revision: 935544

URL: http://svn.apache.org/viewvc?rev=935544&view=rev
Log:
JCR-2344: ClassCastException org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot
be cast to org.apache.xerces.xni.parser.XMLParserConfiguration when deploying in JBoss 5.1

Replace our last Xerces dependency with the SerializingContentHandler class.

Tested against regressions with the litmus and jcr2dav test suites.

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/pom.xml
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
    jackrabbit/trunk/jackrabbit-parent/pom.xml
    jackrabbit/trunk/jackrabbit-spi2dav/pom.xml

Modified: jackrabbit/trunk/jackrabbit-jcr-server/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/pom.xml?rev=935544&r1=935543&r2=935544&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/pom.xml Mon Apr 19 12:47:52 2010
@@ -72,10 +72,6 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
     <dependency>
-      <groupId>xerces</groupId>
-      <artifactId>xercesImpl</artifactId>
-    </dependency>
-    <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
       <scope>provided</scope>

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java?rev=935544&r1=935543&r2=935544&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
Mon Apr 19 12:47:52 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
+import org.apache.jackrabbit.commons.xml.SerializingContentHandler;
 import org.apache.jackrabbit.server.io.IOUtil;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
@@ -37,20 +38,27 @@ import org.apache.jackrabbit.webdav.prop
 import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
 import org.apache.jackrabbit.webdav.property.PropEntry;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
 
+import javax.jcr.Binary;
 import javax.jcr.Item;
 import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
-import javax.jcr.ValueFormatException;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -116,35 +124,55 @@ public class DefaultItemResource extends
         // write properties
         super.spool(outputContext);
         // spool content
-        InputStream in = null;
+        OutputStream out = outputContext.getOutputStream();
+        if (out != null && exists()) {
+            if (isMultiple()) {
+                spoolMultiValued(out);
+            } else {
+                spoolSingleValued(out);
+            }
+        }
+    }
+
+    private void spoolMultiValued(OutputStream out) {
         try {
-            OutputStream out = outputContext.getOutputStream();
-            if (out != null && exists()) {
-                if (isMultiple()) {
-                    Document doc = DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
-                    doc.appendChild(getProperty(JCR_VALUES).toXml(doc));
-                    OutputFormat format = new OutputFormat("xml", "UTF-8", false);
-                    XMLSerializer serializer = new XMLSerializer(out, format);
-                    serializer.setNamespaces(true);
-                    serializer.asDOMSerializer().serialize(doc);
-                } else {
-                    in = ((Property)item).getStream();
-                    if (in != null) {
-                        IOUtil.spool(in, out);
-                    }
+            Document doc =
+                DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
+            doc.appendChild(getProperty(JCR_VALUES).toXml(doc));
+
+            ContentHandler handler =
+                SerializingContentHandler.getSerializer(out);
+
+            Transformer transformer =
+                TransformerFactory.newInstance().newTransformer();
+            transformer.transform(
+                    new DOMSource(doc), new SAXResult(handler));
+        } catch (SAXException e) {
+            log.error("Failed to set up XML serializer for " + item, e);
+        } catch (TransformerConfigurationException e) {
+            log.error("Failed to set up XML transformer for " + item, e);
+        } catch (ParserConfigurationException e) {
+            log.error("Failed to set up XML document for " + item, e);
+        } catch (TransformerException e) {
+            log.error("Failed to serialize the values of " + item, e);
+        }
+    }
+
+    private void spoolSingleValued(OutputStream out) throws IOException {
+        try {
+            Binary binary = ((Property) item).getBinary();
+            try {
+                InputStream in = binary.getStream();
+                try {
+                    IOUtil.spool(in, out);
+                } finally {
+                    in.close();
                 }
+            } finally {
+                binary.dispose();
             }
-        } catch (ParserConfigurationException e) {
-            log.error("Error while spooling multivalued resource: " + e.getMessage());
-        } catch (ValueFormatException e) {
-            // should not occur
-            log.error("Cannot obtain stream from resource: " + e.getMessage());
         } catch (RepositoryException e) {
-            log.error("Cannot obtain stream from resource: " + e.getMessage());
-        } finally {
-            if (in != null) {
-                in.close();
-            }
+            log.error("Cannot obtain stream from " + item, e);
         }
     }
 
@@ -228,7 +256,7 @@ public class DefaultItemResource extends
                 // altering any properties fails if an attempt is made to remove
                 // a property
                 throw new DavException(DavServletResponse.SC_FORBIDDEN);
-            } else if (propEntry instanceof DavProperty) {
+            } else if (propEntry instanceof DavProperty<?>) {
                 DavProperty<?> prop = (DavProperty<?>) propEntry;
                 internalSetProperty(prop);
             } else {

Modified: jackrabbit/trunk/jackrabbit-parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-parent/pom.xml?rev=935544&r1=935543&r2=935544&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-parent/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-parent/pom.xml Mon Apr 19 12:47:52 2010
@@ -305,11 +305,6 @@
         <version>${jetty.version}</version>
       </dependency>
       <dependency>
-        <groupId>xerces</groupId>
-        <artifactId>xercesImpl</artifactId>
-        <version>2.9.0</version>
-      </dependency>
-      <dependency>
         <groupId>cglib</groupId>
         <artifactId>cglib</artifactId>
         <version>2.1_3</version>

Modified: jackrabbit/trunk/jackrabbit-spi2dav/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/pom.xml?rev=935544&r1=935543&r2=935544&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/pom.xml Mon Apr 19 12:47:52 2010
@@ -156,10 +156,6 @@
       <version>2.2-SNAPSHOT</version>
       <exclusions>
         <exclusion>
-          <groupId>xerces</groupId>
-          <artifactId>xercesImpl</artifactId>
-        </exclusion>
-        <exclusion>
           <groupId>org.apache.tika</groupId>
           <artifactId>tika-core</artifactId>
         </exclusion>



Mime
View raw message