incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r617490 - /incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java
Date Fri, 01 Feb 2008 12:57:59 GMT
Author: bdelacretaz
Date: Fri Feb  1 04:57:56 2008
New Revision: 617490

URL: http://svn.apache.org/viewvc?rev=617490&view=rev
Log:
require ServletResolver and MimeTypeService in service method, avoids hard to diagnose problems
if those are missing

Modified:
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java?rev=617490&r1=617489&r2=617490&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java
(original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java
Fri Feb  1 04:57:56 2008
@@ -219,15 +219,25 @@
     public void service(HttpServletRequest servletRequest,
             HttpServletResponse servletResponse) throws IOException {
 
-        // the resource manager factory may be missing
-        if (getResourceResolverFactory() == null) {
-            log.error("service: Cannot handle requests without a ResourceResolverFactory");
-            sendError(HttpServletResponse.SC_NOT_FOUND,
-                "No resource can be found", null, servletRequest,
-                servletResponse);
+        // check that we have all required services
+        String missing = null;
+        if(getResourceResolverFactory() == null) {
+            missing = "ResourceResolverFactory";
+        } else if(getServletResolver() == null) {
+            missing = "ServletResolver";
+        } else if(mimeTypeService == null) {
+            missing = "MimeTypeService";
+        }
+        
+        if(missing != null) {
+            final String err = missing + " service missing, cannot service requests";
+            final int status = HttpServletResponse.SC_SERVICE_UNAVAILABLE; 
+            log.error(err + ", sending status " + status);
+            sendError(status, err, null, servletRequest, servletResponse);
             return;
         }
 
+        // get JCR Session
         Session session = (Session) servletRequest.getAttribute(SESSION);
         if (session == null) {
             log.error("service: Cannot handle request: Missing JCR Session");
@@ -737,5 +747,5 @@
         }
         return stringConfig;
     }
-
+ 
 }



Mime
View raw message