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

[sling-org-apache-sling-servlets-resolver] branch feature/SLING-10862-more-details-in-servlet-resolver-plugin updated (03a91f2 -> ecd23e9)

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

kwin pushed a change to branch feature/SLING-10862-more-details-in-servlet-resolver-plugin
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-resolver.git.


 discard 03a91f2  SLING-10862 expose more details on servlet candidates in web console plugin
     new ecd23e9  SLING-10862 expose more details on servlet candidates in web console plugin

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (03a91f2)
            \
             N -- N -- N   refs/heads/feature/SLING-10862-more-details-in-servlet-resolver-plugin (ecd23e9)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 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:
 .../sling/servlets/resolver/internal/console/WebConsolePlugin.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

[sling-org-apache-sling-servlets-resolver] 01/01: SLING-10862 expose more details on servlet candidates in web console plugin

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

kwin pushed a commit to branch feature/SLING-10862-more-details-in-servlet-resolver-plugin
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-resolver.git

commit ecd23e9d039258f26e4e67f4f479096b839f8161
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri Oct 8 20:32:51 2021 +0200

    SLING-10862 expose more details on servlet candidates in web console
    plugin
---
 .../internal/console/WebConsolePlugin.java         | 89 ++++++++++++----------
 1 file changed, 50 insertions(+), 39 deletions(-)

diff --git a/src/main/java/org/apache/sling/servlets/resolver/internal/console/WebConsolePlugin.java b/src/main/java/org/apache/sling/servlets/resolver/internal/console/WebConsolePlugin.java
index a2a9cde..bc6c84c 100644
--- a/src/main/java/org/apache/sling/servlets/resolver/internal/console/WebConsolePlugin.java
+++ b/src/main/java/org/apache/sling/servlets/resolver/internal/console/WebConsolePlugin.java
@@ -18,6 +18,25 @@
  */
 package org.apache.sling.servlets.resolver.internal.console;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.api.request.RequestPathInfo;
@@ -35,32 +54,17 @@ import org.apache.sling.engine.impl.request.SlingRequestPathInfo;
 import org.apache.sling.serviceusermapping.ServiceUserMapped;
 import org.apache.sling.servlets.resolver.internal.ResolverConfig;
 import org.apache.sling.servlets.resolver.internal.SlingServletResolver;
+import org.apache.sling.servlets.resolver.internal.bundle.BundledScriptServlet;
 import org.apache.sling.servlets.resolver.internal.helper.ResourceCollector;
 import org.apache.sling.servlets.resolver.internal.resolution.ResolutionCache;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkUtil;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Modified;
 import org.osgi.service.component.annotations.Reference;
 
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
-
 /**
  * If the servlet request path ends with .json, the information is returned in JSON format.
  * Otherwise, an HTML code is returned.
@@ -218,16 +222,7 @@ public class WebConsolePlugin extends HttpServlet {
                 final boolean allowed = SlingServletResolver.isPathAllowed(candidateResource.getPath(),
                         this.executionPaths.get());
 
-                String finalCandidate;
-                if (candidate instanceof SlingScript) {
-                    finalCandidate = candidateResource.getPath();
-                } else {
-                    final boolean isOptingServlet = candidate instanceof OptingServlet;
-                    finalCandidate = candidate.getClass().getName();
-                    if (isOptingServlet) {
-                        finalCandidate += " (OptingServlet)";
-                    }
-                }
+                String finalCandidate = getServletDetails(candidate);
 
                 if (allowed) {
                     allowedServlets.add(finalCandidate);
@@ -423,17 +418,7 @@ public class WebConsolePlugin extends HttpServlet {
                 final boolean allowed = SlingServletResolver.isPathAllowed(candidateResource.getPath(), this.executionPaths.get());
                 pw.print("<li>");
 
-                String candidateStr;
-                if (candidate instanceof SlingScript) {
-                    candidateStr = ResponseUtil.escapeXml(candidateResource.getPath());
-                } else {
-                    final boolean isOptingServlet = candidate instanceof OptingServlet;
-                    candidateStr = ResponseUtil.escapeXml((candidate.getClass().getName()));
-                    if ( isOptingServlet ) {
-                        candidateStr +=" (OptingServlet)";
-                    }
-                }
-
+                String candidateStr = getServletDetails(candidate);
                 if ( !allowed ) {
                     pw.print("<del>" + candidateStr + "</del>");
                 } else {
@@ -444,6 +429,32 @@ public class WebConsolePlugin extends HttpServlet {
         }
     }
 
+    private String getServletDetails(Servlet servlet) {
+        StringBuilder details = new StringBuilder();
+        if (servlet instanceof SlingScript) {
+            SlingScript script = SlingScript.class.cast(servlet);
+            details.append(ResponseUtil.escapeXml(script.getScriptResource().getPath()));
+            details.append(" (Resource Script)");
+        } else {
+            final boolean isOptingServlet = servlet instanceof OptingServlet;
+            details.append(ResponseUtil.escapeXml(servlet.getClass().getName()));
+            if (isOptingServlet) {
+                details.append(" (OptingServlet)");
+            } else {
+                if (servlet instanceof BundledScriptServlet) {
+                    details.append(" (Bundled Script)");
+                } else {
+                    details.append(" (Servlet)");
+                }
+            }
+        }
+        Bundle bundle = FrameworkUtil.getBundle(servlet.getClass());
+        if (bundle != null) {
+            details.append(" in bundle ").append(bundle.getSymbolicName()).append(" (").append(bundle.getBundleId()).append(")");
+        }
+        return details.toString();
+    }
+
     private void titleHtml(final PrintWriter pw, final String title, final String description) {
         tr(pw);
         pw.print("<th colspan='3' class='content container'>");