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

rombert pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-fsclassloader.git

commit a2659da38d2622d394683cc5cfe0e8394d2479bb
Author: Radu Cotescu <r...@apache.org>
AuthorDate: Mon Feb 29 23:03:24 2016 +0000

    trivial: changed tabs to spaces
    
    * switched to spaces indentation for 
org.apache.sling.commons.fsclassloader.impl.FSClassLoaderWebConsole
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732967 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../impl/FSClassLoaderWebConsole.java              | 688 ++++++++++-----------
 1 file changed, 344 insertions(+), 344 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderWebConsole.java
 
b/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderWebConsole.java
index 710fcdf..f635bfe 100644
--- 
a/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderWebConsole.java
+++ 
b/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderWebConsole.java
@@ -50,350 +50,350 @@ import org.osgi.service.component.ComponentContext;
 @Component
 @Service
 @Properties({
-               @Property(name = "service.description", value = "Web Console 
for the FileSystem Class Loader"),
-               @Property(name = "service.vendor", value = "The Apache Software 
Foundation"),
-               @Property(name = "felix.webconsole.label", value = 
FSClassLoaderWebConsole.APP_ROOT),
-               @Property(name = "felix.webconsole.title", value = "File System 
Class Loader"),
-               @Property(name = "felix.webconsole.css", value = { 
FSClassLoaderWebConsole.RES_LOC
-                               + "/prettify.css" }),
-               @Property(name = "felix.webconsole.category", value = "Sling") 
})
+        @Property(name = "service.description", value = "Web Console for the 
FileSystem Class Loader"),
+        @Property(name = "service.vendor", value = "The Apache Software 
Foundation"),
+        @Property(name = "felix.webconsole.label", value = 
FSClassLoaderWebConsole.APP_ROOT),
+        @Property(name = "felix.webconsole.title", value = "File System Class 
Loader"),
+        @Property(name = "felix.webconsole.css", value = { 
FSClassLoaderWebConsole.RES_LOC
+                + "/prettify.css" }),
+        @Property(name = "felix.webconsole.category", value = "Sling") })
 public class FSClassLoaderWebConsole extends AbstractWebConsolePlugin {
 
-       static final String APP_ROOT = "fsclassloader";
-
-       static final String RES_LOC = APP_ROOT + "/res/ui";
-
-       /**
-        * Represents a set of class, java and deps files for a script.
-        */
-       private static class ScriptFiles {
-
-               /**
-                * Gets the script associated with the file.
-                * 
-                * @param file
-                *            the file to find the associate script
-                * @return the associated script
-                */
-               public static String getScript(File file) {
-                       String relative = file.getAbsolutePath().substring(
-                                       root.getAbsolutePath().length());
-                       String script = remove(relative, "/org/apache/jsp");
-                       script = remove(script, ".class");
-                       script = remove(script, ".java");
-                       script = remove(script, ".deps");
-                       if (File.separatorChar == '\\') {
-                               script = script.replace(File.separatorChar, 
'/');
-                       }
-                       return StringUtils.substringBeforeLast(script, "_") + 
"."
-                                       + 
StringUtils.substringAfterLast(script, "_");
-               }
-
-               private static String remove(String orig, String rem) {
-                       return orig.replace(rem, "");
-               }
-
-               private final String classFile;
-               private final String depsFile;
-
-               private final String javaFile;
-
-               private final String script;
-
-               public ScriptFiles(File file) {
-                       script = getScript(file);
-
-                       String relative = file.getAbsolutePath().substring(
-                                       root.getAbsolutePath().length());
-
-                       relative = remove(relative, ".class");
-                       relative = remove(relative, ".deps");
-                       relative = remove(relative, ".java");
-                       classFile = relative + ".class";
-                       depsFile = relative + ".deps";
-                       javaFile = relative + ".java";
-               }
-
-               public String getClassFile() {
-                       return classFile;
-               }
-
-               public String getDepsFile() {
-                       return depsFile;
-               }
-
-               public String getJavaFile() {
-                       return javaFile;
-               }
-
-               public String getScript() {
-                       return script;
-               }
-
-       }
-
-       /**
-        * The root under which the class files are under
-        */
-       private static File root;
-
-       /**
-        * The serialization UID
-        */
-       private static final long serialVersionUID = -5728679635644481848L;
-
-       /**
-        * The servlet configuration
-        */
-       private ServletConfig config;
-
-       /**
-        * Activate this component. Create the root directory.
-        * 
-        * @param componentContext the component context
-        * @throws MalformedURLException
-        */
-       @Activate
-       @SuppressWarnings("unused")
-       protected void activate(final ComponentContext componentContext)
-                       throws MalformedURLException {
-               // get the file root
-               root = new 
File(componentContext.getBundleContext().getDataFile(""),
-                               "classes");
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see javax.servlet.Servlet#destroy()
-        */
-       public void destroy() {
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see javax.servlet.Servlet#service(javax.servlet.ServletRequest,
-        * javax.servlet.ServletResponse)
-        */
-       protected void doGet(HttpServletRequest request,
-                       HttpServletResponse response) throws ServletException, 
IOException {
-               String file = request.getParameter("download");
-               File toDownload = new File(root + file);
-               if (!StringUtils.isEmpty(file)) {
-                       if (isValid(toDownload)) {
-                               InputStream is = null;
-                               try {
-                                       is = new FileInputStream(toDownload);
-                                       
response.setHeader("Content-disposition",
-                                                       "attachment; filename=" 
+ toDownload.getName());
-                                       IOUtils.copy(is, 
response.getOutputStream());
-                               } finally {
-                                       IOUtils.closeQuietly(is);
-                                       
IOUtils.closeQuietly(response.getOutputStream());
-                               }
-                       } else {
-                               response.sendError(404, "File " + file + " not 
found");
-                       }
-               } else if (request.getRequestURI().endsWith(RES_LOC + 
"/prettify.css")) {
-                       response.setContentType("text/css");
-                       IOUtils.copy(
-                                       
getClass().getClassLoader().getResourceAsStream(
-                                                       
"/res/ui/prettify.css"), response.getOutputStream());
-               } else if (request.getRequestURI().endsWith(RES_LOC + 
"/prettify.js")) {
-                       response.setContentType("application/javascript");
-                       IOUtils.copy(
-                                       
getClass().getClassLoader().getResourceAsStream(
-                                                       "/res/ui/prettify.js"), 
response.getOutputStream());
-               } else {
-                       super.doGet(request, response);
-               }
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see org.apache.felix.webconsole.AbstractWebConsolePlugin#getLabel()
-        */
-       @Override
-       public String getLabel() {
-               return "fsclassloader";
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see javax.servlet.Servlet#getServletConfig()
-        */
-       public ServletConfig getServletConfig() {
-               return this.config;
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see javax.servlet.Servlet#getServletInfo()
-        */
-       public String getServletInfo() {
-               return "";
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see org.apache.felix.webconsole.AbstractWebConsolePlugin#getTitle()
-        */
-       @Override
-       public String getTitle() {
-               return "File System Class Loader";
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
-        */
-       public void init(ServletConfig config) throws ServletException {
-               this.config = config;
-       }
-
-       /**
-        * Checks whether the specified file is a file and is underneath the 
root
-        * directory.
-        * 
-        * @param file
-        *            the file to check
-        * @return false if not a file or not under the root directory, true
-        *         otherwise
-        * @throws IOException
-        */
-       private boolean isValid(File file) throws IOException {
-               if (file.isFile()) {
-                       File parent = file.getCanonicalFile().getAbsoluteFile()
-                                       .getParentFile();
-                       while (parent != null) {
-                               if 
(parent.getCanonicalPath().equals(root.getCanonicalPath())) {
-                                       return true;
-                               }
-                               parent = parent.getParentFile();
-                       }
-               }
-               return false;
-       }
-
-       /**
-        * Reads all of the files under the current file.
-        * 
-        * @param file
-        *            the root file
-        * @param scripts
-        *            the map of scripts
-        * @throws IOException
-        *             an exception occurs reading the files
-        */
-       private void readFiles(File file, Map<String, ScriptFiles> scripts)
-                       throws IOException {
-               if (file.isDirectory()) {
-                       File[] children = file.listFiles();
-                       if (children != null) {
-                               for (File f : children) {
-                                       readFiles(f, scripts);
-                               }
-                       }
-               } else {
-                       String script = ScriptFiles.getScript(file);
-                       if (!scripts.containsKey(script)
-                                       && file.getName().endsWith(".java")) {
-                               scripts.put(script, new ScriptFiles(file));
-                       }
-               }
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * 
org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax
-        * .servlet.http.HttpServletRequest, 
javax.servlet.http.HttpServletResponse)
-        */
-       @Override
-       protected void renderContent(HttpServletRequest request,
-                       HttpServletResponse response) throws ServletException, 
IOException {
-               Map<String, ScriptFiles> scripts = new LinkedHashMap<String, 
ScriptFiles>();
-               readFiles(root, scripts);
-
-               Writer w = response.getWriter();
-
-               w.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + 
RES_LOC
-                               + "/prettify.css\"></link>");
-               w.write("<script type=\"text/javascript\" src=\"" + RES_LOC
-                               + "/prettify.js\"></script>");
-               w.write("<script>$(document).ready(prettyPrint);</script>");
-               w.write("<style>.prettyprint ol.linenums > li { 
list-style-type: decimal; } pre.prettyprint { white-space: pre-wrap; 
}</style>");
-               String file = request.getParameter("view");
-               File toView = new File(root + file);
-               if (!StringUtils.isEmpty(file)) {
-                       if (isValid(toView)) {
-
-                               w.write("<p class=\"statline 
ui-state-highlight\">Viewing Script: "
-                                               + root + file + 
"</p><br/><br/>");
-                               
-                               ScriptFiles scriptFiles = new 
ScriptFiles(toView);
-
-                               w.write("<table class=\"nicetable 
ui-widget\">");
-                               w.write("<tr class=\"header 
ui-widget-header\">");
-                               w.write("<th>Script</th>");
-                               w.write("<th>Class</th>");
-                               w.write("<th>Deps</th>");
-                               w.write("<th>Java</th>");
-                               w.write("</tr>");
-                               w.write("<tr class=\"ui-state-default\">");
-                               w.write("<td>" + scriptFiles.getScript() + 
"</td>");
-                               w.write("<td>[<a href=\"?download="
-                                               + scriptFiles.getClassFile()
-                                               + "\" 
target=\"_blank\">download</a>]</td>");
-                               w.write("<td>[<a href=\"?download="
-                                               + scriptFiles.getDepsFile()
-                                               + "\" 
target=\"_blank\">download</a>]</td>");
-                               w.write("<td>[<a href=\"?download="
-                                               + scriptFiles.getJavaFile()
-                                               + "\" 
target=\"_blank\">download</a>]</td>");
-                               w.write("</tr>");
-                               w.write("</table><br/><br/>");
-                               InputStream is = null;
-                               try {
-                                       is = new FileInputStream(toView);
-                                       String contents = IOUtils.toString(is);
-                                       w.write("<pre class=\"prettyprint 
linenums\">");
-                                       StringEscapeUtils.escapeHtml(w, 
contents);
-                                       w.write("</pre>");
-                               } finally {
-                                       IOUtils.closeQuietly(is);
-                               }
-                       } else {
-                               response.sendError(404, "File " + file + " not 
found");
-                       }
-               } else {
-
-                       w.write("<p class=\"statline ui-state-highlight\">File 
System ClassLoader Root: "
-                                       + root + "</p>");
-
-                       w.write("<table class=\"nicetable ui-widget\">");
-                       w.write("<tr class=\"header ui-widget-header\">");
-                       w.write("<th>View</th>");
-                       w.write("<th>Script</th>");
-                       w.write("</tr>");
-                       int i = 0;
-                       for (ScriptFiles scriptFiles : scripts.values()) {
-                               w.write("<tr class=\"" + (i % 2 == 0 ? "even" : 
"odd")
-                                               + " ui-state-default\">");
-                               w.write("<td>[<a href=\"?view=" + 
scriptFiles.getJavaFile()
-                                               + "\">view</a>]</td>");
-                               w.write("<td>" + scriptFiles.getScript() + 
"</td>");
-                               w.write("</tr>");
-                               i++;
-                       }
-                       w.write("</table>");
-               }
-       }
+    static final String APP_ROOT = "fsclassloader";
+
+    static final String RES_LOC = APP_ROOT + "/res/ui";
+
+    /**
+     * Represents a set of class, java and deps files for a script.
+     */
+    private static class ScriptFiles {
+
+        /**
+         * Gets the script associated with the file.
+         *
+         * @param file
+         *            the file to find the associate script
+         * @return the associated script
+         */
+        public static String getScript(File file) {
+            String relative = file.getAbsolutePath().substring(
+                    root.getAbsolutePath().length());
+            String script = remove(relative, "/org/apache/jsp");
+            script = remove(script, ".class");
+            script = remove(script, ".java");
+            script = remove(script, ".deps");
+            if (File.separatorChar == '\\') {
+                script = script.replace(File.separatorChar, '/');
+            }
+            return StringUtils.substringBeforeLast(script, "_") + "."
+                    + StringUtils.substringAfterLast(script, "_");
+        }
+
+        private static String remove(String orig, String rem) {
+            return orig.replace(rem, "");
+        }
+
+        private final String classFile;
+        private final String depsFile;
+
+        private final String javaFile;
+
+        private final String script;
+
+        public ScriptFiles(File file) {
+            script = getScript(file);
+
+            String relative = file.getAbsolutePath().substring(
+                    root.getAbsolutePath().length());
+
+            relative = remove(relative, ".class");
+            relative = remove(relative, ".deps");
+            relative = remove(relative, ".java");
+            classFile = relative + ".class";
+            depsFile = relative + ".deps";
+            javaFile = relative + ".java";
+        }
+
+        public String getClassFile() {
+            return classFile;
+        }
+
+        public String getDepsFile() {
+            return depsFile;
+        }
+
+        public String getJavaFile() {
+            return javaFile;
+        }
+
+        public String getScript() {
+            return script;
+        }
+
+    }
+
+    /**
+     * The root under which the class files are under
+     */
+    private static File root;
+
+    /**
+     * The serialization UID
+     */
+    private static final long serialVersionUID = -5728679635644481848L;
+
+    /**
+     * The servlet configuration
+     */
+    private ServletConfig config;
+
+    /**
+     * Activate this component. Create the root directory.
+     *
+     * @param componentContext the component context
+     * @throws MalformedURLException
+     */
+    @Activate
+    @SuppressWarnings("unused")
+    protected void activate(final ComponentContext componentContext)
+            throws MalformedURLException {
+        // get the file root
+        root = new File(componentContext.getBundleContext().getDataFile(""),
+                "classes");
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.Servlet#destroy()
+     */
+    public void destroy() {
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.Servlet#service(javax.servlet.ServletRequest,
+     * javax.servlet.ServletResponse)
+     */
+    protected void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException, IOException 
{
+        String file = request.getParameter("download");
+        File toDownload = new File(root + file);
+        if (!StringUtils.isEmpty(file)) {
+            if (isValid(toDownload)) {
+                InputStream is = null;
+                try {
+                    is = new FileInputStream(toDownload);
+                    response.setHeader("Content-disposition",
+                            "attachment; filename=" + toDownload.getName());
+                    IOUtils.copy(is, response.getOutputStream());
+                } finally {
+                    IOUtils.closeQuietly(is);
+                    IOUtils.closeQuietly(response.getOutputStream());
+                }
+            } else {
+                response.sendError(404, "File " + file + " not found");
+            }
+        } else if (request.getRequestURI().endsWith(RES_LOC + 
"/prettify.css")) {
+            response.setContentType("text/css");
+            IOUtils.copy(
+                    getClass().getClassLoader().getResourceAsStream(
+                            "/res/ui/prettify.css"), 
response.getOutputStream());
+        } else if (request.getRequestURI().endsWith(RES_LOC + "/prettify.js")) 
{
+            response.setContentType("application/javascript");
+            IOUtils.copy(
+                    getClass().getClassLoader().getResourceAsStream(
+                            "/res/ui/prettify.js"), 
response.getOutputStream());
+        } else {
+            super.doGet(request, response);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.felix.webconsole.AbstractWebConsolePlugin#getLabel()
+     */
+    @Override
+    public String getLabel() {
+        return "fsclassloader";
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.Servlet#getServletConfig()
+     */
+    public ServletConfig getServletConfig() {
+        return this.config;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.Servlet#getServletInfo()
+     */
+    public String getServletInfo() {
+        return "";
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.felix.webconsole.AbstractWebConsolePlugin#getTitle()
+     */
+    @Override
+    public String getTitle() {
+        return "File System Class Loader";
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
+     */
+    public void init(ServletConfig config) throws ServletException {
+        this.config = config;
+    }
+
+    /**
+     * Checks whether the specified file is a file and is underneath the root
+     * directory.
+     *
+     * @param file
+     *            the file to check
+     * @return false if not a file or not under the root directory, true
+     *         otherwise
+     * @throws IOException
+     */
+    private boolean isValid(File file) throws IOException {
+        if (file.isFile()) {
+            File parent = file.getCanonicalFile().getAbsoluteFile()
+                    .getParentFile();
+            while (parent != null) {
+                if (parent.getCanonicalPath().equals(root.getCanonicalPath())) 
{
+                    return true;
+                }
+                parent = parent.getParentFile();
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Reads all of the files under the current file.
+     *
+     * @param file
+     *            the root file
+     * @param scripts
+     *            the map of scripts
+     * @throws IOException
+     *             an exception occurs reading the files
+     */
+    private void readFiles(File file, Map<String, ScriptFiles> scripts)
+            throws IOException {
+        if (file.isDirectory()) {
+            File[] children = file.listFiles();
+            if (children != null) {
+                for (File f : children) {
+                    readFiles(f, scripts);
+                }
+            }
+        } else {
+            String script = ScriptFiles.getScript(file);
+            if (!scripts.containsKey(script)
+                    && file.getName().endsWith(".java")) {
+                scripts.put(script, new ScriptFiles(file));
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax
+     * .servlet.http.HttpServletRequest, 
javax.servlet.http.HttpServletResponse)
+     */
+    @Override
+    protected void renderContent(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException, IOException 
{
+        Map<String, ScriptFiles> scripts = new LinkedHashMap<String, 
ScriptFiles>();
+        readFiles(root, scripts);
+
+        Writer w = response.getWriter();
+
+        w.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + RES_LOC
+                + "/prettify.css\"></link>");
+        w.write("<script type=\"text/javascript\" src=\"" + RES_LOC
+                + "/prettify.js\"></script>");
+        w.write("<script>$(document).ready(prettyPrint);</script>");
+        w.write("<style>.prettyprint ol.linenums > li { list-style-type: 
decimal; } pre.prettyprint { white-space: pre-wrap; }</style>");
+        String file = request.getParameter("view");
+        File toView = new File(root + file);
+        if (!StringUtils.isEmpty(file)) {
+            if (isValid(toView)) {
+
+                w.write("<p class=\"statline ui-state-highlight\">Viewing 
Script: "
+                        + root + file + "</p><br/><br/>");
+
+                ScriptFiles scriptFiles = new ScriptFiles(toView);
+
+                w.write("<table class=\"nicetable ui-widget\">");
+                w.write("<tr class=\"header ui-widget-header\">");
+                w.write("<th>Script</th>");
+                w.write("<th>Class</th>");
+                w.write("<th>Deps</th>");
+                w.write("<th>Java</th>");
+                w.write("</tr>");
+                w.write("<tr class=\"ui-state-default\">");
+                w.write("<td>" + scriptFiles.getScript() + "</td>");
+                w.write("<td>[<a href=\"?download="
+                        + scriptFiles.getClassFile()
+                        + "\" target=\"_blank\">download</a>]</td>");
+                w.write("<td>[<a href=\"?download="
+                        + scriptFiles.getDepsFile()
+                        + "\" target=\"_blank\">download</a>]</td>");
+                w.write("<td>[<a href=\"?download="
+                        + scriptFiles.getJavaFile()
+                        + "\" target=\"_blank\">download</a>]</td>");
+                w.write("</tr>");
+                w.write("</table><br/><br/>");
+                InputStream is = null;
+                try {
+                    is = new FileInputStream(toView);
+                    String contents = IOUtils.toString(is);
+                    w.write("<pre class=\"prettyprint linenums\">");
+                    StringEscapeUtils.escapeHtml(w, contents);
+                    w.write("</pre>");
+                } finally {
+                    IOUtils.closeQuietly(is);
+                }
+            } else {
+                response.sendError(404, "File " + file + " not found");
+            }
+        } else {
+
+            w.write("<p class=\"statline ui-state-highlight\">File System 
ClassLoader Root: "
+                    + root + "</p>");
+
+            w.write("<table class=\"nicetable ui-widget\">");
+            w.write("<tr class=\"header ui-widget-header\">");
+            w.write("<th>View</th>");
+            w.write("<th>Script</th>");
+            w.write("</tr>");
+            int i = 0;
+            for (ScriptFiles scriptFiles : scripts.values()) {
+                w.write("<tr class=\"" + (i % 2 == 0 ? "even" : "odd")
+                        + " ui-state-default\">");
+                w.write("<td>[<a href=\"?view=" + scriptFiles.getJavaFile()
+                        + "\">view</a>]</td>");
+                w.write("<td>" + scriptFiles.getScript() + "</td>");
+                w.write("</tr>");
+                i++;
+            }
+            w.write("</table>");
+        }
+    }
 }

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

Reply via email to