click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r793525 - in /incubator/click/trunk/click/framework/src/org/apache/click: service/XmlConfigService.java util/ClickUtils.java
Date Mon, 13 Jul 2009 10:05:49 GMT
Author: sabob
Date: Mon Jul 13 10:05:49 2009
New Revision: 793525

URL: http://svn.apache.org/viewvc?rev=793525&view=rev
Log:
added method that determines if resources can be deployed or not

Modified:
    incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
    incubator/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java

Modified: incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java?rev=793525&r1=793524&r2=793525&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
(original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
Mon Jul 13 10:05:49 2009
@@ -1130,10 +1130,11 @@
     private void deployFiles(Element rootElm) throws Exception {
 
         // Deploy application files if they are not already present.
-        // Only deploy if servletContext.getRealPath() returns a valid path.
-        boolean resourcesDeployable = (servletContext.getRealPath("/") != null);
+        // Only deploy if writes are allowed
+        boolean isResourcesDeployable =
+            ClickUtils.isResourcesDeployable(servletContext);
 
-        if (resourcesDeployable) {
+        if (isResourcesDeployable) {
             deployControls(getResourceRootElement("/click-controls.xml"));
             deployControls(getResourceRootElement("/extras-controls.xml"));
             deployControls(rootElm);

Modified: incubator/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java?rev=793525&r1=793524&r2=793525&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java (original)
+++ incubator/click/trunk/click/framework/src/org/apache/click/util/ClickUtils.java Mon Jul
13 10:05:49 2009
@@ -2405,6 +2405,37 @@
         return buffer.toString();
     }
 
+    /**
+     * Returns true if Click resources (JavaScript, CSS, images etc) packaged
+     * in jars can be deployed to the web application folder, false otherwise.
+     * <p/>
+     * This method will return false in restricted environments where write
+     * access to the underlying file system is disallowed. Examples where
+     * write access is not allowed include the WebLogic JEE server (this can be
+     * changed though) and Google App Engine.
+     *
+     * @param servletContext the application servlet context
+     * @return true if writes are allowed, false otherwise
+     */
+    public static boolean isResourcesDeployable(ServletContext servletContext) {
+        try {
+            boolean canWrite = (servletContext.getRealPath("/") != null);
+            if (!canWrite) {
+                return false;
+            }
+
+            // Since Google App Engine returns a value for getRealPath, check
+            // SecurityManager if writes are allowed
+            SecurityManager security = System.getSecurityManager();
+            if (security != null) {
+        		    security.checkWrite("/click");
+            }
+            return true;
+        } catch (Throwable e) {
+            return false;
+        }
+    }
+
     // -------------------------------------------------------- Package Methods
 
     /**



Mime
View raw message