This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag 
org.apache.sling.jcr.webdav-2.0.2-incubator
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-webdav.git

commit 840140e3a2124ef104dbdc3bf0a071871246a93f
Author: Felix Meschberger <fmesc...@apache.org>
AuthorDate: Thu Jan 17 10:32:10 2008 +0000

    SLING-170 Redirect to the default workspace when accessing the servlet 
directly.
    
    git-svn-id: 
https://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/webdav@612782 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/jcr/webdav/SimpleWebDavServlet.java      | 31 +++++++++++++++++++---
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java 
b/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java
index 03267ba..795c794 100644
--- a/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java
+++ b/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java
@@ -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 @@ public class SimpleWebDavServlet extends SimpleWebdavServlet 
{
         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 @@ public class SimpleWebDavServlet extends 
SimpleWebdavServlet {
                 + 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);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <commits@sling.apache.org>.

Reply via email to