jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1404046 - /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/XmlImportHandler.java
Date Wed, 31 Oct 2012 09:13:52 GMT
Author: mreutegg
Date: Wed Oct 31 09:13:51 2012
New Revision: 1404046

URL: http://svn.apache.org/viewvc?rev=1404046&view=rev
Log:
OAK-127: Support for XML imports
- create node when primary node type is known. otherwise addNode() without node type name
may throw a ConstraintViolationException because there is no child node definition with a
default node type

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/XmlImportHandler.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/XmlImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/XmlImportHandler.java?rev=1404046&r1=1404045&r2=1404046&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/XmlImportHandler.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/XmlImportHandler.java
Wed Oct 31 09:13:51 2012
@@ -30,6 +30,8 @@ public class XmlImportHandler extends De
 
     private Node node;
 
+    private String nodeName;
+
     private String name;
 
     private final List<String> values = new ArrayList<String>();
@@ -47,11 +49,8 @@ public class XmlImportHandler extends De
         if ("http://www.jcp.org/jcr/sv/1.0".equals(uri)) {
             String value = atts.getValue("sv:name");
             if ("node".equals(localName)) {
-                try {
-                    node = node.addNode(value);
-                } catch (RepositoryException e) {
-                    throw new SAXException(e);
-                }
+                // create node on jcr:primaryType sv:property
+                nodeName = value;
             } else if (value != null) {
                 name = value;
             }
@@ -79,7 +78,11 @@ public class XmlImportHandler extends De
             try {
                 if (values.size() == 1) {
                     if (name.equals("jcr:primaryType")) {
-                        node.setPrimaryType(values.get(0));
+                        try {
+                            node = node.addNode(nodeName, values.get(0));
+                        } catch (RepositoryException e) {
+                            throw new SAXException(e);
+                        }
                     } else if (name.equals("jcr:mixinTypes")) {
                         node.addMixin(values.get(0));
                     } else {



Mime
View raw message