karlpauls commented on a change in pull request #52:
URL: 
https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/52#discussion_r558293260



##########
File path: 
src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java
##########
@@ -166,32 +194,46 @@ private void addStatements(@NotNull SystemUser systemUser,
             return;
         }
 
-        Map<AccessControlEntry, String> entries = new LinkedHashMap<>();
+        Map<AccessControlEntry, String> resourceEntries = new 
LinkedHashMap<>();
+        Map<AccessControlEntry, String> principalEntries = new 
LinkedHashMap<>();
+
         authorizations.forEach(entry -> {
             String path = getRepoInitPath(entry.getRepositoryPath(), 
systemUser);
             if (path != null) {
-                entries.put(entry, path);
+                if (enforcePrincipalBased || entry.isPrincipalBased()) {
+                    principalEntries.put(entry, path);
+                } else {
+                    resourceEntries.put(entry, path);
+                }
             }
         });
-        if (!entries.isEmpty()) {
-            formatter.format("set ACL for %s%n", systemUser.getId());
-            entries.forEach((entry, path) -> {
-                formatter.format("%s %s on %s",
-                        entry.getOperation(),
-                        entry.getPrivileges(),
-                        path);
-
-                if (!entry.getRestrictions().isEmpty()) {
-                    formatter.format(" restriction(%s)",
-                            String.join(",", entry.getRestrictions()));
-                }
 
-                formatter.format("%n");
-            });
+        if (!principalEntries.isEmpty()) {
+            formatter.format("set principal ACL for %s%n", systemUser.getId());
+            principalEntries.forEach((entry, path) -> writeEntry(entry, path, 
formatter));
+            formatter.format("end%n");
+        }
+        if (!enforcePrincipalBased && !resourceEntries.isEmpty()) {

Review comment:
       True
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to