jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1774375 - in /jackrabbit/commons/filevault/trunk/vault-core/src: main/java/org/apache/jackrabbit/vault/packaging/impl/ test/java/org/apache/jackrabbit/vault/packaging/integration/ test/resources/org/apache/jackrabbit/vault/packaging/integr...
Date Thu, 15 Dec 2016 06:53:31 GMT
Author: tripod
Date: Thu Dec 15 06:53:30 2016
New Revision: 1774375

URL: http://svn.apache.org/viewvc?rev=1774375&view=rev
Log:
JCRVLT-145 Subpackage extraction should not add parent dependency if no content

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_with_nodetypes.zip
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java?rev=1774375&r1=1774374&r2=1774375&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
Thu Dec 15 06:53:30 2016
@@ -32,14 +32,18 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.jcr.Binary;
+import javax.jcr.NamespaceException;
 import javax.jcr.Node;
 import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
+import javax.jcr.nodetype.NodeTypeManager;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 import org.apache.jackrabbit.vault.fs.api.ImportMode;
 import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
 import org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener;
@@ -49,6 +53,7 @@ import org.apache.jackrabbit.vault.fs.io
 import org.apache.jackrabbit.vault.fs.io.ImportOptions;
 import org.apache.jackrabbit.vault.fs.io.MemoryArchive;
 import org.apache.jackrabbit.vault.fs.io.ZipArchive;
+import org.apache.jackrabbit.vault.fs.spi.NodeTypeSet;
 import org.apache.jackrabbit.vault.packaging.CyclicDependencyException;
 import org.apache.jackrabbit.vault.packaging.Dependency;
 import org.apache.jackrabbit.vault.packaging.DependencyException;
@@ -547,6 +552,29 @@ public class JcrPackageImpl implements J
                 break;
             }
         }
+        // check if package has nodetype no installed in the repository
+        if (!hasOwnContent) {
+            DefaultNamePathResolver npResolver = new DefaultNamePathResolver(getNode().getSession());
+            NodeTypeManager ntMgr = getNode().getSession().getWorkspace().getNodeTypeManager();
+            loop0: for (NodeTypeSet cnd: a.getMetaInf().getNodeTypes()) {
+                for (Name name: cnd.getNodeTypes().keySet()) {
+                    String jcrName;
+                    try {
+                        jcrName = npResolver.getJCRName(name);
+                    } catch (NamespaceException e) {
+                        // in case the uri is not registered. we also break here
+                        log.info("Package {}: contains namespace not installed in the repository:
{}. Sub packages will have a dependency to it", pId, name.getNamespaceURI());
+                        hasOwnContent = true;
+                        break loop0;
+                    }
+                    if (!ntMgr.hasNodeType(jcrName)) {
+                        log.info("Package {}: contains nodetype not installed in the repository:
{}. Sub packages will have a dependency to it", pId, jcrName);
+                        hasOwnContent = true;
+                        break loop0;
+                    }
+                }
+            }
+        }
 
         // process the discovered sub-packages
         for (Archive.Entry e: entries) {

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java?rev=1774375&r1=1774374&r2=1774375&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java
Thu Dec 15 06:53:30 2016
@@ -428,6 +428,34 @@ public class TestSubPackages extends Int
     }
 
     /**
+     * Test if extracted sub-packages have their parent package as dependency, even if not
specified in their properties.
+     * but only if the parent package has nodetypes
+     */
+    @Test
+    public void testSubPackageWithNodeTypesDependency() throws IOException, RepositoryException,
PackageException {
+        JcrPackage pack = packMgr.upload(getStream("testpackages/subtest_with_nodetypes.zip"),
false);
+        assertNotNull(pack);
+        PackageId pId = pack.getDefinition().getId();
+
+        // install
+        ImportOptions opts = getDefaultOptions();
+        pack.extractSubpackages(opts);
+
+        // check for sub packages dependency
+        String expected = new Dependency(pId).toString();
+
+        JcrPackage p1 = packMgr.open(admin.getNode("/etc/packages/my_packages/sub_a.zip"));
+        assertEquals("has 1 dependency", 1, p1.getDefinition().getDependencies().length);
+        assertEquals("has dependency to parent package", expected, p1.getDefinition().getDependencies()[0].toString());
+        JcrPackage p2 = packMgr.open(admin.getNode("/etc/packages/my_packages/sub_b.zip"));
+        assertEquals("has 1 dependency", 1, p2.getDefinition().getDependencies().length);
+        assertEquals("has dependency to parent package", expected, p2.getDefinition().getDependencies()[0].toString());
+
+        // parent package should not be installed.
+        assertEquals("Parent package with content should not be marked as installed.", false,
pack.isInstalled());
+    }
+
+    /**
      * Test if subpackage extraction works recursively
      */
     @Test

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_with_nodetypes.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_with_nodetypes.zip?rev=1774375&view=auto
==============================================================================
Binary files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_with_nodetypes.zip
(added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_with_nodetypes.zip
Thu Dec 15 06:53:30 2016 differ



Mime
View raw message