You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2021/09/18 13:01:35 UTC

[sling-org-apache-sling-feature-cpconverter] branch master updated (a3523f4 -> 35371df)

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

cziegeler pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git.


    from a3523f4  SLING-10822 : Avoid duplicate parsing of configuration pid
     new 4592260  SLING-10823 : Pass in repoinit as a single text
     new 35371df  SLING-10823 : Pass in repoinit as a single text

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../features/DefaultFeaturesManager.java           | 12 ++--------
 .../feature/cpconverter/handlers/RepoInitTest.java |  5 ++--
 ....RepositoryInitializer-conversion-result.config | 28 ++++++++--------------
 3 files changed, 14 insertions(+), 31 deletions(-)

[sling-org-apache-sling-feature-cpconverter] 02/02: SLING-10823 : Pass in repoinit as a single text

Posted by cz...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git

commit 35371dfda2156353df4a8fdb9c5d952980f6b156
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sat Sep 18 15:01:29 2021 +0200

    SLING-10823 : Pass in repoinit as a single text
---
 .../feature/cpconverter/features/DefaultFeaturesManager.java      | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java b/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
index 2ea9c54..7eab0ab 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
@@ -120,8 +120,6 @@ public class DefaultFeaturesManager implements FeaturesManager, PackagesEventsEm
 
     private final Stack<String> packageIds = new Stack<>();
 
-    private String lastRepoinitSource;
-
     DefaultFeaturesManager() {
         this(new File(""));
     }
@@ -529,11 +527,7 @@ public class DefaultFeaturesManager implements FeaturesManager, PackagesEventsEm
         }
 
         // prepend source/origin
-        final String newSource = "# origin=".concat(String.join("|", this.packageIds)).concat(" source=").concat(source);
-        if ( !newSource.equals(lastRepoinitSource) ) {
-            lastRepoinitSource = newSource;
-            text = newSource.concat(System.lineSeparator().concat(text));
-        }
+        text = "# origin=".concat(String.join("|", this.packageIds)).concat(" source=").concat(source).concat(System.lineSeparator()).concat(text);
 
         Extension repoInitExtension = getRunMode(runMode).getExtensions().getByName(Extension.EXTENSION_NAME_REPOINIT);
         if (repoInitExtension == null) {

[sling-org-apache-sling-feature-cpconverter] 01/02: SLING-10823 : Pass in repoinit as a single text

Posted by cz...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git

commit 4592260e9146cb4a0bb4b4682cf433adad22fe26
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sat Sep 18 13:30:24 2021 +0200

    SLING-10823 : Pass in repoinit as a single text
---
 .../features/DefaultFeaturesManager.java           |  4 +---
 .../feature/cpconverter/handlers/RepoInitTest.java |  5 ++--
 ....RepositoryInitializer-conversion-result.config | 28 ++++++++--------------
 3 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java b/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
index 26d301c..2ea9c54 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
@@ -313,9 +313,7 @@ public class DefaultFeaturesManager implements FeaturesManager, PackagesEventsEm
         if (REPOINIT_FACTORY_PID.equals(cfg.getFactoryPid())) {
             final String[] scripts = Converters.standardConverter().convert(configurationProperties.get("scripts")).to(String[].class);
             if (scripts != null && scripts.length > 0) {
-                for (final String text : scripts) {
-                    getAclManager().addRepoinitExtention(cfg.getPid(), text, runMode, this);
-                }
+                getAclManager().addRepoinitExtention(cfg.getPid(), String.join(System.lineSeparator(), scripts), runMode, this);
             }
             checkReferences(configurationProperties, cfg.getPid());
             return true;
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepoInitTest.java b/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepoInitTest.java
index 5fbce0d..7a6c85f 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepoInitTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepoInitTest.java
@@ -76,11 +76,10 @@ public class RepoInitTest {
     @Test
     public void parseConversionRepoInit() throws Exception {
         String path = PATH_PREFIX + "-conversion-test.config";
-        String result = PATH_PREFIX + "-conversion-result.config";
 
         Extension expectedExtension;
         if (enforcePrincipalBasedAcSetup) {
-            expectedExtension = extractExtensions(result, false, false);
+            expectedExtension = extractExtensions(PATH_PREFIX + "-conversion-result.config", false, false);
         } else {
             expectedExtension = extractExtensions(path, false, false);
         }
@@ -88,7 +87,7 @@ public class RepoInitTest {
         assertNotNull(expectedExtension);
         assertNotNull(extension);
         String txt = normalize(extension.getText());
-        assertEquals(name, normalize(expectedExtension.getText()), txt);
+        assertEquals(txt, normalize(expectedExtension.getText()), txt);
 
         // verify that the generated repo-init is valid
         assertFalse(name, new RepoInitParserService().parse(new StringReader(txt)).isEmpty());
diff --git a/src/test/resources/org/apache/sling/feature/cpconverter/handlers/jcr_root/apps/asd/config.publish/org.apache.sling.jcr.repoinit.RepositoryInitializer-conversion-result.config b/src/test/resources/org/apache/sling/feature/cpconverter/handlers/jcr_root/apps/asd/config.publish/org.apache.sling.jcr.repoinit.RepositoryInitializer-conversion-result.config
index 3bfcc0e..492f5f0 100644
--- a/src/test/resources/org/apache/sling/feature/cpconverter/handlers/jcr_root/apps/asd/config.publish/org.apache.sling.jcr.repoinit.RepositoryInitializer-conversion-result.config
+++ b/src/test/resources/org/apache/sling/feature/cpconverter/handlers/jcr_root/apps/asd/config.publish/org.apache.sling.jcr.repoinit.RepositoryInitializer-conversion-result.config
@@ -24,39 +24,31 @@ create service user su3 with forced path system/cq:services/myfeature/subtree
 set ACL on /conf,/libs,:repository,home(su1)
     remove jcr:modifyProperties for su3
 end
+create service user su-second-script with forced path system/cq:services
+set ACL on /second-script
+    allow jcr:write for group1
+end
+set ACL for group2
+    allow jcr:read on /third-script
+end
 set principal ACL for su1
     allow jcr:read,jcr:modifyProperties on /conf,/content restriction(rep:glob,*)
     allow jcr:read on /conf,/content restriction(rep:itemNames,jcr:primaryType,jcr:mixinTypes) restriction(rep:ntNames,nt:folder)
     allow jcr:read,jcr:write on /conf,/libs,:repository,home(su1)
+    allow jcr:read on /second-script
 end
 set principal ACL for su2 (ACLOptions\=someOption,someOtherOption,namespaced:option)
     allow jcr:read on /tmp
 end
 set principal ACL for su2
     allow jcr:read,jcr:write on /conf,/libs,:repository,home(su1)
+    allow jcr:write on /second-script
 end
 set principal ACL for su3
     deny jcr:versionManagement on /conf,/libs,:repository,home(su1) restriction(rep:glob,/subtree)
-end",\
-"
-create service user su-second-script with forced path system/cq:services
-set ACL on /second-script
-    allow jcr:write for group1
-end
-set principal ACL for su1
-    allow jcr:read on /second-script
+    allow jcr:read on /third-script
 end
 set principal ACL for su-second-script
     allow jcr:read on /second-script
-end
-set principal ACL for su2
-    allow jcr:write on /second-script
-end",\
-"
-set ACL for group2
-    allow jcr:read on /third-script
-end
-set principal ACL for su3
-    allow jcr:read on /third-script
 end"
 ]
\ No newline at end of file