You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:49:37 UTC

[sling-org-apache-sling-jcr-repoinit] 10/17: SLING-5923 - Support marker in model.section.name config param, same meaning as empty string

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

rombert pushed a commit to annotated tag org.apache.sling.jcr.repoinit-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-repoinit.git

commit 4bb31e7159ae61ea8d714fc515a395ebce1fa179
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jul 29 12:17:45 2016 +0000

    SLING-5923 - Support <RAW> marker in model.section.name config param, same meaning as empty string
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/repoinit@1754501 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/jcr/repoinit/impl/RepositoryInitializer.java    |  8 ++++++--
 .../sling/jcr/repoinit/RepositoryInitializerTest.java     | 15 ++++++++-------
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
index 0c948f8..87b55d7 100644
--- a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
+++ b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
@@ -66,6 +66,10 @@ public class RepositoryInitializer implements SlingRepositoryInitializer {
 
     public static final String DEFAULT_TEXT_URL = "context:/resources/provisioning/model.txt";
     
+    /** Special value for model section name config parameter, which indicates that
+     *  the configured URL provides raw repoinit statements */ 
+    public static final String RAW_SECTION_MARKER = "<RAW>";
+    
     @Property(
             label="Text URL", 
             description="URL of the source text that provides repoinit statements."
@@ -80,7 +84,7 @@ public class RepositoryInitializer implements SlingRepositoryInitializer {
             label="Model section name", 
             description=
                 "Optional provisioning model additional section name (without leading colon) used to extract"
-                + " repoinit statements from the raw text provided by our text URL. Leave empty to consider the content"
+                + " repoinit statements from the raw text provided by our text URL. Leave empty or set to <RAW> to consider the content"
                 + " provided by that URL to already be in repoinit format", 
             value=DEFAULT_MODEL_SECTION_NAME)
     public static final String PROP_MODEL_SECTION_NAME = "model.section.name";
@@ -138,7 +142,7 @@ public class RepositoryInitializer implements SlingRepositoryInitializer {
         final String rawText = getRawRepoInitText();
         log.debug("Raw text from {}: \n{}", textURL, rawText);
         log.info("Got {} characters from {}", rawText.length(), textURL);
-        final boolean parseRawText = modelSectionName.trim().length() == 0;
+        final boolean parseRawText = modelSectionName.trim().length() == 0 || RAW_SECTION_MARKER.equals(modelSectionName);
         if (parseRawText) {
             log.info("Parsing raw repoinit statements from {}", textURL);
             return rawText;
diff --git a/src/test/java/org/apache/sling/jcr/repoinit/RepositoryInitializerTest.java b/src/test/java/org/apache/sling/jcr/repoinit/RepositoryInitializerTest.java
index 60615e9..4c977a3 100644
--- a/src/test/java/org/apache/sling/jcr/repoinit/RepositoryInitializerTest.java
+++ b/src/test/java/org/apache/sling/jcr/repoinit/RepositoryInitializerTest.java
@@ -65,20 +65,21 @@ public class RepositoryInitializerTest {
     public static Collection<Object[]> data() {
         final List<Object []> result = new ArrayList<Object[]>();
         
-        result.add(new Object[] { "All empty, just setup + parsing", "", false });
-        result.add(new Object[] { "Using provisioning model", "SECTION_" + UUID.randomUUID(), true }); 
-        result.add(new Object[] { "Raw repoinit/empty section", "", true}); 
-        result.add(new Object[] { "Default value of model section config", null, true}); 
+        result.add(new Object[] { "All empty, just setup + parsing", "", false, false });
+        result.add(new Object[] { "Using provisioning model", "SECTION_" + UUID.randomUUID(), true, true }); 
+        result.add(new Object[] { "Raw repoinit/empty section", "", false, true}); 
+        result.add(new Object[] { "Raw repoinit/special section name", "<RAW>", false, true}); 
+        result.add(new Object[] { "Default value of model section config", null, true, true}); 
         return result;
     }
     
-    public RepositoryInitializerTest(String description, String modelSection, boolean testLogin) throws IOException {
+    public RepositoryInitializerTest(String description, String modelSection, boolean useProvisioningModel, boolean testLogin) throws IOException {
         serviceUser = getClass().getSimpleName() + "-" + UUID.randomUUID();
         
         String txt = "create service user " + serviceUser; 
-        if(modelSection == null) {
+        if(useProvisioningModel && modelSection == null) {
             txt = "[feature name=foo]\n[:repoinit]\n" + txt; 
-        } else if(modelSection.length() > 0) {
+        } else if(useProvisioningModel) {
             txt = "[feature name=bar]\n[:" + modelSection + "]\n" + txt; 
         }
         this.repoInitText = txt + "\n";

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.