jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1461455 - in /jackrabbit/branches/2.4: ./ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
Date Wed, 27 Mar 2013 08:58:22 GMT
Author: reschke
Date: Wed Mar 27 08:58:22 2013
New Revision: 1461455

URL: http://svn.apache.org/r1461455
Log:
2.4: Merged revision 1437963, 1438158 and 1439797 (JCR-1873)

Modified:
    jackrabbit/branches/2.4/   (props changed)
    jackrabbit/branches/2.4/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
    jackrabbit/branches/2.4/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java

Propchange: jackrabbit/branches/2.4/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1437963,1438158,1439797

Modified: jackrabbit/branches/2.4/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java?rev=1461455&r1=1461454&r2=1461455&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
Wed Mar 27 08:58:22 2013
@@ -98,18 +98,30 @@ public class WebdavRequestImpl implement
 
     /**
      * Creates a new <code>DavServletRequest</code> with the given parameters.
+     */
+    public WebdavRequestImpl(HttpServletRequest httpRequest, DavLocatorFactory factory) {
+        this(httpRequest, factory, true);
+    }
+
+    /**
+     * Creates a new <code>DavServletRequest</code> with the given parameters.
      *
      * @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/branches/2.4/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java?rev=1461455&r1=1461454&r2=1461455&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
Wed Mar 27 08:58:22 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,13 @@ 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..
+        String param = getInitParameter(INIT_PARAM_CREATE_ABSOLUTE_URI);
+        if (param != null) {
+            createAbsoluteURI = Boolean.parseBoolean(param);
+        }
+        log.info(INIT_PARAM_CREATE_ABSOLUTE_URI + " = " + createAbsoluteURI);
     }
 
     /**
@@ -226,6 +245,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 +265,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