jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r552539 - in /jackrabbit/branches/1.3/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io: DefaultHandler.java XmlHandler.java
Date Mon, 02 Jul 2007 16:47:32 GMT
Author: jukka
Date: Mon Jul  2 09:47:31 2007
New Revision: 552539

URL: http://svn.apache.org/viewvc?view=rev&rev=552539
Log:
1.3: Merged revision 548395 (JCR-973)

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

Modified: jackrabbit/branches/1.3/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java?view=diff&rev=552539&r1=552538&r2=552539
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
Mon Jul  2 09:47:31 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/branches/1.3/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.3/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java?view=diff&rev=552539&r1=552538&r2=552539
==============================================================================
--- jackrabbit/branches/1.3/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
(original)
+++ jackrabbit/branches/1.3/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/XmlHandler.java
Mon Jul  2 09:47:31 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