jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r548395 - in /jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io: DefaultHandler.java XmlHandler.java
Date Mon, 18 Jun 2007 16:26:56 GMT
Author: tripod
Date: Mon Jun 18 09:26:55 2007
New Revision: 548395

URL: http://svn.apache.org/viewvc?view=rev&rev=548395
Log:
JCR-973 XML import using MacOS X WebDAV client does not work

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java?view=diff&rev=548395&r1=548394&r2=548395
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
Mon Jun 18 09:26:55 2007
@@ -289,21 +289,28 @@
             String ntName = (isCollection) ? getCollectionNodeType() : getNodeType();
             parentNode = parentNode.addNode(name, ntName);
         }
-        Node contentNode;
+        Node contentNode = null;
         if (isCollection) {
             contentNode = parentNode;
         } else {
             if (parentNode.hasNode(JcrConstants.JCR_CONTENT)) {
                 contentNode = parentNode.getNode(JcrConstants.JCR_CONTENT);
-                // remove all entries in the jcr:content since replacing content
-                // includes properties (DefaultHandler) and nodes (e.g. ZipHandler)
-                if (contentNode.hasNodes()) {
-                    NodeIterator it = contentNode.getNodes();
-                    while (it.hasNext()) {
-                        it.nextNode().remove();
+                // check if nodetype is compatible (might be update of an existing file)
+                if (contentNode.isNodeType(getContentNodeType())) {
+                    // remove all entries in the jcr:content since replacing content
+                    // includes properties (DefaultHandler) and nodes (e.g. ZipHandler)
+                    if (contentNode.hasNodes()) {
+                        NodeIterator it = contentNode.getNodes();
+                        while (it.hasNext()) {
+                            it.nextNode().remove();
+                        }
                     }
+                } else {
+                    contentNode.remove();
+                    contentNode = null;
                 }
-            } else {
+            }
+            if (contentNode == null) {
                 contentNode = parentNode.addNode(JcrConstants.JCR_CONTENT, getContentNodeType());
             }
         }

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java?view=diff&rev=548395&r1=548394&r2=548395
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
Mon Jun 18 09:26:55 2007
@@ -90,7 +90,10 @@
             return false;
         }
         boolean isXmlMimeType = XML_MIMETYPE.equals(context.getMimeType());
-        return isXmlMimeType && context.hasStream() && super.canImport(context,
isCollection);
+        return isXmlMimeType
+                && context.hasStream()
+                && context.getContentLength() > 0
+                && super.canImport(context, isCollection);
     }
 
     /**



Mime
View raw message