incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r584428 - /incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
Date Sat, 13 Oct 2007 16:55:13 GMT
Author: fmeschbe
Date: Sat Oct 13 09:55:11 2007
New Revision: 584428

URL: http://svn.apache.org/viewvc?rev=584428&view=rev
Log:
Minor: Should use the Node.isNodeType method to check the node type to also catch a positive
if the node is of a node type extending nt:file

Modified:
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java?rev=584428&r1=584427&r2=584428&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/scripting/SlingScriptResolver.java
Sat Oct 13 09:55:11 2007
@@ -31,16 +31,16 @@
  *  followed by the extension of the current request and the desired script
  *  extension.
  *  For example, a "js" script for a GET request on a Resource of type some/type
- *  with request extension "html" should be stored as 
+ *  with request extension "html" should be stored as
  *  <pre>
  *      /sling/scripts/some/type/get.html.js
  *  </pre>
  *  in the repository.
  */
 public class SlingScriptResolver {
-    
+
     private static final Logger log = LoggerFactory.getLogger(SlingScriptResolver.class);
-    
+
     public static final String SCRIPT_BASE_PATH = "/sling/scripts";
 
     /** Try to find a script Node that can process the given request, based on the
@@ -48,49 +48,49 @@
      *  @return null if not found.
      */
     public Node resolveScript(HttpServletRequest req,String scriptExtension) throws Exception
{
-        
+
         final SlingRequestContext ctx = SlingRequestContext.getFromRequest(req);
         final Resource r = ctx.getResource();
         final Session s = ctx.getSession();
         Node result = null;
-        
+
         if(r==null) {
             return null;
         }
-        
+
         String extensionPart = "";
         if(ctx.getExtension() != null && ctx.getExtension().length() > 0) {
             extensionPart = "." + ctx.getExtension();
         }
-        
-        final String scriptPath = 
+
+        final String scriptPath =
             SCRIPT_BASE_PATH
             + "/"
             + r.getResourceType()
             + "/"
-            + req.getMethod().toLowerCase() 
-            + extensionPart 
+            + req.getMethod().toLowerCase()
+            + extensionPart
             + "." + scriptExtension
         ;
-        
+
         if(s.itemExists(scriptPath)) {
             final Item i = s.getItem(scriptPath);
             if(i instanceof Node) {
                 result = (Node)i;
             }
-            
-            // TODO is this the right way of checking for an nt:file node?
-            if(!"nt:file".equals(result.getPrimaryNodeType().getName())) {
+
+            // the node must be (an extension of) nt:file
+            if (!result.isNodeType("nt:file")) {
                 result = null;
             }
         }
-        
+
         if(result!=null) {
             log.info("Found nt:file script node " + result.getPath() + " for Resource=" +
r);
         } else {
             log.debug("nt:file script node not found at path=" + scriptPath + " for Resource="
+ r);
         }
-        
+
         return result;
     }
 }



Mime
View raw message