tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject git commit: TAP5-2364: Tapestry can use prohibited operations in some environments, such as Google App Engine
Date Fri, 01 Aug 2014 15:46:21 GMT
Repository: tapestry-5
Updated Branches:
  refs/heads/master b25c8cde5 -> 7345bfb29


TAP5-2364: Tapestry can use prohibited operations in some environments, such as Google App
Engine


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/7345bfb2
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/7345bfb2
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/7345bfb2

Branch: refs/heads/master
Commit: 7345bfb29bbb995209fcfb9f98f365b1cb643f68
Parents: b25c8cd
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Fri Aug 1 08:46:08 2014 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Fri Aug 1 08:46:08 2014 -0700

----------------------------------------------------------------------
 .../org/apache/tapestry5/SymbolConstants.java   |  7 +++++++
 .../exceptions/ExceptionReporterImpl.java       | 20 +++++++++++++++++---
 .../tapestry5/modules/TapestryModule.java       |  8 +++++---
 .../ResourceTransformerFactoryImpl.java         |  9 +++++----
 4 files changed, 34 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7345bfb2/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java b/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
index 4ed67a8..bef3df4 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
@@ -520,4 +520,11 @@ public class SymbolConstants
      */
     public static final String ENABLE_HTML5_SUPPORT = "tapestry.enable-html5-support";
 
+    /**
+     * A general switch for restrictive environments, such as Google App Engine, which forbid
some useful operations,
+     * such as creating files or directories. Defaults to false.
+     *
+     * @since 5.4
+     */
+    public static final String RESTRICTIVE_ENVIRONMENT = "tapestry.restrictive-environment";
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7345bfb2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/exceptions/ExceptionReporterImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/exceptions/ExceptionReporterImpl.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/exceptions/ExceptionReporterImpl.java
index 6a9bfad..3d0ab83 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/exceptions/ExceptionReporterImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/exceptions/ExceptionReporterImpl.java
@@ -69,6 +69,10 @@ public class ExceptionReporterImpl implements ExceptionReporter
     private String contextPath;
 
     @Inject
+    @Symbol(SymbolConstants.RESTRICTIVE_ENVIRONMENT)
+    private boolean restrictive;
+
+    @Inject
     private ExceptionAnalyzer analyzer;
 
     private final AtomicInteger uid = new AtomicInteger();
@@ -83,15 +87,25 @@ public class ExceptionReporterImpl implements ExceptionReporter
     public void reportException(Throwable exception)
     {
         Date date = new Date();
-        String folderName = String.format("%tY-%<tm-%<td/%<tH/%<tM", date);
         String fileName = String.format(
                 "exception-%tY%<tm%<td-%<tH%<tM%<tS-%<tL.%d.txt", date,
                 uid.getAndIncrement());
 
+        File folder;
+
         try
         {
-            File folder = new File(logDir, folderName);
-            folder.mkdirs();
+            if (restrictive)
+            {
+                // Good luck with this; all exceptions written to a single folder.
+                folder = logDir;
+            } else
+            {
+                String folderName = String.format("%tY-%<tm-%<td/%<tH/%<tM",
date);
+                folder = new File(logDir, folderName);
+
+                folder.mkdirs();
+            }
 
             File log = new File(folder, fileName);
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7345bfb2/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
index de06610..2d852a9 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
@@ -2128,15 +2128,17 @@ public final class TapestryModule
         configuration.add(SymbolConstants.FORM_FIELD_CSS_CLASS, "form-control");
         
         // TAP5-1998
-        configuration.add(SymbolConstants.LENIENT_DATE_FORMAT, "false");
+        configuration.add(SymbolConstants.LENIENT_DATE_FORMAT, false);
         
         // TAP5-2187
-        configuration.add(SymbolConstants.STRICT_CSS_URL_REWRITING, "false");
+        configuration.add(SymbolConstants.STRICT_CSS_URL_REWRITING, false);
 
         configuration.add(SymbolConstants.EXCEPTION_REPORTS_DIR, "build/exceptions");
         
         // TAP5-1815
-        configuration.add(SymbolConstants.ENABLE_HTML5_SUPPORT, "false");
+        configuration.add(SymbolConstants.ENABLE_HTML5_SUPPORT, false);
+
+        configuration.add(SymbolConstants.RESTRICTIVE_ENVIRONMENT, false);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/7345bfb2/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/ResourceTransformerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/ResourceTransformerFactoryImpl.java
b/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/ResourceTransformerFactoryImpl.java
index 5fea1d9..904fa54 100644
--- a/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/ResourceTransformerFactoryImpl.java
+++ b/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/ResourceTransformerFactoryImpl.java
@@ -1,5 +1,3 @@
-// Copyright 2013 The Apache Software Foundation
-//
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
@@ -60,9 +58,12 @@ public class ResourceTransformerFactoryImpl implements ResourceTransformerFactor
     }
 
     @PostInjection
-    public void createCacheDir()
+    public void createCacheDir(@Symbol(SymbolConstants.RESTRICTIVE_ENVIRONMENT) boolean restrictive)
     {
-        cacheDir.mkdirs();
+        if (!restrictive)
+        {
+            cacheDir.mkdirs();
+        }
     }
 
     static class Compiled extends ContentChangeTracker


Mime
View raw message