svn commit: r1848257 - in /tomcat/trunk/java/org/apache/catalina/valves: ExtendedAccessLogValve.java LocalStrings.properties rewrite/LocalStrings.properties rewrite/RewriteValve.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1848257 - in /tomcat/trunk/java/org/apache/catalina/valves: ExtendedAccessLogValve.java LocalStrings.properties rewrite/LocalStrings.properties rewrite/RewriteValve.java

Rémy Maucherat
Author: remm
Date: Wed Dec  5 23:19:47 2018
New Revision: 1848257

URL: http://svn.apache.org/viewvc?rev=1848257&view=rev
Log:
Add i18n for the valves package.

Added:
    tomcat/trunk/java/org/apache/catalina/valves/rewrite/LocalStrings.properties   (with props)
Modified:
    tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
    tomcat/trunk/java/org/apache/catalina/valves/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/valves/rewrite/RewriteValve.java

Modified: tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java?rev=1848257&r1=1848256&r2=1848257&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/ExtendedAccessLogValve.java Wed Dec  5 23:19:47 2018
@@ -544,7 +544,7 @@ public class ExtendedAccessLogValve exte
             tokenizer.getWhiteSpaces();
 
             if (tokenizer.isEnded()) {
-                log.info("pattern was just empty or whitespace");
+                log.info(sm.getString("extendedAccessLogValve.emptyPattern"));
                 return null;
             }
 
@@ -572,7 +572,7 @@ public class ExtendedAccessLogValve exte
             }
             return list.toArray(new AccessLogElement[0]);
         } catch (IOException e) {
-            log.error("parse error", e);
+            log.error(sm.getString("extendedAccessLogValve.patternParseError", pattern), e);
             return null;
         }
     }
@@ -630,7 +630,7 @@ public class ExtendedAccessLogValve exte
         } else if ("x".equals(token)) {
             return getXParameterElement(tokenizer);
         }
-        log.error("unable to decode with rest of chars starting: " + token);
+        log.error(sm.getString("extendedAccessLogValve.decodeError", token));
         return null;
     }
 
@@ -680,13 +680,12 @@ public class ExtendedAccessLogValve exte
         } else if (tokenizer.hasParameter()) {
             String parameter = tokenizer.getParameter();
             if (parameter == null) {
-                log.error("No closing ) found for in decode");
+                log.error(sm.getString("extendedAccessLogValve.noClosing"));
                 return null;
             }
             return new RequestHeaderElement(parameter);
         }
-        log.error("The next characters couldn't be decoded: "
-                + tokenizer.getRemains());
+        log.error(sm.getString("extendedAccessLogValve.decodeError", tokenizer.getRemains()));
         return null;
     }
 
@@ -702,13 +701,12 @@ public class ExtendedAccessLogValve exte
         } else if (tokenizer.hasParameter()) {
             String parameter = tokenizer.getParameter();
             if (parameter == null) {
-                log.error("No closing ) found for in decode");
+                log.error(sm.getString("extendedAccessLogValve.noClosing"));
                 return null;
             }
             return new ResponseHeaderElement(parameter);
         }
-        log.error("The next characters couldn't be decoded: "
-                + tokenizer.getRemains());
+        log.error(sm.getString("extendedAccessLogValve.decodeError", tokenizer.getRemains()));
         return null;
     }
 
@@ -722,14 +720,14 @@ public class ExtendedAccessLogValve exte
             tokenizer.getParameter();
             return new StringElement("-");
         }
-        log.error("The next characters couldn't be decoded: " + token);
+        log.error(sm.getString("extendedAccessLogValve.decodeError", token));
         return null;
     }
 
     protected AccessLogElement getXParameterElement(PatternTokenizer tokenizer)
             throws IOException {
         if (!tokenizer.hasSubToken()) {
-            log.error("x param in wrong format. Needs to be 'x-#(...)' read the docs!");
+            log.error(sm.getString("extendedAccessLogValve.badXParam"));
             return null;
         }
         String token = tokenizer.getToken();
@@ -738,12 +736,12 @@ public class ExtendedAccessLogValve exte
         }
 
         if (!tokenizer.hasParameter()) {
-            log.error("x param in wrong format. Needs to be 'x-#(...)' read the docs!");
+            log.error(sm.getString("extendedAccessLogValve.badXParam"));
             return null;
         }
         String parameter = tokenizer.getParameter();
         if (parameter == null) {
-            log.error("No closing ) found for in decode");
+            log.error(sm.getString("extendedAccessLogValve.noClosing"));
             return null;
         }
         if ("A".equals(token)) {
@@ -761,8 +759,7 @@ public class ExtendedAccessLogValve exte
         } else if ("O".equals(token)) {
             return new ResponseAllHeaderElement(parameter);
         }
