geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r1141367 - in /geronimo/server/trunk/plugins: j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/ j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/ jasper/geronimo-jasper-b...
Date Thu, 30 Jun 2011 02:32:07 GMT
Author: rwonly
Date: Thu Jun 30 02:32:07 2011
New Revision: 1141367

URL: http://svn.apache.org/viewvc?rev=1141367&view=rev
Log:
GERONIMO-6025 make the url-pattern validation happen in a single place

Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/WebAppInfoBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/WebDeploymentValidationUtils.java
    geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/WebAppInfoBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/WebAppInfoBuilder.java?rev=1141367&r1=1141366&r2=1141367&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/WebAppInfoBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/WebAppInfoBuilder.java
Thu Jun 30 02:32:07 2011
@@ -43,6 +43,7 @@ import org.apache.geronimo.web.info.Sess
 import org.apache.geronimo.web.info.SessionCookieConfigInfo;
 import org.apache.geronimo.web.info.WebAppInfo;
 import org.apache.geronimo.web.info.WebResourceCollectionInfo;
+import org.apache.geronimo.web25.deployment.utils.WebDeploymentValidationUtils;
 import org.apache.openejb.jee.Dispatcher;
 import org.apache.openejb.jee.ErrorPage;
 import org.apache.openejb.jee.Filter;
