jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1738191 - in /jackrabbit/commons/filevault/trunk/vault-core/src: main/java/org/apache/jackrabbit/vault/fs/impl/io/ test/java/org/apache/jackrabbit/vault/packaging/integration/ test/resources/org/apache/jackrabbit/vault/packaging/integratio...
Date Thu, 07 Apr 2016 21:02:01 GMT
Author: tripod
Date: Thu Apr  7 21:02:01 2016
New Revision: 1738191

URL: http://svn.apache.org/viewvc?rev=1738191&view=rev
Log:
JCRVLT-105 Use Node.setPrimaryType() when changing primary type.

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_nt_folder.zip
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java?rev=1738191&r1=1738190&r2=1738191&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
Thu Apr  7 21:02:01 2016
@@ -765,11 +765,6 @@ public class DocViewSAXImporter extends
         } else if (ni.uuid == null) {
             if (stack.checkForNode() && currentNode.hasNode(ni.label)) {
                 node = currentNode.getNode(ni.label);
-                if (ni.primary != null && !node.getPrimaryNodeType().getName().equals(ni.primary))
{
-                    // if node type mismatches => replace
-                    oldNode = node;
-                    node = null;
-                }
             }
         } else {
             try {
@@ -792,20 +787,9 @@ public class DocViewSAXImporter extends
             if (node == null) {
                 if (stack.checkForNode() && currentNode.hasNode(ni.label)) {
                     node = currentNode.getNode(ni.label);
-                    if (ni.primary != null && !node.getPrimaryNodeType().getName().equals(ni.primary))
{
-                        // if node type mismatches => replace
-                        oldNode = node;
-                        node = null;
-                    }
                 }
             } else {
-                if (node.getName().equals(ni.name)) {
-                    if (ni.primary != null && !node.getPrimaryNodeType().getName().equals(ni.primary))
{
-                        // if node type mismatches => replace
-                        oldNode = node;
-                        node = null;
-                    }
-                } else {
+                if (!node.getName().equals(ni.name)) {
                     // if names mismatches => replace
                     oldNode = node;
                     node = null;
@@ -881,6 +865,11 @@ public class DocViewSAXImporter extends
             }
             VersioningState vs = new VersioningState(stack, node);
 
+            // set new primary type (but never set rep:root)
+            if (!"rep:root".equals(ni.primary)) {
+                node.setPrimaryType(ni.primary);
+            }
+
             // remove the 'system' properties from the set
             ni.props.remove(JcrConstants.JCR_PRIMARYTYPE);
             ni.props.remove(JcrConstants.JCR_MIXINTYPES);

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java?rev=1738191&r1=1738190&r2=1738191&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
Thu Apr  7 21:02:01 2016
@@ -432,6 +432,32 @@ public class TestPackageInstall extends
         assertEquals("U", listener.getActions().get("/tmp/binary/test"));
     }
 
+    /**
+     * Installs a package with a different node type
+     */
+    @Test
+    public void testNodeTypeChange() throws RepositoryException, IOException, PackageException
{
+        JcrPackage pack = packMgr.upload(getStream("testpackages/tmp.zip"), false);
+        assertNotNull(pack);
+        assertNodeExists("/etc/packages/my_packages/tmp.zip");
+
+        ImportOptions opts = getDefaultOptions();
+        pack.install(opts);
+
+        assertNodeExists("/tmp/foo");
+        assertEquals(admin.getNode("/tmp").getPrimaryNodeType().getName(), "sling:OrderedFolder");
+
+        pack = packMgr.upload(getStream("testpackages/tmp_nt_folder.zip"), false);
+        assertNotNull(pack);
+        assertNodeExists("/etc/packages/my_packages/tmp.zip");
+
+        pack.install(opts);
+
+        assertNodeExists("/tmp/foo");
+        assertEquals(admin.getNode("/tmp").getPrimaryNodeType().getName(), "nt:folder");
+    }
+
+
     // todo: upload with version
     // todo: rename
 

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_nt_folder.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_nt_folder.zip?rev=1738191&view=auto
==============================================================================
Binary files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_nt_folder.zip
(added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_nt_folder.zip
Thu Apr  7 21:02:01 2016 differ



Mime
View raw message