jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r616082 - in /jackrabbit/trunk/jackrabbit-jcr-rmi/src: main/java/org/apache/jackrabbit/rmi/client/ main/java/org/apache/jackrabbit/rmi/xml/ test/java/org/apache/jackrabbit/rmi/
Date Mon, 28 Jan 2008 22:11:11 GMT
Author: jukka
Date: Mon Jan 28 14:11:10 2008
New Revision: 616082

URL: http://svn.apache.org/viewvc?rev=616082&view=rev
Log:
JCR-1343: Replace Xerces for serialization by JAXP
    - Use the new XML classes from jcr-commons

Removed:
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/xml/
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/test/java/org/apache/jackrabbit/rmi/
Modified:
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientSession.java
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientWorkspace.java

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientSession.java?rev=616082&r1=616081&r2=616082&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientSession.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientSession.java
Mon Jan 28 14:11:10 2008
@@ -41,8 +41,9 @@
 import javax.xml.transform.sax.SAXResult;
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.jackrabbit.commons.xml.DefaultContentHandler;
+import org.apache.jackrabbit.commons.xml.SerializingContentHandler;
 import org.apache.jackrabbit.rmi.remote.RemoteSession;
-import org.apache.jackrabbit.rmi.xml.SessionImportContentHandler;
 import org.apache.jackrabbit.rmi.value.SerialValueFactory;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
@@ -263,9 +264,25 @@
     }
 
     /** {@inheritDoc} */
-    public ContentHandler getImportContentHandler(String path, int mode)
-            throws RepositoryException {
-        return new SessionImportContentHandler(this, path, mode);
+    public ContentHandler getImportContentHandler(
+            final String path, final int mode) throws RepositoryException {
+        try {
+            final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+            ContentHandler handler =
+                SerializingContentHandler.getSerializer(buffer);
+            return new DefaultContentHandler(handler) {
+                public void endDocument() throws SAXException {
+                    super.endDocument();
+                    try {
+                        remote.importXML(path, buffer.toByteArray(), mode);
+                    } catch (Exception e) {
+                        throw new SAXException("XML import failed", e);
+                    }
+                }
+            };
+        } catch (SAXException e) {
+            throw new RepositoryException("XML serialization failed", e);
+        }
     }
 
     /** {@inheritDoc} */

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientWorkspace.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientWorkspace.java?rev=616082&r1=616081&r2=616082&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientWorkspace.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/ClientWorkspace.java
Mon Jan 28 14:11:10 2008
@@ -31,12 +31,14 @@
 import javax.jcr.query.QueryManager;
 import javax.jcr.version.Version;
 
+import org.apache.jackrabbit.commons.xml.DefaultContentHandler;
+import org.apache.jackrabbit.commons.xml.SerializingContentHandler;
 import org.apache.jackrabbit.rmi.remote.RemoteNamespaceRegistry;
 import org.apache.jackrabbit.rmi.remote.RemoteNodeTypeManager;
 import org.apache.jackrabbit.rmi.remote.RemoteQueryManager;
 import org.apache.jackrabbit.rmi.remote.RemoteWorkspace;
-import org.apache.jackrabbit.rmi.xml.WorkspaceImportContentHandler;
 import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
 
 /**
  * Local adapter for the JCR-RMI {@link RemoteWorkspace RemoteWorkspace}
@@ -193,9 +195,23 @@
 
     /** {@inheritDoc} */
     public ContentHandler getImportContentHandler(
-            String path, int uuidBehaviour)
-            throws RepositoryException {
-        return new WorkspaceImportContentHandler(this, path, uuidBehaviour);
+            final String path, final int mode) throws RepositoryException {
+        try {
+            final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+            return new DefaultContentHandler(
+                    SerializingContentHandler.getSerializer(buffer)) {
+                public void endDocument() throws SAXException {
+                    super.endDocument();
+                    try {
+                        remote.importXML(path, buffer.toByteArray(), mode);
+                    } catch (Exception e) {
+                        throw new SAXException("XML import failed", e);
+                    }
+                }
+            };
+        } catch (SAXException e) {
+            throw new RepositoryException("XML serialization failed", e);
+        }
     }
 
     /** {@inheritDoc} */



Mime
View raw message