You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2009/08/14 10:29:21 UTC

svn commit: r804126 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java

Author: cziegeler
Date: Fri Aug 14 08:29:20 2009
New Revision: 804126

URL: http://svn.apache.org/viewvc?rev=804126&view=rev
Log:
SLING-1085 - Check for empty value before creating the mapping.

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java?rev=804126&r1=804125&r2=804126&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/MapEntries.java Fri Aug 14 08:29:20 2009
@@ -305,29 +305,31 @@
             // what is stored in the sling:vanityPath property
             String[] pVanityPaths = row.get("sling:vanityPath", new String[0]);
             for (String pVanityPath : pVanityPaths) {
-                String url = "^" + ANY_SCHEME_HOST
-                    + String.valueOf(pVanityPath);
+                // check for empty values
+                if ( pVanityPath != null && pVanityPath.trim().length() > 0 ) {
+                    String url = "^" + ANY_SCHEME_HOST + pVanityPath.trim();
+
+                    // redirect target is the node providing the sling:vanityPath
+                    // property (or its parent if the node is called jcr:content)
+                    String redirect = resource.getPath();
+                    if (ResourceUtil.getName(redirect).equals("jcr:content")) {
+                        redirect = ResourceUtil.getParent(redirect);
+                    }
 
-                // redirect target is the node providing the sling:vanityPath
-                // property (or its parent if the node is called jcr:content)
-                String redirect = resource.getPath();
-                if (ResourceUtil.getName(redirect).equals("jcr:content")) {
-                    redirect = ResourceUtil.getParent(redirect);
+                    // whether the target is attained by a 302/FOUND or by an
+                    // internal redirect is defined by the sling:redirect property
+                    int status = row.get("sling:redirect", false)
+                            ? HttpServletResponse.SC_FOUND
+                            : -1;
+
+                    // 1. entry with exact match
+                    entries.add(new MapEntry(url + "$", status, false, redirect
+                        + ".html"));
+
+                    // 2. entry with match supporting selectors and extension
+                    entries.add(new MapEntry(url + "(\\..*)", status, false,
+                        redirect + "$1"));
                 }
-
-                // whether the target is attained by a 302/FOUND or by an
-                // internal redirect is defined by the sling:redirect property
-                int status = row.get("sling:redirect", false)
-                        ? HttpServletResponse.SC_FOUND
-                        : -1;
-
-                // 1. entry with exact match
-                entries.add(new MapEntry(url + "$", status, false, redirect
-                    + ".html"));
-
-                // 2. entry with match supporting selectors and extension
-                entries.add(new MapEntry(url + "(\\..*)", status, false,
-                    redirect + "$1"));
             }
         }
     }