jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1560543 - in /jackrabbit/commons/filevault/trunk: parent/ vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/ vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/
Date Wed, 22 Jan 2014 22:14:43 GMT
Author: tripod
Date: Wed Jan 22 22:14:42 2014
New Revision: 1560543

URL: http://svn.apache.org/r1560543
Log:
JCRVLT-25 Implement AccessControllHandling MERGE and MERGE_PRESERVE

- use latest oak

Modified:
    jackrabbit/commons/filevault/trunk/parent/pom.xml
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java

Modified: jackrabbit/commons/filevault/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/parent/pom.xml?rev=1560543&r1=1560542&r2=1560543&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/parent/pom.xml (original)
+++ jackrabbit/commons/filevault/trunk/parent/pom.xml Wed Jan 22 22:14:42 2014
@@ -41,7 +41,7 @@
 
     <properties>
         <jackrabbit.version>2.7.2</jackrabbit.version>
-        <oak.version>0.15-SNAPSHOT</oak.version>
+        <oak.version>0.16-SNAPSHOT</oak.version>
     </properties>
 
     <!-- ====================================================================== -->

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java?rev=1560543&r1=1560542&r2=1560543&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java
Wed Jan 22 22:14:42 2014
@@ -42,7 +42,6 @@ import org.apache.jackrabbit.vault.fs.io
 import org.apache.jackrabbit.vault.util.DocViewNode;
 import org.apache.jackrabbit.vault.util.DocViewProperty;
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
 /**
@@ -54,7 +53,7 @@ public class JackrabbitACLImporter imple
     /**
      * default logger
      */
-    private static final Logger log = LoggerFactory.getLogger(JackrabbitACLImporter.class);
+    private static final Logger log = DocViewSAXImporter.log;
 
     private final Node accessControlledNode;
 
@@ -64,6 +63,8 @@ public class JackrabbitACLImporter imple
 
     private final PrincipalManager pMgr;
 
+    private final String accessControlledPath;
+
     private Map<String, List<ACE>> aceMap = new HashMap<String, List<ACE>>();
 
     private ACE currentACE;
@@ -83,8 +84,10 @@ public class JackrabbitACLImporter imple
             throw new RepositoryException("Error while reading access control content: unsupported
AccessControlHandling: " + aclHandling);
         }
         this.accessControlledNode = accessControlledNode;
-        this.acMgr = accessControlledNode.getSession().getAccessControlManager();
-        this.pMgr = ((JackrabbitSession) accessControlledNode.getSession()).getPrincipalManager();
+        this.accessControlledPath = accessControlledNode.getPath();
+        final JackrabbitSession session = ((JackrabbitSession) accessControlledNode.getSession());
+        this.acMgr = session.getAccessControlManager();
+        this.pMgr = session.getPrincipalManager();
         this.aclHandling = aclHandling;
         this.states.push(State.INITIAL);
     }
@@ -103,13 +106,7 @@ public class JackrabbitACLImporter imple
 
             case ACL:
                 try {
-                    currentACE = new ACE(node);
-                    List<ACE> list = aceMap.get(currentACE.principalName);
-                    if (list == null) {
-                        list = new ArrayList<ACE>();
-                        aceMap.put(currentACE.principalName, list);
-                    }
-                    list.add(currentACE);
+                    currentACE = addACE(aceMap, new ACE(node));
                     state = State.ACE;
                 } catch (IllegalArgumentException e) {
                     log.error("Error while reading access control content: {}", e);
@@ -131,6 +128,16 @@ public class JackrabbitACLImporter imple
         states.push(state);
     }
 
+    private static ACE addACE(Map<String, List<ACE>> map, ACE ace) {
+        List<ACE> list = map.get(ace.principalName);
+        if (list == null) {
+            list = new ArrayList<ACE>();
+            map.put(ace.principalName, list);
+        }
+        list.add(ace);
+        return ace;
+    }
+
     public void endNode() throws SAXException {
         State state = states.pop();
         if (state == State.ACE) {
@@ -150,13 +157,12 @@ public class JackrabbitACLImporter imple
     }
 
     private void apply() throws RepositoryException {
-        final String path = accessControlledNode.getPath();
         final ValueFactory valueFactory = accessControlledNode.getSession().getValueFactory();
 
         // find principals of existing ACL
         JackrabbitAccessControlList acl = null;
         Set<String> existingPrincipals = new HashSet<String>();
-        for (AccessControlPolicy p: acMgr.getPolicies(path)) {
+        for (AccessControlPolicy p: acMgr.getPolicies(accessControlledPath)) {
             if (p instanceof JackrabbitAccessControlList) {
                 acl = (JackrabbitAccessControlList) p;
                 for (AccessControlEntry ace: acl.getAccessControlEntries()) {
@@ -167,12 +173,12 @@ public class JackrabbitACLImporter imple
 
         // remove existing policy for 'overwrite'
         if (aclHandling == AccessControlHandling.OVERWRITE && acl != null) {
-            acMgr.removePolicy(path, acl);
+            acMgr.removePolicy(accessControlledPath, acl);
             acl = null;
         }
 
         if (acl == null) {
-            AccessControlPolicyIterator iter = acMgr.getApplicablePolicies(path);
+            AccessControlPolicyIterator iter = acMgr.getApplicablePolicies(accessControlledPath);
             while (iter.hasNext()) {
                 AccessControlPolicy p = iter.nextAccessControlPolicy();
                 if (p instanceof JackrabbitAccessControlList) {
@@ -182,7 +188,7 @@ public class JackrabbitACLImporter imple
             }
         }
         if (acl == null) {
-            throw new RepositoryException("not JackrabbitAccessControlList applicable on
" + path);
+            throw new RepositoryException("not JackrabbitAccessControlList applicable on
" + accessControlledPath);
         }
 
         // apply ACEs of package
@@ -226,7 +232,7 @@ public class JackrabbitACLImporter imple
                 acl.addEntry(principal, privileges, ace.allow, svRestrictions, mvRestrictions);
             }
         }
-        acMgr.setPolicy(path, acl);
+        acMgr.setPolicy(accessControlledPath, acl);
     }
 
     private static class ACE {

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=1560543&r1=1560542&r2=1560543&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
Wed Jan 22 22:14:42 2014
@@ -39,6 +39,7 @@ import org.apache.jackrabbit.core.securi
 import org.apache.jackrabbit.oak.jcr.Jcr;
 import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
+import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration;
 import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
@@ -87,8 +88,11 @@ public class IntegrationTestBase  {
             userProps.put(AccessControlAction.USER_PRIVILEGE_NAMES, new String[] {PrivilegeConstants.JCR_ALL});
             userProps.put(AccessControlAction.GROUP_PRIVILEGE_NAMES, new String[] {PrivilegeConstants.JCR_READ});
             userProps.put(ProtectedItemImporter.PARAM_IMPORT_BEHAVIOR, ImportBehavior.NAME_BESTEFFORT);
+            Properties authzProps = new Properties();
+            authzProps.put(ProtectedItemImporter.PARAM_IMPORT_BEHAVIOR, ImportBehavior.NAME_BESTEFFORT);
             Properties securityProps = new Properties();
             securityProps.put(UserConfiguration.NAME, ConfigurationParameters.of(userProps));
+            securityProps.put(AuthorizationConfiguration.NAME, ConfigurationParameters.of(authzProps));
             repository = new Jcr()
                     .with(new SecurityProviderImpl(ConfigurationParameters.of(securityProps)))
                     .createRepository();



Mime
View raw message