incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r587157 - in /incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling: resource/JcrNodeResource.java servlet/MicroSlingServlet.java
Date Mon, 22 Oct 2007 17:13:30 GMT
Author: bdelacretaz
Date: Mon Oct 22 10:13:30 2007
New Revision: 587157

URL: http://svn.apache.org/viewvc?rev=587157&view=rev
Log:
SLING-70 - fix mapping to StreamServlet, and add some logging to MicroSlingServlet to expose
Servlets + scripts resolution

Modified:
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
    incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java?rev=587157&r1=587156&r2=587157&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
Mon Oct 22 10:13:30 2007
@@ -93,6 +93,6 @@
 
     /** Filter a node type name so that it can be used in a resource type value */
     public static String filterName(String name) {
-        return name.toLowerCase().replaceAll("\\:","_");
+        return name.toLowerCase().replaceAll("\\:","/");
     }
 }

Modified: incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java?rev=587157&r1=587156&r2=587157&view=diff
==============================================================================
--- incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
(original)
+++ incubator/sling/whiteboard/microsling/src/main/java/org/apache/sling/microsling/servlet/MicroSlingServlet.java
Mon Oct 22 10:13:30 2007
@@ -45,6 +45,8 @@
 import org.apache.sling.microsling.services.MicroslingServiceLocator;
 import org.apache.sling.microsling.slingservlets.DefaultSlingServlet;
 import org.apache.sling.microsling.slingservlets.StreamServlet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The main microsling servlet: apply Filters to the request using our
@@ -64,6 +66,8 @@
     private SlingScriptResolver scriptResolver;
 
     private DefaultSlingServlet defaultSlingServlet;
+    
+    private static final Logger log = LoggerFactory.getLogger(MicroSlingServlet.class);
 
     @Override
     public void init() throws ServletException {
@@ -77,7 +81,9 @@
 
         // TODO use OSGi to setup this list
         servlets = new HashMap<String, Servlet>();
-        addServlet("nt:file", new StreamServlet());
+        
+        // TODO use a utility class to map nt:file to the magic NODETYPES path 
+        addServlet("NODETYPES/nt/file", new StreamServlet());
 
         try {
 
@@ -144,7 +150,10 @@
                 // no typed servlet, so lets try scripting
                 boolean scriptExists = scriptResolver.evaluateScript(req, resp);
                 if (!scriptExists) {
-                    // use the default servlet if there is script
+                    if(log.isDebugEnabled()) {
+                        final Resource r = SlingRequestContext.Accessor.getSlingRequestContext(req).getResource();
+                        log.debug("No specific Servlet or script found for Resource " + r
+ ", using default Servlet");
+                    }
                     delegateToSlingServlet(defaultSlingServlet, req, resp);
                 }
             }
@@ -166,7 +175,17 @@
         // use the resource type to select a servlet
         final Resource r = SlingRequestContext.Accessor.getSlingRequestContext(req).getResource();

         String type = (r == null ? null : r.getResourceType());
-        return (type != null) ? servlets.get(type) : null;
+        final Servlet result = (type != null) ? servlets.get(type) : null;
+        
+        if(log.isDebugEnabled()) {
+            if(result==null) {
+                log.debug("No Servlet found for resource type " + type);
+            } else {
+                log.debug("Using Servlet class " + result.getClass().getSimpleName() + "
for resource type " + type);
+             }
+        }
+        
+        return result;
     }
 
     /** Delegate to the given SlingServlet, based on the request HTTP method */



Mime
View raw message