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 2022/08/05 11:30:43 UTC

[sling-org-apache-sling-resourceresolver] 02/03: SLING-11511 - Allow checking the map/resolve result for an empty path

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

rombert pushed a commit to branch feature/console-improvements
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git

commit ec10105f0ae7ab629dffbb0fd145db6d43bae517
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri Aug 5 11:35:16 2022 +0300

    SLING-11511 - Allow checking the map/resolve result for an empty path
    
    - allow the path to be empty, but not null
    - return a more informative message if no mappings are found
---
 .../impl/console/ResourceResolverWebConsolePlugin.java           | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/console/ResourceResolverWebConsolePlugin.java b/src/main/java/org/apache/sling/resourceresolver/impl/console/ResourceResolverWebConsolePlugin.java
index 186dcea..4ce1629 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/console/ResourceResolverWebConsolePlugin.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/console/ResourceResolverWebConsolePlugin.java
@@ -214,7 +214,7 @@ public class ResourceResolverWebConsolePlugin extends HttpServlet {
 
         final String test = request.getParameter(ATTR_TEST);
         String msg = null;
-        if (test != null && test.length() > 0) {
+        if (test != null) {
 
             ResourceResolver resolver = null;
             try {
@@ -267,7 +267,7 @@ public class ResourceResolverWebConsolePlugin extends HttpServlet {
 
     private static String mappingsToString(Collection<String> allMappings) {
         if ( allMappings.size() == 0 )
-            return ""; // should not happen
+            return "(no mappings)"; // should not happen
         if ( allMappings.size() == 1)
             return allMappings.iterator().next();
 
@@ -630,7 +630,10 @@ public class ResourceResolverWebConsolePlugin extends HttpServlet {
         @Override
         public String getPathInfo() {
             try {
-                return uri.getPath();
+                String path = uri.getPath();
+                if ( path == null )
+                    path = "";
+                return path;
             } catch (URIException ue) {
                 return "";
             }