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:34 UTC

[sling-org-apache-sling-jcr-repoinit] 07/17: SLING-5917 parseRawText flag in getRepoInitText() is ambiguous

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 2ea4d7ff8b650049e72b52edc0437817c310dbc4
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Fri Jul 29 07:11:24 2016 +0000

    SLING-5917 parseRawText flag in getRepoInitText() is ambiguous
    
    fix meaning of parseRawText flag and make getRepoInitText() more readable
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/repoinit@1754481 13f79535-47bb-0310-9956-ffa450edef68
---
 .../jcr/repoinit/impl/RepositoryInitializer.java   | 39 +++++++++++-----------
 1 file changed, 19 insertions(+), 20 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 62a433d..0c948f8 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
@@ -135,33 +135,32 @@ public class RepositoryInitializer implements SlingRepositoryInitializer {
     }
     
     private String getRepoInitText() {
-        final boolean parseRawText = modelSectionName.trim().length() > 0;
-        if(parseRawText) {
-            log.info("Reading repoinit statements from {}", textURL);
+        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;
+        if (parseRawText) {
+            log.info("Parsing raw repoinit statements from {}", textURL);
+            return rawText;
         } else {
-            log.info("Extracting repoinit statements from section {} of provisioning model {}", modelSectionName, textURL);
-        }
-        String result = getRawRepoInitText();
-        log.debug("Raw text from {}: \n{}", textURL, result);
-        log.info("Got {} characters from {}", result.length(), textURL);
-        if(parseRawText) {
-            final StringReader r = new StringReader(result);
+            log.info("Extracting repoinit statements from section '{}' of provisioning model {}", modelSectionName, textURL);
+            final StringReader reader = new StringReader(rawText);
             try {
-                final Model m = ModelReader.read(r, textURL);
-                final StringBuilder b = new StringBuilder();
-                for(Feature f : m.getFeatures()) {
-                    for(Section s : f.getAdditionalSections(modelSectionName)) {
-                        b.append("# ").append(modelSectionName).append(" from ").append(f.getName()).append("\n");
-                        b.append("# ").append(s.getComment()).append("\n");
-                        b.append(s.getContents()).append("\n");
+                final Model model = ModelReader.read(reader, textURL);
+                final StringBuilder sb = new StringBuilder();
+                for (final Feature feature : model.getFeatures()) {
+                    for (final Section section : feature.getAdditionalSections(modelSectionName)) {
+                        sb.append("# ").append(modelSectionName).append(" from ").append(feature.getName()).append("\n");
+                        sb.append("# ").append(section.getComment()).append("\n");
+                        sb.append(section.getContents()).append("\n");
                     }
                 }
-                result = b.toString();
+                return sb.toString();
             } catch (IOException e) {
-                result = "";
                 log.warn("Error parsing provisioning model from " + textURL, e);
+                return "";
             }
         }
-        return result;
     }
+
 }

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