sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1805075 - in /sling/trunk/bundles/jcr/repoinit/src: main/java/org/apache/sling/jcr/repoinit/impl/ test/java/org/apache/sling/jcr/repoinit/
Date Tue, 15 Aug 2017 12:49:53 GMT
Author: cziegeler
Date: Tue Aug 15 12:49:53 2017
New Revision: 1805075

URL: http://svn.apache.org/viewvc?rev=1805075&view=rev
Log:
Minor clean up and add missing vendor to service

Modified:
    sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/AclUtil.java
    sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/JcrRepoInitOpsProcessorImpl.java
    sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java
    sling/trunk/bundles/jcr/repoinit/src/test/java/org/apache/sling/jcr/repoinit/GeneralAclTest.java

Modified: sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/AclUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/AclUtil.java?rev=1805075&r1=1805074&r2=1805075&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/AclUtil.java
(original)
+++ sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/AclUtil.java
Tue Aug 15 12:49:53 2017
@@ -27,7 +27,6 @@ import java.util.Set;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.security.AccessControlEntry;
@@ -39,11 +38,8 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
-
 import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
-
 import org.apache.sling.repoinit.parser.operations.RestrictionClause;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -71,8 +67,8 @@ public class AclUtil {
      * @throws RepositoryException
      */
     private static LocalRestrictions createLocalRestrictions(List<RestrictionClause>
list, JackrabbitAccessControlList jacl, Session s) throws RepositoryException {
-        Map<String,Value> restrictions = new HashMap<String,Value>();
-        Map<String,Value[]> mvrestrictions = new HashMap<String,Value[]>();
+        Map<String,Value> restrictions = new HashMap<>();
+        Map<String,Value[]> mvrestrictions = new HashMap<>();
 
         if(list != null && !list.isEmpty()){
             ValueFactory vf = s.getValueFactory();
@@ -146,7 +142,7 @@ public class AclUtil {
             if ( changed ) {
                 getJACM(session).setPolicy(path, acl);
             }
-            
+
         }
     }
 
@@ -200,7 +196,7 @@ public class AclUtil {
      * Helper class which allows easy comparison of a local (proposed) access control entry
with an existing one
      */
     static class LocalAccessControlEntry {
-        
+
         private final Principal principal;
         private final Privilege[] privileges;
         private final boolean isAllow;
@@ -216,7 +212,7 @@ public class AclUtil {
             this.isAllow = isAllow;
             this.restrictions = restrictions != null ? restrictions : new LocalRestrictions();
         }
-        
+
         public boolean isContainedIn(JackrabbitAccessControlEntry other) throws RepositoryException
{
             return other.getPrincipal().equals(principal) &&
                     contains(other.getPrivileges(), privileges) &&
@@ -270,12 +266,12 @@ public class AclUtil {
         private boolean contains(Privilege[] first, Privilege[] second) {
             // we need to ensure that the privilege order is not taken into account, so we
use sets
             Set<Privilege> set1 = expandPrivileges(first);
-            
+
             Set<Privilege> set2 = expandPrivileges(second);
-            
+
             return set1.containsAll(set2);
         }
-        
+
         @Override
         public String toString() {
             return "[" + getClass().getSimpleName() + "# principal " + principal+ ", privileges:
" + Arrays.toString(privileges) + ", isAllow : " + isAllow + "]";

Modified: sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/JcrRepoInitOpsProcessorImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/JcrRepoInitOpsProcessorImpl.java?rev=1805075&r1=1805074&r2=1805075&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/JcrRepoInitOpsProcessorImpl.java
(original)
+++ sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/JcrRepoInitOpsProcessorImpl.java
Tue Aug 15 12:49:53 2017
@@ -23,12 +23,16 @@ import javax.jcr.Session;
 import org.apache.sling.jcr.repoinit.JcrRepoInitOpsProcessor;
 import org.apache.sling.repoinit.parser.operations.Operation;
 import org.apache.sling.repoinit.parser.operations.OperationVisitor;
+import org.osgi.framework.Constants;
 import org.osgi.service.component.annotations.Component;
 
 /**
  * Apply Operations produced by the repoinit parser to a JCR Repository
  */
-@Component(service = JcrRepoInitOpsProcessor.class)
+@Component(service = JcrRepoInitOpsProcessor.class,
+    property = {
+            Constants.SERVICE_VENDOR + "=The Apache Software Foundation"
+    })
 public class JcrRepoInitOpsProcessorImpl implements JcrRepoInitOpsProcessor {
 
     /** Apply the supplied operations: first the namespaces and nodetypes

Modified: sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java?rev=1805075&r1=1805074&r2=1805075&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java
(original)
+++ sling/trunk/bundles/jcr/repoinit/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java
Tue Aug 15 12:49:53 2017
@@ -39,8 +39,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * SlingRepositoryInitializer Factory that executes repoinit statements read
- * from a configurable URL.
+ * SlingRepositoryInitializer Factory that executes repoinit statements configured
+ * through OSGi configurations. A configuration can contain URLs from which the
+ * statements are read or inlined statements.
  */
 @Designate(ocd = RepositoryInitializerFactory.Config.class, factory=true)
 @Component(service = SlingRepositoryInitializer.class,

Modified: sling/trunk/bundles/jcr/repoinit/src/test/java/org/apache/sling/jcr/repoinit/GeneralAclTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/repoinit/src/test/java/org/apache/sling/jcr/repoinit/GeneralAclTest.java?rev=1805075&r1=1805074&r2=1805075&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/repoinit/src/test/java/org/apache/sling/jcr/repoinit/GeneralAclTest.java
(original)
+++ sling/trunk/bundles/jcr/repoinit/src/test/java/org/apache/sling/jcr/repoinit/GeneralAclTest.java
Tue Aug 15 12:49:53 2017
@@ -25,14 +25,7 @@ import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-import javax.jcr.security.AccessControlEntry;
-
-import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
-import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
-import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
+
 import org.apache.sling.jcr.repoinit.impl.TestUtil;
 import org.apache.sling.repoinit.parser.RepoInitParsingException;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -43,20 +36,18 @@ import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
-import java.util.Arrays;
-
 /** Various ACL-related tests */
 public class GeneralAclTest {
 
     @Rule
     public final SlingContext context = new SlingContext(ResourceResolverType.JCR_OAK);
-    
+
     private TestUtil U;
     private String userA;
     private String userB;
 
     private Session s;
-    
+
     @Before
     public void setup() throws RepositoryException, RepoInitParsingException {
         U = new TestUtil(context);
@@ -74,32 +65,32 @@ public class GeneralAclTest {
         U.cleanupUser();
         s.logout();
     }
-    
+
     @Test(expected=AccessDeniedException.class)
     public void getRootNodeIntiallyFails() throws Exception {
         s.getRootNode();
     }
-    
+
     @Test
     public void readOnlyThenWriteThenDeny() throws Exception {
         final Node tmp = U.adminSession.getRootNode().addNode("tmp_" + U.id);
         U.adminSession.save();
         final String path = tmp.getPath();
-        
+
         try {
             s.getNode(path);
             fail("Expected read access to be initially denied:" + path);
         } catch(PathNotFoundException ignore) {
         }
-        
-        final String allowRead =  
+
+        final String allowRead =
                 "set ACL for " + U.username + "\n"
                 + "allow jcr:read on " + path + "\n"
                 + "end"
                 ;
         U.parseAndExecute(allowRead);
         final Node n = s.getNode(path);
-        
+
         try {
             n.setProperty("U.id", U.id);
             s.save();
@@ -107,8 +98,8 @@ public class GeneralAclTest {
         } catch(AccessDeniedException ignore) {
         }
         s.refresh(false);
-        
-        final String allowWrite = 
+
+        final String allowWrite =
                 "set ACL for " + U.username + "\n"
                 + "allow jcr:write on " + path + "\n"
                 + "end"
@@ -116,8 +107,8 @@ public class GeneralAclTest {
         U.parseAndExecute(allowWrite);
         n.setProperty("U.id", U.id);
         s.save();
-        
-        final String deny = 
+
+        final String deny =
                 "set ACL for " + U.username + "\n"
                 + "deny jcr:all on " + path + "\n"
                 + "end"
@@ -129,18 +120,18 @@ public class GeneralAclTest {
         } catch(PathNotFoundException ignore) {
         }
     }
-    
+
     @Test
     public void addChildAtRoot() throws Exception {
         final String nodename = "test_" + U.id;
         final String path = "/" + nodename;
-        
-        final String aclSetup = 
+
+        final String aclSetup =
             "set ACL for " + U.username + "\n"
             + "allow jcr:all on /\n"
             + "end"
             ;
-        
+
         U.parseAndExecute(aclSetup);
         try {
             assertFalse(s.itemExists(path));
@@ -243,7 +234,7 @@ public class GeneralAclTest {
    @Test
    @Ignore("SLING-6423 - ACLOptions processing is not implemented yet")
    public void mergeMode_ReplaceExistingPrincipalTest() throws Exception {
-      final String initialAclSetup = 
+      final String initialAclSetup =
                      " set ACL for " + userA + "\n"
                      + "allow jcr:read,jcr:addChildNodes on / \n"
                      + "end"



Mime
View raw message