@@ -85,6 +86,10 @@ public class WebAppInfoBuilder {
         if (webAppInfo != null) {
             throw new IllegalStateException("already built");
         }
+        
+        // check url-pattern and multiplicities
+        WebDeploymentValidationUtils.validateWebApp(webApp);
+        
         List<String> problems = new ArrayList<String>();
         WebAppInfo webAppInfo = webAppInfoFactory.newWebAppInfo();
 
@@ -131,7 +136,7 @@ public class WebAppInfoBuilder {
                 if (!filterMapping.getUrlPattern().isEmpty()) {
                     FilterMappingInfo urlMapping = new FilterMappingInfo();
                     urlMapping.dispatchers = toEnumSet(filterMapping.getDispatcher());
-                    normalizeUrlPatterns(filterMapping.getUrlPattern(), urlMapping.mapping,
problems);
+                    normalizeUrlPatterns(filterMapping.getUrlPattern(), urlMapping.mapping);
                     filterInfo.urlMappings.add(urlMapping);
                 }
             }
@@ -175,7 +180,7 @@ public class WebAppInfoBuilder {
             for (WebResourceCollection webResourceCollection : securityConstraint.getWebResourceCollection())
{
                 WebResourceCollectionInfo webResourceCollectionInfo = new WebResourceCollectionInfo();
                 webResourceCollectionInfo.webResourceName = webResourceCollection.getWebResourceName();
-                normalizeUrlPatterns(webResourceCollection.getUrlPattern(), webResourceCollectionInfo.urlPatterns,
problems);
+                normalizeUrlPatterns(webResourceCollection.getUrlPattern(), webResourceCollectionInfo.urlPatterns);
                 if (webResourceCollection.getHttpMethod().size() > 0) {
                     webResourceCollectionInfo.omission = false;
                     webResourceCollectionInfo.httpMethods.addAll(webResourceCollection.getHttpMethod());
@@ -239,7 +244,7 @@ public class WebAppInfoBuilder {
             if (servletInfo == null) {
                 problems.add("\nNo servlet matching servlet mappings for " + servletName);
             } else {
-                normalizeUrlPatterns(servletMapping.getUrlPattern(), servletInfo.servletMappings,
problems);
+                normalizeUrlPatterns(servletMapping.getUrlPattern(), servletInfo.servletMappings);
             }
         }
 
@@ -298,11 +303,8 @@ public class WebAppInfoBuilder {
         return webAppInfoFactory.copy(filterInfo);
     }
 
-    public static void normalizeUrlPatterns(Collection<String> source, Collection<String>
target, Collection<String> problems) {
+    public static void normalizeUrlPatterns(Collection<String> source, Collection<String>
target) {
         for (String pattern : source) {
-            if (pattern.contains("\n") || pattern.contains("\r")) {
-                problems.add("Invalid url pattern containing a line break: '" + pattern +
"'");
-            }
             if (!pattern.startsWith("*") && !pattern.startsWith("/")) {
                 pattern = "/" + pattern;
                 //log.info("corrected url pattern to " + pattern);

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/WebDeploymentValidationUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/WebDeploymentValidationUtils.java?rev=1141367&r1=1141366&r2=1141367&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/WebDeploymentValidationUtils.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/utils/WebDeploymentValidationUtils.java
Thu Jun 30 02:32:07 2011
@@ -22,6 +22,8 @@ import java.util.regex.Pattern;
 
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.openejb.jee.FilterMapping;
+import org.apache.openejb.jee.JspConfig;
+import org.apache.openejb.jee.JspPropertyGroup;
 import org.apache.openejb.jee.SecurityConstraint;
 import org.apache.openejb.jee.ServletMapping;
 import org.apache.openejb.jee.WebApp;
@@ -67,12 +69,21 @@ public class WebDeploymentValidationUtil
                 }
             }
         }
+        List<JspConfig> jspConfigs = webApp.getJspConfig();
+        for (JspConfig jspConfig : jspConfigs) {
+            for (JspPropertyGroup propertyGroup : jspConfig.getJspPropertyGroup()) {
+                for (String urlPattern : propertyGroup.getUrlPattern()) {
+                    if (!isValidUrlPattern(urlPattern.trim())) {
+                        throw new DeploymentException(WebDeploymentMessageUtils.createInvalidUrlPatternErrorMessage("jsp-config",
propertyGroup.getDisplayName(), urlPattern
+                                , "web.xml"));
+                    }
+                }
+            }
+        }
         List<SecurityConstraint> constraints = webApp.getSecurityConstraint();
         for (SecurityConstraint constraint : constraints) {
-            List<WebResourceCollection> collections = constraint.getWebResourceCollection();
-            for (WebResourceCollection collection : collections) {
-                List<String> patterns = collection.getUrlPattern();
-                for (String pattern : patterns) {
+            for (WebResourceCollection collection : constraint.getWebResourceCollection())
{
+                for (String pattern : collection.getUrlPattern()) {
                     if (!isValidUrlPattern(pattern.trim())) {
                         throw new DeploymentException(WebDeploymentMessageUtils.createInvalidUrlPatternErrorMessage("security-constraint",
collection.getWebResourceName(), pattern
                                 , "web.xml"));
@@ -93,4 +104,5 @@ public class WebDeploymentValidationUtil
             throw new DeploymentException(WebDeploymentMessageUtils.createMultipleConfigurationWebAppErrorMessage("login-config"));
         }
     }
+    
 }

Modified: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java?rev=1141367&r1=1141366&r2=1141367&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java
(original)
+++ geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java
Thu Jun 30 02:32:07 2011
@@ -187,19 +187,12 @@ public class JspModuleBuilderExtension i
             //install default jsp servlet....
             ServletInfo jspServlet = webAppInfoBuilder.copy(defaultJspServletInfo);
             List<JspConfig> jspConfigs = webApp.getJspConfig();
-            if (jspConfigs.size() > 1) {
-                throw new DeploymentException("Web app " + module.getName() + " cannot have
more than one jsp-config element.  Currently has " + jspConfigs.size() + " jsp-config elements.");
-            }
             List<String> jspMappings = new ArrayList<String>();
-            List<String> problems = new ArrayList<String>();
             for (JspConfig jspConfig : jspConfigs) {
                 for (JspPropertyGroup propertyGroup : jspConfig.getJspPropertyGroup()) {
-                    WebAppInfoBuilder.normalizeUrlPatterns(propertyGroup.getUrlPattern(),
jspMappings, problems);
+                    WebAppInfoBuilder.normalizeUrlPatterns(propertyGroup.getUrlPattern(),
jspMappings);
                 }
             }
-            if (!problems.isEmpty()) {
-                throw new DeploymentException("Invalid url patterns: " + problems);
-            }
 
             jspServlet.servletMappings.addAll(jspMappings);
             for (ServletInfo servletInfo: webAppInfo.servlets) {

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=1141367&r1=1141366&r2=1141367&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Thu Jun 30 02:32:07 2011
@@ -27,7 +27,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.jar.JarFile;
@@ -72,9 +71,6 @@ import org.apache.geronimo.naming.deploy
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
 import org.apache.geronimo.openwebbeans.SharedOwbContext;
-import org.apache.geronimo.schema.ElementConverter;
-import org.apache.geronimo.schema.NamespaceElementConverter;
-import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.security.deployment.GeronimoSecurityBuilderImpl;
 import org.apache.geronimo.security.jaas.ConfigurationFactory;
 import org.apache.geronimo.tomcat.LifecycleListenerGBean;
@@ -230,7 +226,7 @@ public class TomcatModuleBuilder extends
                 } finally {
                     in.close();
                 }
-//                WebDeploymentValidationUtils.validateWebApp(webApp);
+
             } catch (Exception e) {
                 throw new DeploymentException("Error reading web.xml for " + bundle.getSymbolicName(),
e);
             }
@@ -297,7 +293,7 @@ public class TomcatModuleBuilder extends
             } finally {
                 in.close();
             }
-//            WebDeploymentValidationUtils.validateWebApp(webApp);
+
         } catch (JAXBException e) {
             // Output the target path in the error to make it clearer to the user which webapp
             // has the problem.  The targetPath is used, as moduleFile may have an unhelpful



Mime
View raw message