jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r656199 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ xml/
Date Wed, 14 May 2008 09:52:18 GMT
Author: jukka
Date: Wed May 14 02:52:18 2008
New Revision: 656199

URL: http://svn.apache.org/viewvc?rev=656199&view=rev
Log:
JCR-1579: Improved XML export handling
    - Drop XML export functionality from jcr2spi, use the one in jcr-commons instead

Removed:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/AbstractSAXEventGenerator.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/DocViewSAXEventGenerator.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewSAXEventGenerator.java
Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=656199&r1=656198&r2=656199&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Wed May 14 02:52:18 2008
@@ -30,8 +30,6 @@
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
-import org.apache.jackrabbit.jcr2spi.xml.DocViewSAXEventGenerator;
-import org.apache.jackrabbit.jcr2spi.xml.SysViewSAXEventGenerator;
 import org.apache.jackrabbit.jcr2spi.xml.ImportHandler;
 import org.apache.jackrabbit.jcr2spi.xml.SessionImporter;
 import org.apache.jackrabbit.jcr2spi.xml.Importer;
@@ -86,18 +84,12 @@
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.version.VersionException;
 import javax.jcr.version.Version;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.TransformerException;
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.ParserConfigurationException;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.security.AccessControlException;
 import java.util.Map;
 
@@ -423,72 +415,6 @@
     }
 
     /**
-     * @see javax.jcr.Session#exportSystemView(String, org.xml.sax.ContentHandler, boolean,
boolean)
-     */
-    public void exportSystemView(String absPath, ContentHandler contentHandler, boolean skipBinary,
boolean noRecurse) throws PathNotFoundException, SAXException, RepositoryException {
-        checkIsAlive();
-        Item item = getItem(absPath);
-        if (!item.isNode()) {
-            // a property instead of a node exists at the specified path
-            throw new PathNotFoundException(absPath);
-        }
-        new SysViewSAXEventGenerator((Node)item, noRecurse, skipBinary, contentHandler).serialize();
-    }
-
-    /**
-     * @see javax.jcr.Session#exportSystemView(String, OutputStream, boolean, boolean)
-     */
-    public void exportSystemView(String absPath, OutputStream out, boolean skipBinary, boolean
noRecurse) throws IOException, PathNotFoundException, RepositoryException {
-        SAXTransformerFactory stf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
-        try {
-            TransformerHandler th = stf.newTransformerHandler();
-            th.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
-            th.getTransformer().setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-            th.getTransformer().setOutputProperty(OutputKeys.INDENT, "no");
-            th.setResult(new StreamResult(out));
-
-            exportSystemView(absPath, th, skipBinary, noRecurse);
-        } catch (TransformerException te) {
-            throw new RepositoryException(te);
-        } catch (SAXException se) {
-            throw new RepositoryException(se);
-        }
-    }
-
-    /**
-     * @see javax.jcr.Session#exportDocumentView(String, org.xml.sax.ContentHandler, boolean,
boolean)
-     */
-    public void exportDocumentView(String absPath, ContentHandler contentHandler, boolean
skipBinary, boolean noRecurse) throws InvalidSerializedDataException, PathNotFoundException,
SAXException, RepositoryException {
-        checkIsAlive();
-        Item item = getItem(absPath);
-        if (!item.isNode()) {
-            // a property instead of a node exists at the specified path
-            throw new PathNotFoundException(absPath);
-        }
-        new DocViewSAXEventGenerator((Node) item, noRecurse, skipBinary, contentHandler).serialize();
-    }
-
-    /**
-     * @see javax.jcr.Session#exportDocumentView(String, OutputStream, boolean, boolean)
-     */
-    public void exportDocumentView(String absPath, OutputStream out, boolean skipBinary,
boolean noRecurse) throws InvalidSerializedDataException, IOException, PathNotFoundException,
RepositoryException {
-        SAXTransformerFactory stf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
-        try {
-            TransformerHandler th = stf.newTransformerHandler();
-            th.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
-            th.getTransformer().setOutputProperty(OutputKeys.ENCODING, "UTF-8");
-            th.getTransformer().setOutputProperty(OutputKeys.INDENT, "no");
-            th.setResult(new StreamResult(out));
-
-            exportDocumentView(absPath, th, skipBinary, noRecurse);
-        } catch (TransformerException te) {
-            throw new RepositoryException(te);
-        } catch (SAXException se) {
-            throw new RepositoryException(se);
-        }
-    }
-
-    /**
      * @see javax.jcr.Session#setNamespacePrefix(String, String)
      */
     public void setNamespacePrefix(String prefix, String uri)

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java?rev=656199&r1=656198&r2=656199&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SysViewImportHandler.java
Wed May 14 02:52:18 2008
@@ -37,6 +37,21 @@
  */
 class SysViewImportHandler extends TargetImportHandler {
 
+    /** Local part of <code>sv:node</code>. */
+    private static final String NODE = "node";
+
+    /** Local part of <code>sv:property</code>. */
+    private static final String PROPERTY = "property";
+
+    /** Local part of <code>sv:value</code>. */
+    private static final String VALUE = "value";
+
+    /** Local part of <code>sv:name</code>. */
+    private static final String NAME = "name";
+
+    /** Local part of <code>sv:type</code>. */
+    private static final String TYPE = "type";
+
     /**
      * stack of ImportState instances; an instance is pushed onto the stack
      * in the startElement method every time a sv:node element is encountered;
@@ -109,11 +124,11 @@
                     + namespaceURI));
         }
         // check element name
-        if (SysViewSAXEventGenerator.NODE_ELEMENT.equals(localName)) {
+        if (NODE.equals(localName)) {
             // sv:node element
 
             // node name (value of sv:name attribute)
-            String name = atts.getValue(SysViewSAXEventGenerator.PREFIXED_NAME_ATTRIBUTE);
+            String name = atts.getValue(Name.NS_SV_URI, NAME);
             if (name == null) {
                 throw new SAXException(new InvalidSerializedDataException(
                         "missing mandatory sv:name attribute of element sv:node"));
@@ -139,14 +154,14 @@
                 throw new SAXException(new InvalidSerializedDataException("illegal node name:
" + name, e));
             }
             stack.push(state);
-        } else if (SysViewSAXEventGenerator.PROPERTY_ELEMENT.equals(localName)) {
+        } else if (PROPERTY.equals(localName)) {
             // sv:property element
 
             // reset temp fields
             currentPropValues.clear();
 
             // property name (value of sv:name attribute)
-            String name = atts.getValue(SysViewSAXEventGenerator.PREFIXED_NAME_ATTRIBUTE);
+            String name = atts.getValue(Name.NS_SV_URI, NAME);
             if (name == null) {
                 throw new SAXException(new InvalidSerializedDataException(
                         "missing mandatory sv:name attribute of element sv:property"));
@@ -159,13 +174,13 @@
                 throw new SAXException(new InvalidSerializedDataException("illegal property
name: " + name, e));
             }
             // property type (sv:type attribute)
-            String type = atts.getValue(SysViewSAXEventGenerator.PREFIXED_TYPE_ATTRIBUTE);
+            String type = atts.getValue(Name.NS_SV_URI, TYPE);
             if (type == null) {
                 throw new SAXException(new InvalidSerializedDataException(
                         "missing mandatory sv:type attribute of element sv:property"));
             }
             currentPropType = PropertyType.valueFromName(type);
-        } else if (SysViewSAXEventGenerator.VALUE_ELEMENT.equals(localName)) {
+        } else if (VALUE.equals(localName)) {
             // sv:value element
 
             // reset temp fields
@@ -218,7 +233,7 @@
             throws SAXException {
         // check element name
         ImportState state = (ImportState) stack.peek();
-        if (SysViewSAXEventGenerator.NODE_ELEMENT.equals(localName)) {
+        if (NODE.equals(localName)) {
             // sv:node element
             if (!state.started) {
                 // need to start & end current node
@@ -230,7 +245,7 @@
             }
             // pop current state from stack
             stack.pop();
-        } else if (SysViewSAXEventGenerator.PROPERTY_ELEMENT.equals(localName)) {
+        } else if (PROPERTY.equals(localName)) {
             // sv:property element
 
             // check if all system properties (jcr:primaryType, jcr:uuid etc.)
@@ -282,7 +297,7 @@
             }
             // reset temp fields
             currentPropValues.clear();
-        } else if (SysViewSAXEventGenerator.VALUE_ELEMENT.equals(localName)) {
+        } else if (VALUE.equals(localName)) {
             // sv:value element
             currentPropValues.add(currentPropValue);
             // reset temp fields



Mime
View raw message