click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r901212 - /incubator/click/trunk/click/framework/src/org/apache/click/service/CommonsFileUploadService.java
Date Wed, 20 Jan 2010 14:32:32 GMT
Author: sabob
Date: Wed Jan 20 14:32:32 2010
New Revision: 901212

URL: http://svn.apache.org/viewvc?rev=901212&view=rev
Log:
improved feedback

Modified:
    incubator/click/trunk/click/framework/src/org/apache/click/service/CommonsFileUploadService.java

Modified: incubator/click/trunk/click/framework/src/org/apache/click/service/CommonsFileUploadService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/service/CommonsFileUploadService.java?rev=901212&r1=901211&r2=901212&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/service/CommonsFileUploadService.java
(original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/service/CommonsFileUploadService.java
Wed Jan 20 14:32:32 2010
@@ -82,32 +82,53 @@
         ConfigService configService = ClickUtils.getConfigService(servletContext);
         LogService logService = configService.getLogService();
 
+        boolean logWarning = false;
+        boolean restrictedEnvironment = false;
+
+        // Uploaded files are saved to java.io.tmpdir. Here we check if this
+        // directory exists, if it does does not, log a warning
+        String tmpdir = System.getProperty("java.io.tmpdir");
+
         try {
-            // Uploaded files are saved to java.io.tmpdir. Here we check if this
-            // directory exists, if it does does not, log a warning
-            String tmpdir = System.getProperty("java.io.tmpdir");
-            File tmpfile = new File(tmpdir);
-            if (!tmpfile.exists()) {
-                logService.warn("The java.io.tmpdir directory, '" + tmpdir
-                    + "', does not exist. This can cause file uploading to fail"
-                    + " as uploaded files are saved to directory specified by the"
-                    + " 'java.io.tmpdir' property.");
+            if (tmpdir == null) {
+                logWarning = true;
+
+            } else {
+                File tmpfile = new File(tmpdir);
+                if (!tmpfile.exists()) {
+                    logWarning = true;
+                }
             }
 
-        } catch (AccessControlException exception) {
             if (!ClickUtils.isResourcesDeployable(servletContext)) {
-                // Probably deploying on Google App Engine which throws
-                // Security Exception if accessing temp folder
-                logService.warn("If you are deploying to Google App Engine,"
-                    + " please note that Click's default"
-                    + " org.apache.click.service.CommonsFileUploadService"
-                    + " does not work with Google App Engine. Instead use"
-                    + " org.apache.click.extras.gae.MemoryFileUploadService.");
-            } else {
-                // If resources are deployable throw exception
+                restrictedEnvironment = true;
+            }
+
+        } catch (AccessControlException exception) {
+            if (ClickUtils.isResourcesDeployable(servletContext)) {
+                // If resources are deployable, throw exception
                 throw exception;
+            } else {
+                restrictedEnvironment = true;
             }
         }
+
+        if (logWarning) {
+            logService.warn("The java.io.tmpdir directory, '" + tmpdir
+                + "', does not exist. This can cause file uploading to fail"
+                + " as uploaded files are saved to directory specified by the"
+                + " 'java.io.tmpdir' property.");
+        }
+
+        if (restrictedEnvironment) {
+            // Probably deploying on Google App Engine which throws
+            // Security Exception if accessing temp folder
+            logService.warn("If you are deploying to Google App Engine,"
+                + " please note that Click's default"
+                + " org.apache.click.service.CommonsFileUploadService"
+                + " does not work with Google App Engine. Instead use"
+                + " org.apache.click.extras.gae.MemoryFileUploadService.");
+        }
     }
 
     /**



Mime
View raw message