jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cko...@apache.org
Subject svn commit: r1437963 - in /jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav: WebdavRequestImpl.java server/AbstractWebdavServlet.java
Date Thu, 24 Jan 2013 11:28:45 GMT
Author: ckoell
Date: Thu Jan 24 11:28:45 2013
New Revision: 1437963

URL: http://svn.apache.org/viewvc?rev=1437963&view=rev
Log:
JCR-1873 It should be possible to define how hrefs are generated for WebDav

Modified:
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java?rev=1437963&r1=1437962&r2=1437963&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
Thu Jan 24 11:28:45 2013
@@ -101,15 +101,20 @@ public class WebdavRequestImpl implement
      *
      * @param httpRequest
      * @param factory
+     * @param createAbsoluteURI defines if we must create a absolute URI. if false a absolute
path will be created
      */
-    public WebdavRequestImpl(HttpServletRequest httpRequest, DavLocatorFactory factory) {
+    public WebdavRequestImpl(HttpServletRequest httpRequest, DavLocatorFactory factory, boolean
createAbsoluteURI) {
         this.httpRequest = httpRequest;
         this.factory = factory;
         this.ifHeader = new IfHeader(httpRequest);
 
-        String host = getHeader("Host");
-        String scheme = getScheme();
-        hrefPrefix = scheme + "://" + host + getContextPath();
+        if (createAbsoluteURI)  {
+            String host = getHeader("Host");
+            String scheme = getScheme();
+            hrefPrefix = scheme + "://" + host + getContextPath();
+        } else {
+            hrefPrefix = getContextPath();
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java?rev=1437963&r1=1437962&r2=1437963&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
Thu Jan 24 11:28:45 2013
@@ -134,6 +134,13 @@ abstract public class AbstractWebdavServ
      */
     public static final String INIT_PARAM_CSRF_PROTECTION = "csrf-protection";
 
+    /** 
+     * Name of the 'createAbsoluteURI' init parameter that defines whether hrefs
+     * should be created with a absolute URI or as absolute Path (ContextPath). 
+     * The value should be 'true' or 'false'. The default value if not set is true.
+     */
+    public final static String INIT_PARAM_CREATE_ABSOLUTE_URI = "createAbsoluteURI";
+
 
     /**
      * Header value as specified in the {@link #INIT_PARAM_AUTHENTICATE_HEADER} parameter.
@@ -145,6 +152,11 @@ abstract public class AbstractWebdavServ
      */
     private CSRFUtil csrfUtil;
 
+    /**
+     * Create per default absolute URI hrefs
+     */
+    private boolean createAbsoluteURI = true;
+
     @Override
     public void init() throws ServletException {
         super.init();
@@ -160,6 +172,10 @@ abstract public class AbstractWebdavServ
         String csrfParam = getInitParameter(INIT_PARAM_CSRF_PROTECTION);
         csrfUtil = new CSRFUtil(csrfParam);
         log.info(INIT_PARAM_CSRF_PROTECTION + " = " + csrfParam);
+
+        //create absolute URI hrefs..
+        createAbsoluteURI = Boolean.parseBoolean(getInitParameter(INIT_PARAM_CREATE_ABSOLUTE_URI));
+        log.info(INIT_PARAM_CREATE_ABSOLUTE_URI + " = " + createAbsoluteURI);
     }
 
     /**
@@ -226,6 +242,15 @@ abstract public class AbstractWebdavServ
     }
 
     /**
+     * Returns if a absolute URI should be created for hrefs.
+     * 
+     * @return absolute URI hrefs
+     */
+    protected boolean isCreateAbsoluteURI() {
+        return createAbsoluteURI;
+    }
+    
+    /**
      * Service the given request.
      *
      * @param request
@@ -237,7 +262,7 @@ abstract public class AbstractWebdavServ
     protected void service(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {
 
-        WebdavRequest webdavRequest = new WebdavRequestImpl(request, getLocatorFactory());
+        WebdavRequest webdavRequest = new WebdavRequestImpl(request, getLocatorFactory(),
isCreateAbsoluteURI());
         // DeltaV requires 'Cache-Control' header for all methods except 'VERSION-CONTROL'
and 'REPORT'.
         int methodCode = DavMethods.getMethodCode(request.getMethod());
         boolean noCache = DavMethods.isDeltaVMethod(webdavRequest) && !(DavMethods.DAV_VERSION_CONTROL
== methodCode || DavMethods.DAV_REPORT == methodCode);



Mime
View raw message