Author: fmeschbe
Date: Thu Jan 17 02:32:10 2008
New Revision: 612782

URL: http://svn.apache.org/viewvc?rev=612782&view=rev
Log:
SLING-170 Redirect to the default workspace when accessing the servlet directly.

Modified:
    
incubator/sling/trunk/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java

Modified: 
incubator/sling/trunk/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java?rev=612782&r1=612781&r2=612782&view=diff
==============================================================================
--- 
incubator/sling/trunk/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java
 (original)
+++ 
incubator/sling/trunk/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java
 Thu Jan 17 02:32:10 2008
@@ -18,11 +18,14 @@
  */
 package org.apache.sling.jcr.webdav;
 
+import java.io.IOException;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
 import javax.jcr.Repository;
 import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet;
 import org.apache.sling.jcr.api.SlingRepository;
@@ -59,6 +62,26 @@
         return repository;
     }
 
+    // ---------- AbstractWebdavServlet overwrite 
------------------------------
+
+    @Override
+    protected void service(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException, IOException 
{
+        
+        // redirect to the default workspace if directly addressing the servlet
+        String pinfo = request.getPathInfo();
+        if (pinfo == null || "/".equals(pinfo)) {
+            String uri = request.getRequestURI();
+            if (pinfo == null) {
+                uri += "/";
+            }
+            uri += repository.getDefaultWorkspace();
+            response.sendRedirect(uri);
+        }
+        
+        super.service(request, response);
+    }
+    
     // ---------- SCR integration 
----------------------------------------------
 
     protected void activate(ComponentContext componentContext) {
@@ -76,10 +99,10 @@
                 + value + "\"");
         }
 
-//        value = getString(props, INIT_PARAM_MISSING_AUTH_MAPPING, null);
-//        if (value != null) {
-//            initparams.put(INIT_PARAM_MISSING_AUTH_MAPPING, value);
-//        }
+        // value = getString(props, INIT_PARAM_MISSING_AUTH_MAPPING, null);
+        // if (value != null) {
+        // initparams.put(INIT_PARAM_MISSING_AUTH_MAPPING, value);
+        // }
 
         try {
             httpService.registerServlet(context, this, initparams, null);


Reply via email to