jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1155403 - /jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java
Date Tue, 09 Aug 2011 15:31:38 GMT
Author: jukka
Date: Tue Aug  9 15:31:38 2011
New Revision: 1155403

URL: http://svn.apache.org/viewvc?rev=1155403&view=rev
Log:
JCR-3029: JcrRemotingServlet should interpolate system properties in the home init-param

Use the standard java.io.tmpdir location for temporary files when no explicit configuration
is present.

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java?rev=1155403&r1=1155402&r2=1155403&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java
Tue Aug  9 15:31:38 2011
@@ -46,6 +46,7 @@ import javax.jcr.Workspace;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.NodeIterator;
 import javax.jcr.PathNotFoundException;
+import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
@@ -238,29 +239,37 @@ public abstract class JcrRemotingServlet
             }
         }
 
-        // setup home directory
-        String paramHome = getServletConfig().getInitParameter(INIT_PARAM_HOME);
-        if (paramHome == null) {
-            log.debug("missing init-param " + INIT_PARAM_HOME + ". using default: 'jackrabbit'");
-            paramHome = "jackrabbit";
+        // Determine the configured location for temporary files used when
+        // processing file uploads. Since JCR-3029 the default is the
+        // standard java.io.tmpdir location, but the presence of explicit
+        // configuration parameters restores the original behavior.
+        File tmp = null;
+        ServletConfig config = getServletConfig();
+        String paramHome = config.getInitParameter(INIT_PARAM_HOME);
+        String paramTemp = config.getInitParameter(INIT_PARAM_TMP_DIRECTORY);
+        if (paramHome != null || paramTemp != null) {
+            if (paramHome == null) {
+                log.debug("Missing init-param " + INIT_PARAM_HOME
+                        + ". Using default: 'jackrabbit'");
+                paramHome = "jackrabbit";
+            } else if (paramTemp == null) {
+                log.debug("Missing init-param " + INIT_PARAM_TMP_DIRECTORY
+                        + ". Using default: 'tmp'");
+                paramTemp = "tmp";
+            }
+
+            tmp = new File(paramHome, paramTemp);
+            try {
+                tmp = tmp.getCanonicalFile();
+                tmp.mkdirs();
+                log.debug("  temp-directory = " + tmp.getPath());
+            } catch (IOException e) {
+                log.warn("Invalid temporary directory " + tmp.getPath()
+                        + ", using system default instead", e);
+                tmp = null;
+            }
         }
-        File home;
-        try {
-            home = new File(paramHome).getCanonicalFile();
-        } catch (IOException e) {
-            throw new ServletException(INIT_PARAM_HOME + " invalid." + e.toString());
-        }
-        home.mkdirs();
-
-        String tmp = getServletConfig().getInitParameter(INIT_PARAM_TMP_DIRECTORY);
-        if (tmp == null) {
-            log.debug("No " + INIT_PARAM_TMP_DIRECTORY + " specified. using 'tmp'");
-            tmp = "tmp";
-        }
-        File tmpDirectory = new File(home, tmp);
-        tmpDirectory.mkdirs();
-        log.debug("  temp-directory = " + tmpDirectory.getPath());
-        getServletContext().setAttribute(ATTR_TMP_DIRECTORY, tmpDirectory);
+        getServletContext().setAttribute(ATTR_TMP_DIRECTORY, tmp);
 
         // force usage of custom locator factory.
         super.setLocatorFactory(new DavLocatorFactoryImpl(getInitParameter(INIT_PARAM_RESOURCE_PATH_PREFIX)));



Mime
View raw message