jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1545669 - in /jackrabbit/commons/filevault/trunk/vault-core: ./ src/main/java/org/apache/jackrabbit/vault/fs/impl/io/ src/test/java/org/apache/jackrabbit/vault/packaging/integration/ src/test/resources/org/apache/jackrabbit/vault/packaging...
Date Tue, 26 Nov 2013 14:12:28 GMT
Author: tripod
Date: Tue Nov 26 14:12:28 2013
New Revision: 1545669

URL: http://svn.apache.org/r1545669
Log:
JCRVLT-22 Import of SNS content on not supporting repositories

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/test_sns.zip
  (with props)
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/pom.xml
    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/IntegrationTestBase.java

Modified: jackrabbit/commons/filevault/trunk/vault-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/pom.xml?rev=1545669&r1=1545668&r2=1545669&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/pom.xml (original)
+++ jackrabbit/commons/filevault/trunk/vault-core/pom.xml Tue Nov 26 14:12:28 2013
@@ -110,7 +110,30 @@
                     </instructions>
                 </configuration>
             </plugin>
+
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <executions>
+                    <!-- run tests 2 second time on jackrabbit oak -->
+                    <execution>
+                        <id>oak</id>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <argLine>-Doak=true</argLine>
+                            <excludes>
+                                <exclude>**/TestGroupMergePackage.java</exclude>
+                                <exclude>**/TestACLAndMerge.java</exclude>
+                                <exclude>**/JcrPackageManagerImplTest.java</exclude>
+                                <exclude>**/AdminPermissionCheckerTest.java</exclude>
+                            </excludes>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
+
     </build>
 
     <!-- ====================================================================== -->
@@ -197,6 +220,12 @@
             <version>${jackrabbit.version}</version>
             <scope>test</scope>
         </dependency>
-    </dependencies>
 
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>oak-run</artifactId>
+            <version>0.13-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
 </project>

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=1545669&r1=1545668&r2=1545669&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 Nov 26 14:12:28 2013
@@ -37,6 +37,7 @@ import javax.jcr.NodeIterator;
 import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
 import javax.jcr.PropertyType;
