sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-scripting-sightly-repl] 10/14: SLING-5126 - Provide information on the Sightly REPL Java tab on how to enable source code generation
Date Tue, 07 Nov 2017 10:12:04 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 6bb0ca0f7ea73093c33896b726d5fc1ac0c84ce0
Author: Radu Cotescu <radu@apache.org>
AuthorDate: Thu Oct 8 10:53:43 2015 +0000

    SLING-5126 - Provide information on the Sightly REPL Java tab on how to enable source
code generation
    
    * added link to engine configuration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/scripting/sightly/repl@1707473
13f79535-47bb-0310-9956-ffa450edef68
---
 .../scripting/sightly/repl/REPLJavaSourceCodeServlet.java  | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/scripting/sightly/repl/REPLJavaSourceCodeServlet.java
b/src/main/java/org/apache/sling/scripting/sightly/repl/REPLJavaSourceCodeServlet.java
index 35411c3..e8a1939 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/repl/REPLJavaSourceCodeServlet.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/repl/REPLJavaSourceCodeServlet.java
@@ -63,7 +63,18 @@ public class REPLJavaSourceCodeServlet extends SlingSafeMethodsServlet
{
     @Override
     protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
         response.setContentType("text/plain");
-        response.getWriter().write(getClassSourceCode());
+        String sourceCode = getClassSourceCode();
+        if (sourceCode.length() == 0) {
+            StringBuilder configurationLink = new StringBuilder();
+            configurationLink.append(request.getScheme()).append("://").append(request.getServerName());
+            if (request.getServerPort() != 80) {
+                configurationLink.append(":").append(request.getServerPort());
+            }
+            configurationLink.append(request.getContextPath()).append("/system/console/configMgr/org.apache.sling.scripting.sightly.impl.engine.SightlyEngineConfiguration");
+            response.getWriter().write("/**\n * Please enable development mode at\n * " +
configurationLink.toString() + "\n */");
+        } else {
+            response.getWriter().write(getClassSourceCode());
+        }
     }
 
     private String getClassSourceCode() {
@@ -74,7 +85,6 @@ public class REPLJavaSourceCodeServlet extends SlingSafeMethodsServlet {
                     return IOUtils.toString(new FileInputStream(classFile), "UTF-8");
                 } catch (IOException e) {
                     LOGGER.error("Unable to read file " + classFile.getAbsolutePath(), e);
-                    return "";
                 }
             }
         }

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

Mime
View raw message