-        log.error("x param for servlet request, couldn't decode value: "
-                + token);
+        log.error(sm.getString("extendedAccessLogValve.badXParamValue", token));
         return null;
     }
 
@@ -857,8 +854,7 @@ public class ExtendedAccessLogValve exte
                 }
             };
         }
-        log.error("x param for servlet request, couldn't decode value: "
-                + parameter);
+        log.error(sm.getString("extendedAccessLogValve.badXParamValue", parameter));
         return null;
     }
 

Modified: tomcat/trunk/java/org/apache/catalina/valves/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/LocalStrings.properties?rev=1848257&r1=1848256&r2=1848257&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/LocalStrings.properties [UTF-8] (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/LocalStrings.properties [UTF-8] Wed Dec  5 23:19:47 2018
@@ -42,6 +42,13 @@ errorReportValve.statusReport=Status Rep
 errorReportValve.type=Type
 errorReportValve.unknownReason=Unknown Reason
 
+extendedAccessLogValve.badXParam=Invalid x parameter format, needs to be 'x-#(...)
+extendedAccessLogValve.badXParamValue=Invalid x parameter value for Servlet request [{0}]
+extendedAccessLogValve.decodeError=Unable to decode the rest of chars starting with [{0}]
+extendedAccessLogValve.emptyPattern=Pattern was just empty or whitespace
+extendedAccessLogValve.noClosing=No closing ) found for in decode
+extendedAccessLogValve.patternParseError=Error parsing pattern [{0}]
+
 http.400.desc=The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
 http.400.reason=Bad Request
 http.401.desc=The request has not been applied because it lacks valid authentication credentials for the target resource.

Added: tomcat/trunk/java/org/apache/catalina/valves/rewrite/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/rewrite/LocalStrings.properties?rev=1848257&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/rewrite/LocalStrings.properties (added)
+++ tomcat/trunk/java/org/apache/catalina/valves/rewrite/LocalStrings.properties Wed Dec  5 23:19:47 2018
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+rewriteValve.closeError=Error closing configuration
+rewriteValve.invalidFlags=Invalid flag in [{0}] flags [{1}]
+rewriteValve.invalidLine=Invalid line [{0}]
+rewriteValve.invalidMapClassName=Invalid map class name [{0}]
+rewriteValve.readError=Error reading configuration

Propchange: tomcat/trunk/java/org/apache/catalina/valves/rewrite/LocalStrings.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tomcat/trunk/java/org/apache/catalina/valves/rewrite/RewriteValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/rewrite/RewriteValve.java?rev=1848257&r1=1848256&r2=1848257&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/rewrite/RewriteValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/rewrite/RewriteValve.java Wed Dec  5 23:19:47 2018
@@ -122,6 +122,7 @@ public class RewriteValve extends ValveB
     protected synchronized void startInternal() throws LifecycleException {
 
         super.startInternal();
+        context = (getContainer() instanceof Context);
 
         InputStream is = null;
 
@@ -158,12 +159,12 @@ public class RewriteValve extends ValveB
                 BufferedReader reader = new BufferedReader(isr)) {
             parse(reader);
         } catch (IOException ioe) {
-            containerLog.error("Error closing configuration", ioe);
+            containerLog.error(sm.getString("rewriteValve.closeError"), ioe);
         } finally {
             try {
                 is.close();
             } catch (IOException e) {
-                containerLog.error("Error closing configuration", e);
+                containerLog.error(sm.getString("rewriteValve.closeError"), e);
             }
         }
 
@@ -243,7 +244,7 @@ public class RewriteValve extends ValveB
                     }
                 }
             } catch (IOException e) {
-                containerLog.error("Error reading configuration", e);
+                containerLog.error(sm.getString("rewriteValve.readError"), e);
             }
         }
         this.rules = rules.toArray(new RewriteRule[0]);
@@ -565,7 +566,7 @@ public class RewriteValve extends ValveB
                 // RewriteCond TestString CondPattern [Flags]
                 RewriteCond condition = new RewriteCond();
                 if (tokenizer.countTokens() < 2) {
-                    throw new IllegalArgumentException("Invalid line: " + line);
+                    throw new IllegalArgumentException(sm.getString("rewriteValve.invalidLine", line));
                 }
                 condition.setTestString(tokenizer.nextToken());
                 condition.setCondPattern(tokenizer.nextToken());