+import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
@@ -211,6 +212,11 @@ public class DocViewSAXImporter extends 
     private AccessControlHandling aclHandling = AccessControlHandling.IGNORE;
 
     /**
+     * flag indicating if SNS are supported by the underlying repository
+     */
+    private final boolean snsSupported;
+
+    /**
      * Creates a new importer that will receive SAX events and imports the
      * items below the given root.
      *
@@ -231,6 +237,8 @@ public class DocViewSAXImporter extends 
         this.rootNodeName = rootNodeName;
         this.aclManagement = ServiceProviderFactory.getProvider().getACLManagement();
         this.userManagement = ServiceProviderFactory.getProvider().getUserManagement();
+        this.snsSupported = session.getRepository().
+                getDescriptorValue(Repository.NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED).getBoolean();
 
         String rootPath = parentNode.getPath();
         if (!rootPath.equals("/")) {
@@ -558,8 +566,21 @@ public class DocViewSAXImporter extends 
         String label = ISO9075.decode(qName);
         String name = label;
         log.debug("-> element {}", label);
+        boolean snsNode = false;
         int idx = name.lastIndexOf('[');
         if (idx > 0) {
+            if (!snsSupported) {
+                int idx2 = name.indexOf(']', idx);
+                if (idx2 > 0) {
+                    try {
+                        if (Integer.valueOf(name.substring(idx+1, idx2)) > 1) {
+                            snsNode = true;
+                        }
+                    } catch (NumberFormatException e) {
+                        // ignore
+                    }
+                }
+            }
             name = name.substring(0, idx);
         }
         try {
@@ -579,6 +600,10 @@ public class DocViewSAXImporter extends 
                     // only ordering node. skip
                     log.debug("Skipping empty node {}", node.getPath() + "/" + name);
                     stack = stack.push(null);
+                } else if (snsNode) {
+                    // skip SNS nodes with index > 1
+                    log.warn("Skipping unsupported SNS node with index > 1. Some content
will be missing after import: {}", node.getPath() + "/" + label);
+                    stack = stack.push(null);
                 } else {
                     try {
                         DocViewNode ni = new DocViewNode(name, label, attributes, npResolver);

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=1545669&r1=1545668&r2=1545669&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 Nov 26 14:12:28 2013
@@ -20,6 +20,7 @@ package org.apache.jackrabbit.vault.pack
 import java.io.IOException;
 
 import javax.jcr.Node;
+import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
@@ -194,5 +195,32 @@ public class ImportTests extends Integra
 
     }
 
+    @Test
+    public void testSNSImport() throws IOException, RepositoryException, ConfigurationException
{
+        ZipArchive archive = new ZipArchive(getTempFile("testpackages/test_sns.zip"));
+        archive.open(true);
+        Node rootNode = admin.getRootNode();
+        ImportOptions opts = getDefaultOptions();
+        Importer importer = new Importer(opts);
+        importer.run(archive, rootNode);
+
+        assertNodeExists("/tmp/testroot");
+        assertNodeExists("/tmp/testroot/foo");
+        assertProperty("/tmp/testroot/foo/name", "foo1");
+
+        // only check for SNS nodes if SNS supported
+        if (admin.getRepository().getDescriptorValue(Repository.NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED).getBoolean())
{
+            assertNodeExists("/tmp/testroot/foo[2]");
+            assertNodeExists("/tmp/testroot/foo[3]");
+            assertProperty("/tmp/testroot/foo[2]/name", "foo2");
+            assertProperty("/tmp/testroot/foo[3]/name", "foo3");
+        } else {
+            // otherwise nodes must not exist
+            assertNodeMissing("/tmp/testroot/foo[2]");
+            assertNodeMissing("/tmp/testroot/foo[3]");
+        }
+
+    }
+
 
 }
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java?rev=1545669&r1=1545668&r2=1545669&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java
Tue Nov 26 14:12:28 2013
@@ -24,6 +24,7 @@ import java.io.InputStream;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
+import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
@@ -32,6 +33,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.jackrabbit.oak.jcr.Jcr;
 import org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener;
 import org.apache.jackrabbit.vault.fs.io.ImportOptions;
 import org.apache.jackrabbit.vault.packaging.JcrPackageManager;
@@ -59,7 +61,7 @@ public class IntegrationTestBase  {
 
     private static final String REPO_HOME = "target/repository";
 
-    protected static RepositoryImpl repository;
+    protected static Repository repository;
 
     protected Session admin;
 
@@ -67,17 +69,24 @@ public class IntegrationTestBase  {
 
     @BeforeClass
     public static void initRepository() throws RepositoryException {
-        InputStream in = IntegrationTestBase.class.getResourceAsStream("repository.xml");
-        RepositoryConfig cfg = RepositoryConfig.create(in, REPO_HOME);
-        repository = RepositoryImpl.create(cfg);
+        if (Boolean.getBoolean("oak")) {
+            repository = new Jcr().createRepository();
+        } else {
+            InputStream in = IntegrationTestBase.class.getResourceAsStream("repository.xml");
+            RepositoryConfig cfg = RepositoryConfig.create(in, REPO_HOME);
+            repository = RepositoryImpl.create(cfg);
+        }
+        log.info("repository created: {} {}",
+                repository.getDescriptor(Repository.REP_NAME_DESC),
+                repository.getDescriptor(Repository.REP_VERSION_DESC));
     }
 
     @AfterClass
     public static void shutdownRepository() {
-        if (repository != null) {
-            repository.shutdown();
-            repository = null;
+        if (repository instanceof RepositoryImpl) {
+            ((RepositoryImpl) repository).shutdown();
         }
+        repository = null;
     }
 
     @Before

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/test_sns.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/test_sns.zip?rev=1545669&view=auto
==============================================================================
Binary file - no diff available.

Propchange: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/test_sns.zip
------------------------------------------------------------------------------
    svn:mime-type = application/jar



Mime
View raw message