This is an automated email from the ASF dual-hosted git repository.

enorman pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git


The following commit(s) were added to refs/heads/master by this push:
     new ef29842  SLING-8805 The ModifyAce#modifyAce calls should have an 
option to not autoSave the session
ef29842 is described below

commit ef2984264802e42799f62948d083198f8741be65
Author: Eric Norman <[email protected]>
AuthorDate: Fri Oct 25 15:50:21 2019 -0700

    SLING-8805 The ModifyAce#modifyAce calls should have an option to not
    autoSave the session
---
 .../jcr/jackrabbit/accessmanager/ModifyAce.java    | 77 +++++++++++++++++++++-
 .../jcr/jackrabbit/accessmanager/package-info.java |  2 +-
 .../accessmanager/post/ModifyAceServlet.java       | 27 +++++++-
 .../accessmanager/post/package-info.java           |  2 +-
 4 files changed, 102 insertions(+), 6 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/ModifyAce.java 
b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/ModifyAce.java
index 6ad8095..f096763 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/ModifyAce.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/ModifyAce.java
@@ -39,6 +39,9 @@ public interface ModifyAce {
         * Add or modify the access control entry for the specified user 
         * or group.
         * 
+        * This is equivalent to {@link #modifyAce(Session, String, String, 
Map, String, boolean)} with
+        * the autoSave parameter value equal to true.
+        * 
         * @param jcrSession the JCR session of the user updating the user
         * @param resourcePath The absolute path of the resource to apply the 
ACE to (required)
         * @param principalId The name of the user/group to provision (required)
@@ -61,11 +64,45 @@ public interface ModifyAce {
                                                        Map<String, String> 
privileges,
                                                        String order
                                ) throws RepositoryException;
+
+       /**
+        * Add or modify the access control entry for the specified user 
+        * or group.
+        * 
+        * @param jcrSession the JCR session of the user updating the user
+        * @param resourcePath The absolute path of the resource to apply the 
ACE to (required)
+        * @param principalId The name of the user/group to provision (required)
+        * @param privileges Map of privileges to apply. (optional)
+     * @param order where the access control entry should go in the list.
+     *         Value should be one of these:
+     *         <table>
+     *          <tr><td>null</td><td>If the ACE for the principal doesn't 
exist add at the end, otherwise leave the ACE at it's current 
position.</td></tr>
+     *                         <tr><td>first</td><td>Place the target ACE as 
the first amongst its siblings</td></tr>
+        *                      <tr><td>last</td><td>Place the target ACE as 
the last amongst its siblings</td></tr>
+        *                      <tr><td>before xyz</td><td>Place the target ACE 
immediately before the sibling whose name is xyz</td></tr>
+        *                      <tr><td>after xyz</td><td>Place the target ACE 
immediately after the sibling whose name is xyz</td></tr>
+        *                      <tr><td>numeric</td><td>Place the target ACE at 
the specified numeric index</td></tr>
+        *         </table>
+        * @param autoSave true to automatically save changes to the JCR 
session, false otherwise
+        * @throws RepositoryException
+        */
+       default void modifyAce(Session jcrSession,
+                                                       String resourcePath,
+                                                       String principalId,
+                                                       Map<String, String> 
privileges,
+                                                       String order,
+                                                       boolean autoSave
+                               ) throws RepositoryException {
+               throw new UnsupportedRepositoryOperationException();
+       }
        
        /**
         * Add or modify the access control entry for the specified user 
         * or group.
         * 
+        * This is equivalent to {@link #modifyAce(Session, String, String, 
Map, String, Map, Map, Set, boolean)} with
+        * the autoSave parameter value equal to true.
+        * 
         * @param jcrSession the JCR session of the user updating the user
         * @param resourcePath The absolute path of the resource to apply the 
ACE to (required)
         * @param principalId The name of the user/group to provision (required)
@@ -94,7 +131,45 @@ public interface ModifyAce {
                                                        Map<String, Value[]> 
mvRestrictions,
                                                        Set<String> 
removeRestrictionNames
                                ) throws RepositoryException {
-               throw new UnsupportedRepositoryOperationException();
+               modifyAce(jcrSession, resourcePath, principalId, 
+                               privileges, order, restrictions, 
mvRestrictions, 
+                               removeRestrictionNames, true);
        }
 
+       /**
+        * Add or modify the access control entry for the specified user 
+        * or group.
+        * 
+        * @param jcrSession the JCR session of the user updating the user
+        * @param resourcePath The absolute path of the resource to apply the 
ACE to (required)
+        * @param principalId The name of the user/group to provision (required)
+        * @param privileges Map of privileges to apply. (optional)
+     * @param order where the access control entry should go in the list.
+     *         Value should be one of these:
+     *         <table>
+     *          <tr><td>null</td><td>If the ACE for the principal doesn't 
exist add at the end, otherwise leave the ACE at it's current 
position.</td></tr>
+     *                         <tr><td>first</td><td>Place the target ACE as 
the first amongst its siblings</td></tr>
+        *                      <tr><td>last</td><td>Place the target ACE as 
the last amongst its siblings</td></tr>
+        *                      <tr><td>before xyz</td><td>Place the target ACE 
immediately before the sibling whose name is xyz</td></tr>
+        *                      <tr><td>after xyz</td><td>Place the target ACE 
immediately after the sibling whose name is xyz</td></tr>
+        *                      <tr><td>numeric</td><td>Place the target ACE at 
the specified numeric index</td></tr>
+        *         </table>
+        * @param restrictions Map of single-value restrictions to apply. 
(optional)
+        * @param mvRestrictions Map of multi-value restrictions to apply. 
(optional)
+        * @param removeRestrictionNames Set of existing restriction names to 
remove (optional)
+        * @param autoSave true to automatically save changes to the JCR 
session, false otherwise
+        * @throws RepositoryException
+        */
+       default void modifyAce(Session jcrSession,
+                                                       String resourcePath,
+                                                       String principalId,
+                                                       Map<String, String> 
privileges,
+                                                       String order,
+                                                       Map<String, Value> 
restrictions,
+                                                       Map<String, Value[]> 
mvRestrictions,
+                                                       Set<String> 
removeRestrictionNames,
+                                                       boolean autoSave
+                               ) throws RepositoryException {
+               throw new UnsupportedRepositoryOperationException();
+       }
 }