@@ -585,7 +586,7 @@ public class RewriteValve extends ValveB
                 // RewriteRule Pattern Substitution [Flags]
                 RewriteRule rule = new RewriteRule();
                 if (tokenizer.countTokens() < 2) {
-                    throw new IllegalArgumentException("Invalid line: " + line);
+                    throw new IllegalArgumentException(sm.getString("rewriteValve.invalidLine", line));
                 }
                 rule.setPatternString(tokenizer.nextToken());
                 rule.setSubstitutionString(tokenizer.nextToken());
@@ -604,7 +605,7 @@ public class RewriteValve extends ValveB
             } else if (token.equals("RewriteMap")) {
                 // RewriteMap name rewriteMapClassName whateverOptionalParameterInWhateverFormat
                 if (tokenizer.countTokens() < 2) {
-                    throw new IllegalArgumentException("Invalid line: " + line);
+                    throw new IllegalArgumentException(sm.getString("rewriteValve.invalidLine", line));
                 }
                 String name = tokenizer.nextToken();
                 String rewriteMapClassName = tokenizer.nextToken();
@@ -613,7 +614,7 @@ public class RewriteValve extends ValveB
                     map = (RewriteMap) (Class.forName(
                             rewriteMapClassName).getConstructor().newInstance());
                 } catch (Exception e) {
-                    throw new IllegalArgumentException("Invalid map className: " + line);
+                    throw new IllegalArgumentException(sm.getString("rewriteValve.invalidMapClassName", line));
                 }
                 if (tokenizer.hasMoreTokens()) {
                     map.setParameters(tokenizer.nextToken());
@@ -625,7 +626,7 @@ public class RewriteValve extends ValveB
             } else if (token.startsWith("#")) {
                 // it's a comment, ignore it
             } else {
-                throw new IllegalArgumentException("Invalid line: " + line);
+                throw new IllegalArgumentException(sm.getString("rewriteValve.invalidLine", line));
             }
         }
         return null;
@@ -644,7 +645,7 @@ public class RewriteValve extends ValveB
         } else if (flag.equals("OR") || flag.equals("ornext")) {
             condition.setOrnext(true);
         } else {
-            throw new IllegalArgumentException("Invalid flag in: " + line + " flags: " + flag);
+            throw new IllegalArgumentException(sm.getString("rewriteValve.invalidFlags", line, flag));
         }
     }
 
@@ -669,7 +670,7 @@ public class RewriteValve extends ValveB
             }
             StringTokenizer tokenizer = new StringTokenizer(flag, ":");
             if (tokenizer.countTokens() < 2) {
-                throw new IllegalArgumentException("Invalid flag in: " + line);
+                throw new IllegalArgumentException(sm.getString("rewriteValve.invalidFlags", line, flag));
             }
             rule.setCookieName(tokenizer.nextToken());
             rule.setCookieValue(tokenizer.nextToken());
@@ -680,7 +681,7 @@ public class RewriteValve extends ValveB
                 try {
                     rule.setCookieLifetime(Integer.parseInt(tokenizer.nextToken()));
                 } catch (NumberFormatException e) {
-                    throw new IllegalArgumentException("Invalid flag in: " + line, e);
+                    throw new IllegalArgumentException(sm.getString("rewriteValve.invalidFlags", line, flag), e);
                 }
             }
             if (tokenizer.hasMoreTokens()) {
@@ -701,7 +702,7 @@ public class RewriteValve extends ValveB
             }
             int pos = flag.indexOf(':');
             if (pos == -1 || (pos + 1) == flag.length()) {
-                throw new IllegalArgumentException("Invalid flag in: " + line);
+                throw new IllegalArgumentException(sm.getString("rewriteValve.invalidFlags", line, flag));
             }
             rule.addEnvName(flag.substring(0, pos));
             rule.addEnvValue(flag.substring(pos + 1));
@@ -766,7 +767,7 @@ public class RewriteValve extends ValveB
             rule.setType(true);
             rule.setTypeValue(flag);
         } else {
-            throw new IllegalArgumentException("Invalid flag in: " + line + " flag: " + flag);
+            throw new IllegalArgumentException(sm.getString("rewriteValve.invalidFlags", line, flag));
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]