incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r618997 - /incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java
Date Wed, 06 Feb 2008 14:20:50 GMT
Author: fmeschbe
Date: Wed Feb  6 06:20:49 2008
New Revision: 618997

URL: http://svn.apache.org/viewvc?rev=618997&view=rev
Log:
SLING-227 do not actually use the resolved resource just use it to
test whether a SyntheticResource must be created or not. Finally
retrieve the RequestDispatcher with the resource or the path
depending on what is available.

Modified:
    incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java

Modified: incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java?rev=618997&r1=618996&r2=618997&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java
(original)
+++ incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java
Wed Feb  6 06:20:49 2008
@@ -71,30 +71,31 @@
 
         // check for resource otherwise resolve from path
         RequestDispatcherOptions opts = null;
+        if (resourceType != null) {
+            opts = new RequestDispatcherOptions();
+            opts.put(RequestDispatcherOptions.OPT_FORCE_RESOURCE_TYPE, resourceType);
+        }
+
+        // ensure the path (if set) is absolute and normalized
+        if (path != null) {
+            if (!path.startsWith("/")) {
+                path = request.getResource().getPath() + "/" + path;
+            }
+            path = JcrResourceUtil.normalize(path);
+        }
+        
+        // check the resource
         if (resource == null) {
             if (path == null) {
+                // neither resource nor path is defined, use current resource
                 resource = request.getResource();
             } else {
-                if (!path.startsWith("/")) {
-                    path = request.getResource().getPath() + "/" + JcrResourceUtil.normalize(this.path);
+                // check whether the path (would) resolve, else SyntheticRes.
+                Resource tmp = request.getResourceResolver().resolve(path);
+                if (tmp == null && resourceType != null) {
+                    opts = null; // not needed
+                    resource = new SyntheticResource(path, resourceType);
                 }
-                resource = request.getResourceResolver().getResource(path);
-            }
-        }
-
-        // if resource could not be resolved, create synthetic one
-        if (resource == null) {
-            if (resourceType == null) {
-                TagUtil.log(log, pageContext, "unable to include path " + path
-                    + ". Resource not found and no resource type given.", null);
-                return EVAL_PAGE;
-            }
-            resource = new SyntheticResource(path, resourceType);
-        } else {
-            // overwrite resource type if desired
-            if (resourceType != null && !resourceType.equals(resource.getResourceType()))
{
-                opts = new RequestDispatcherOptions();
-                opts.put(RequestDispatcherOptions.OPT_FORCE_RESOURCE_TYPE, resourceType);
             }
         }
 
@@ -104,8 +105,15 @@
                 // might throw an IOException of course
                 pageContext.getOut().flush();
             }
-            // include the rendered content
-            RequestDispatcher dispatcher = request.getRequestDispatcher(resource, opts);
+            
+            // create a dispatcher for the resource or path
+            RequestDispatcher dispatcher;
+            if (resource != null) {
+                dispatcher = request.getRequestDispatcher(resource, opts);
+            } else {
+                dispatcher = request.getRequestDispatcher(path, opts);
+            }
+            
             if (dispatcher != null) {
                 SlingHttpServletResponse response = new JspSlingHttpServletResponseWrapper(
                     pageContext);



Mime
View raw message