diff --git 
a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/package-info.java 
b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/package-info.java
index e46171e..494de5b 100644
--- 
a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/package-info.java
+++ 
b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/package-info.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
[email protected]("3.1.0")
[email protected]("3.2.0")
 package org.apache.sling.jcr.jackrabbit.accessmanager;
 
 
diff --git 
a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
 
b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
index 1282299..deeb03d 100644
--- 
a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
+++ 
b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
@@ -217,17 +217,27 @@ public class ModifyAceServlet extends 
AbstractAccessPostServlet implements Modif
                }
                String order = request.getParameter("order");
        modifyAce(session, resourcePath, principalId, privileges, order, 
restrictions, mvRestrictions, 
-                       removeRestrictionNames);
+                       removeRestrictionNames, false);
        }
        
 
        /* (non-Javadoc)
+        * @see 
org.apache.sling.jcr.jackrabbit.accessmanager.ModifyAce#modifyAce(javax.jcr.Session,
 java.lang.String, java.lang.String, java.util.Map, java.lang.String, boolean)
+        */
+       @Override
+       public void modifyAce(Session jcrSession, String resourcePath, String 
principalId, Map<String, String> privileges,
+                       String order, boolean autoSave) throws 
RepositoryException {
+               modifyAce(jcrSession, resourcePath, principalId, privileges, 
order, 
+                               null, null, null, autoSave);
+       }
+
+       /* (non-Javadoc)
         * @see 
org.apache.sling.jcr.jackrabbit.accessmanager.ModifyAce#modifyAce(javax.jcr.Session,
 java.lang.String, java.lang.String, java.util.Map, java.lang.String)
         */
        public void modifyAce(Session jcrSession, String resourcePath,
                        String principalId, Map<String, String> privileges, 
String order)
                        throws RepositoryException {
-               modifyAce(jcrSession, resourcePath, principalId, privileges, 
order, null, null, null);
+               modifyAce(jcrSession, resourcePath, principalId, privileges, 
order, true);
        }
        /* (non-Javadoc)
         * @see 
org.apache.sling.jcr.jackrabbit.accessmanager.ModifyAce#modifyAce(javax.jcr.Session,
 java.lang.String, java.lang.String, java.util.Map, java.lang.String, 
java.util.Map, java.util.Map, java.util.Set)
@@ -236,6 +246,17 @@ public class ModifyAceServlet extends 
AbstractAccessPostServlet implements Modif
        public void modifyAce(Session jcrSession, String resourcePath, String 
principalId, Map<String, String> privileges,
                        String order, Map<String, Value> restrictions, 
Map<String, Value[]> mvRestrictions,
                        Set<String> removeRestrictionNames) throws 
RepositoryException {
+               modifyAce(jcrSession, resourcePath, principalId, privileges, 
order, 
+                               restrictions, mvRestrictions, 
removeRestrictionNames, true);
+       }       
+       
+       /* (non-Javadoc)
+        * @see 
org.apache.sling.jcr.jackrabbit.accessmanager.ModifyAce#modifyAce(javax.jcr.Session,
 java.lang.String, java.lang.String, java.util.Map, java.lang.String, 
java.util.Map, java.util.Map, java.util.Set, boolean)
+        */
+       @Override
+       public void modifyAce(Session jcrSession, String resourcePath, String 
principalId, Map<String, String> privileges,
+                       String order, Map<String, Value> restrictions, 
Map<String, Value[]> mvRestrictions,
+                       Set<String> removeRestrictionNames, boolean autoSave) 
throws RepositoryException {
                if (jcrSession == null) {
                        throw new RepositoryException("JCR Session not found");
                }
@@ -291,7 +312,7 @@ public class ModifyAceServlet extends 
AbstractAccessPostServlet implements Modif
                                        restrictions,
                                        mvRestrictions,
                                        removeRestrictionNames);
-                       if (jcrSession.hasPendingChanges()) {
+                       if (autoSave && jcrSession.hasPendingChanges()) {
                                jcrSession.save();
                        }
                } catch (RepositoryException re) {
diff --git 
a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/package-info.java
 
b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/package-info.java
index 839033a..19ca1ff 100644
--- 
a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/package-info.java
+++ 
b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/package-info.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
[email protected]("3.2.0")
[email protected]("3.3.0")
 package org.apache.sling.jcr.jackrabbit.accessmanager.post;
 
 

Reply via email to