jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1569157 - 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 Tue, 18 Feb 2014 01:10:26 GMT
Author: tripod
Date: Tue Feb 18 01:10:25 2014
New Revision: 1569157

URL: http://svn.apache.org/r1569157
Log:
JCRVLT-28 Improve package import for subtrees

- fix minor error when root node is already new. this only happens with relative imports

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_with_thumbnail.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/ImportTests.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=1569157&r1=1569156&r2=1569157&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
Tue Feb 18 01:10:25 2014
@@ -686,7 +686,7 @@ public class DocViewSAXImporter extends 
             // special case for root node update
             node = currentNode;
         } else if (ni.uuid == null) {
-            if (!stack.isNew && currentNode.hasNode(ni.label)) {
+            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
@@ -713,7 +713,7 @@ public class DocViewSAXImporter extends 
                 // ignore
             }
             if (node == null) {
-                if (!stack.isNew && currentNode.hasNode(ni.label)) {
+                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
@@ -1278,6 +1278,10 @@ public class DocViewSAXImporter extends 
             return parent == null;
         }
 
+        public boolean checkForNode() {
+            // we should check if child node exist if stack is not new or if it's a root
node
+            return !isNew || parent == null;
+        }
         public void addName(String name) {
             childNames.addName(name);
         }
@@ -1286,7 +1290,7 @@ public class DocViewSAXImporter extends 
         }
 
         public void restoreOrder() throws RepositoryException {
-            if (!isNew && childNames.needsReorder(node)) {
+            if (checkForNode() && childNames.needsReorder(node)) {
                 ensureCheckedOut();
                 childNames.restoreOrder(node);
             }

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportTests.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportTests.java?rev=1569157&r1=1569156&r2=1569157&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportTests.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportTests.java
Tue Feb 18 01:10:25 2014
@@ -26,6 +26,8 @@ import javax.jcr.RepositoryException;
 import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
 import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
 import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.io.Archive;
 import org.apache.jackrabbit.vault.fs.io.ImportOptions;
 import org.apache.jackrabbit.vault.fs.io.Importer;
 import org.apache.jackrabbit.vault.fs.io.JcrArchive;
@@ -33,21 +35,15 @@ import org.apache.jackrabbit.vault.fs.io
 import org.apache.jackrabbit.vault.packaging.PackageException;
 import org.junit.Before;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 
 /**
  * <code>ImportTests</code>...
  */
 public class ImportTests extends IntegrationTestBase {
 
-    /**
-     * default logger
-     */
-    private static final Logger log = LoggerFactory.getLogger(ImportTests.class);
-
     public static final String TEST_ROOT = "/testroot";
 
     public static final String ARCHIVE_ROOT = "/archiveroot";
@@ -223,4 +219,34 @@ public class ImportTests extends Integra
     }
 
 
+    @Test
+    public void testSubArchiveExtract() throws IOException, RepositoryException, ConfigurationException
{
+        ZipArchive archive = new ZipArchive(getTempFile("testpackages/tmp_with_thumbnail.zip"));
+        archive.open(true);
+        Node rootNode = admin.getRootNode();
+        Node tmpNode = rootNode.addNode("tmp");
+        Node fileNode = tmpNode.addNode("package.zip", "nt:file");
+        Node contentNode = fileNode.addNode("jcr:content", "nt:resource");
+        contentNode.setProperty("jcr:data", "");
+        contentNode.setProperty("jcr:lastModified", 0);
+        contentNode.addMixin("vlt:Package");
+        Node defNode = contentNode.addNode("vlt:definition", "vlt:PackageDefinition");
+
+        ImportOptions opts = getDefaultOptions();
+        Archive subArchive =  archive.getSubArchive("META-INF/vault/definition", true);
+
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        filter.add(new PathFilterSet(defNode.getPath()));
+
+        Importer importer = new Importer(opts);
+        importer.getOptions().setAutoSaveThreshold(Integer.MAX_VALUE);
+        importer.getOptions().setFilter(filter);
+        importer.run(subArchive, defNode);
+        admin.save();
+
+        assertFalse("Importer must not have any errors", importer.hasErrors());
+        assertNodeExists("/tmp/package.zip/jcr:content/vlt:definition/thumbnail.png");
+    }
+
+
 }
\ No newline at end of file

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=1569157&r1=1569156&r2=1569157&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
Tue Feb 18 01:10:25 2014
@@ -23,7 +23,6 @@ import java.io.IOException;
 import javax.jcr.RepositoryException;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.jackrabbit.vault.packaging.InstallContext;
 import org.apache.jackrabbit.vault.packaging.JcrPackage;
 import org.apache.jackrabbit.vault.packaging.PackageException;
 import org.apache.tika.io.IOUtils;
@@ -54,6 +53,19 @@ public class TestPackageInstall extends 
     }
 
     /**
+     * Installs a package that contains and checks if everything is correct.
+     */
+    @Test
+    public void testUploadWithThumbnail() throws RepositoryException, IOException, PackageException
{
+        JcrPackage pack = packMgr.upload(getStream("testpackages/tmp_with_thumbnail.zip"),
false);
+        assertNotNull(pack);
+        assertNodeExists("/etc/packages/my_packages/tmp.zip");
+
+        // upload already unrwapps it, so check if definition is ok
+        assertNodeExists("/etc/packages/my_packages/tmp.zip/jcr:content/vlt:definition/thumbnail.png");
+    }
+
+    /**
      * Installs a package that contains /tmp/fullcoverage/a/aa using a vlt:FullCoverage mixin.
      * check if the package manager installs that node type although not present in the package.
      */

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_with_thumbnail.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_with_thumbnail.zip?rev=1569157&view=auto
==============================================================================
Files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_with_thumbnail.zip
(added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_with_thumbnail.zip
Tue Feb 18 01:10:25 2014 differ



Mime
View raw message