jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1705214 - in /jackrabbit/commons/filevault/trunk/vault-core/src: main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java
Date Fri, 25 Sep 2015 06:06:49 GMT
Author: tripod
Date: Fri Sep 25 06:06:49 2015
New Revision: 1705214

URL: http://svn.apache.org/viewvc?rev=1705214&view=rev
Log:
JCRVLT-98 Multivalued properties of users are saved as single valued properties

Modified:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java?rev=1705214&r1=1705213&r2=1705214&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JcrSysViewTransformer.java
Fri Sep 25 06:06:49 2015
@@ -172,6 +172,10 @@ public class JcrSysViewTransformer imple
                 attrs = new AttributesImpl();
                 attrs.addAttribute(Name.NS_SV_URI, "name", "sv:name", "CDATA", p.name);
                 attrs.addAttribute(Name.NS_SV_URI, "type", "sv:type", "CDATA", PropertyType.nameFromValue(p.type));
+                if (p.isMulti) {
+                    attrs.addAttribute(Name.NS_SV_URI, "multiple", "sv:multiple", "CDATA",
"true");
+                }
+
                 handler.startElement(Name.NS_SV_URI, "property", "sv:property", attrs);
                 for (String v: p.values) {
                     handler.startElement(Name.NS_SV_URI, "value", "sv:value", DocViewSAXImporter.EMPTY_ATTRIBUTES);

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java?rev=1705214&r1=1705213&r2=1705214&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java
Fri Sep 25 06:06:49 2015
@@ -17,11 +17,15 @@
 
 package org.apache.jackrabbit.vault.packaging.integration;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Properties;
 import java.util.Set;
 
+import javax.jcr.Node;
+import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeType;
 
@@ -31,10 +35,15 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.core.security.principal.PrincipalImpl;
 import org.apache.jackrabbit.vault.fs.api.ImportMode;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
 import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
 import org.apache.jackrabbit.vault.fs.io.ImportOptions;
+import org.apache.jackrabbit.vault.packaging.ExportOptions;
 import org.apache.jackrabbit.vault.packaging.JcrPackage;
 import org.apache.jackrabbit.vault.packaging.PackageException;
+import org.apache.jackrabbit.vault.packaging.VaultPackage;
 import org.apache.jackrabbit.vault.util.Text;
 import org.junit.Test;
 
@@ -42,6 +51,7 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 /**
  * <code>TestEmptyPackage</code>...
@@ -281,6 +291,41 @@ public class TestUserContentPackage exte
         pack.install(opts);
     }
 
+
+
+    @Test
+    public void install_mv_property() throws RepositoryException, IOException, PackageException
{
+        UserManager mgr = ((JackrabbitSession) admin).getUserManager();
+        User u = mgr.createUser(ID_TEST_USER_A, "nonce");
+        Node node = admin.getNode(u.getPath());
+
+        node.setProperty("mv", new String[]{"mv1"});
+        Property property = node.getProperty("mv");
+        assertTrue(property.isMultiple());
+        admin.save();
+
+        File tmpFile = createPackage("test", "test", u.getPath());
+        u.remove();
+        u = (User)  mgr.getAuthorizable(ID_TEST_USER_A);
+        assertNull(u);
+
+
+        JcrPackage pack = packMgr.upload(tmpFile, true, true, null);
+        assertNotNull(pack);
+        ImportOptions opts = getDefaultOptions();
+        pack.install(opts);
+
+
+        u = (User)  mgr.getAuthorizable(ID_TEST_USER_A);
+        assertNotNull(u);
+
+        node = admin.getNode(u.getPath());
+        property = node.getProperty("mv");
+        assertTrue(property.isMultiple());
+
+    }
+
+
     private User installUserA(ImportMode mode, boolean usePkgPath, boolean expectPkgPath)
throws RepositoryException, IOException, PackageException {
         UserManager mgr = ((JackrabbitSession) admin).getUserManager();
         assertNull("test-user-a must not exist", mgr.getAuthorizable(ID_TEST_USER_A));
@@ -344,4 +389,30 @@ public class TestUserContentPackage exte
         return userA;
     }
 
+
+
+    public File createPackage(String group, String name, String... paths) throws RepositoryException,
IOException, PackageException {
+        ExportOptions opts = new ExportOptions();
+        DefaultMetaInf inf = new DefaultMetaInf();
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        for (String path : paths) {
+            filter.add(new PathFilterSet(path));
+        }
+
+        inf.setFilter(filter);
+        Properties props = new Properties();
+        props.setProperty(VaultPackage.NAME_GROUP, group);
+        props.setProperty(VaultPackage.NAME_NAME, name);
+        inf.setProperties(props);
+
+        opts.setMetaInf(inf);
+
+        File tmpFile = File.createTempFile("vaulttest", "zip");
+        VaultPackage pkg = packMgr.assemble(admin, opts, tmpFile);
+
+        pkg.close();
+
+        return tmpFile;
+    }
+
 }
\ No newline at end of file



Mime
View raw message