svn commit: r1848282 - /tomcat/trunk/java/org/apache/catalina/storeconfig/

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

svn commit: r1848282 - /tomcat/trunk/java/org/apache/catalina/storeconfig/

Rémy Maucherat
Author: remm
Date: Thu Dec  6 10:51:04 2018
New Revision: 1848282

URL: http://svn.apache.org/viewvc?rev=1848282&view=rev
Log:
Add i18n for the storeconfig package. Also filter out tomcat-web.xml that has been added.

Modified:
    tomcat/trunk/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/storeconfig/NamingResourcesSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StandardContextSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreFileMover.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/WatchedResourceSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperListenerSF.java

Modified: tomcat/trunk/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java?rev=1848282&r1=1848281&r2=1848282&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java (original)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java Thu Dec  6 10:51:04 2018
@@ -55,21 +55,16 @@ public class GlobalNamingResourcesSF ext
                     resourcesdesc.getStoreFactory().store(aWriter, indent + 2,
                             resources);
                 } else {
-                    if(log.isWarnEnabled())
-                        log.warn("Can't find NamingResources Store Factory!");
+                    log.warn(sm.getString("globalNamingResourcesSF.noFactory"));
                 }
 
                 getStoreAppender().printIndent(aWriter, indent + 2);
                 getStoreAppender().printCloseTag(aWriter, elementDesc);
             } else {
-                if (log.isWarnEnabled())
-                    log.warn("Descriptor for element" + aElement.getClass()
-                            + " not configured!");
+                log.warn(sm.getString("storeFactory.noDescriptor", aElement.getClass(), "GlobalNamingResources"));
             }
         } else {
-            if (log.isWarnEnabled())
-                log.warn("wrong element " + aElement.getClass());
-
+            log.warn(sm.getString("globalNamingResourcesSF.wrongElement", aElement.getClass()));
         }
     }
 }

Modified: tomcat/trunk/java/org/apache/catalina/storeconfig/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/LocalStrings.properties?rev=1848282&r1=1848281&r2=1848282&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/LocalStrings.properties [UTF-8] (original)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/LocalStrings.properties [UTF-8] Thu Dec  6 10:51:04 2018
@@ -22,8 +22,22 @@ config.storeServerError=Error storing se
 factory.storeNoDescriptor=Descriptor for element class [{0}] not configured!
 factory.storeTag=store tag [{0}] ( Object: [{1}] )
 
+globalNamingResourcesSF.noFactory=Cannot find NamingResources store factory
+globalNamingResourcesSF.wrongElement=Wrong element [{0}]
+
 registry.loadClassFailed=Failed to load class [{0}]
 
+standardContextSF.canonicalPathError=Failed to obtain the canonical path of the configuration file [{0}]
+standardContextSF.cannotWriteFile=Cannot write file at [{0}]
+standardContextSF.moveFailed=Context original file at [{0}] is null, not a file or not writable
+standardContextSF.storeContext=Store context [{0}] configuration separately at path [{1}]
+standardContextSF.storeContextWithBackup=Store context [{0}] configuration separately with backup at path [{1}]
+
 storeConfigListener.loadError=Error loading StoreConfig
 storeConfigListener.notServer=The listener was added to component other than the Server and will therefore be ignored
 storeConfigListener.registerError=Error registering StoreConfig MBean
+
+storeFactory.noDescriptor=Descriptor for element [{0}].[{1}] not configured
+
+storeFileMover.directoryCreationError=Cannot create directory [{0}]
+storeFileMover.renameError=Cannot rename [{0}] to [{1}]

Modified: tomcat/trunk/java/org/apache/catalina/storeconfig/NamingResourcesSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/NamingResourcesSF.java?rev=1848282&r1=1848281&r2=1848282&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/NamingResourcesSF.java (original)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/NamingResourcesSF.java Thu Dec  6 10:51:04 2018
@@ -50,9 +50,7 @@ public class NamingResourcesSF extends S
                         + " )");
             storeChildren(aWriter, indent, aElement, elementDesc);
         } else {
-            if (log.isWarnEnabled())
-                log.warn("Descriptor for element" + aElement.getClass()
-                        + " not configured!");
+            log.warn(sm.getString("storeFactory.noDescriptor", aElement.getClass(), "NamingResources"));
         }
     }
 

Modified: tomcat/trunk/java/org/apache/catalina/storeconfig/StandardContextSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/StandardContextSF.java?rev=1848282&r1=1848281&r2=1848282&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/StandardContextSF.java (original)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/StandardContextSF.java Thu Dec  6 10:51:04 2018
@@ -125,15 +125,11 @@ public class StandardContextSF extends S
                         config.getPath());
             }
             if( (!config.isFile()) || (!config.canWrite())) {
-                log.error("Cannot write context output file at "
-                            + configFile + ", not saving.");
-                throw new IOException("Context save file at "
-                                      + configFile
-                                      + " not a file, or not writable.");
-            }
-            if (log.isInfoEnabled())
-                log.info("Store Context " + aContext.getPath()
-                        + " separate at file " + config);
+                throw new IOException(sm.getString("standardContextSF.cannotWriteFile", configFile));
+            }
+            if (log.isInfoEnabled()) {
+                log.info(sm.getString("standardContextSF.storeContext", aContext.getPath(), config));
+            }
             try (FileOutputStream fos = new FileOutputStream(config);
                     PrintWriter writer = new PrintWriter(new OutputStreamWriter(
                             fos , getRegistry().getEncoding()))) {
@@ -159,24 +155,16 @@ public class StandardContextSF extends S
                     || (mover.getConfigOld().isDirectory())
                     || (mover.getConfigOld().exists() &&
                             !mover.getConfigOld().canWrite())) {
-                log.error("Cannot move orignal context output file at "
-                        + mover.getConfigOld());
-                throw new IOException("Context original file at "
-                        + mover.getConfigOld()
-                        + " is null, not a file or not writable.");
+                throw new IOException(sm.getString("standardContextSF.moveFailed", mover.getConfigOld()));
             }
             File dir = mover.getConfigSave().getParentFile();
             if (dir != null && dir.isDirectory() && (!dir.canWrite())) {
-                log.error("Cannot save context output file at "
-                        + mover.getConfigSave());
-                throw new IOException("Context save file at "
-                        + mover.getConfigSave() + " is not writable.");
-            }
-            if (log.isInfoEnabled())
-                log.info("Store Context " + aContext.getPath()
-                        + " separate with backup (at file "
-                        + mover.getConfigSave() + " )");
-
+                throw new IOException(sm.getString("standardContextSF.cannotWriteFile", mover.getConfigSave()));
+            }
+            if (log.isInfoEnabled()) {
+                log.info(sm.getString("standardContextSF.storeContextWithBackup",
+                        aContext.getPath(), mover.getConfigSave()));
+            }
             try (PrintWriter writer = mover.getWriter()) {
                 storeXMLHead(writer);
                 super.store(writer, -2, aContext);
@@ -317,7 +305,7 @@ public class StandardContextSF extends S
             try {
                 file = file.getCanonicalFile();
             } catch (IOException e) {
-                log.error(e);
+                log.error(sm.getString("standardContextSF.canonicalPathError"), e);
             }
         }
         return file;
@@ -346,11 +334,11 @@ public class StandardContextSF extends S
         String confHostDefault = new File(configBase, "context.xml.default")
                 .getCanonicalPath();
         String configFile = (context.getConfigFile() != null ? new File(context.getConfigFile().toURI()).getCanonicalPath() : null);
-        String webxml = "WEB-INF/web.xml" ;
+        String webxml = "WEB-INF/web.xml";
+        String tomcatwebxml = "WEB-INF/tomcat-web.xml";
 
         List<String> resource = new ArrayList<>();
         for (int i = 0; i < wresources.length; i++) {
-
             if (wresources[i].equals(confContext))
                 continue;
             if (wresources[i].equals(confWeb))
@@ -361,6 +349,8 @@ public class StandardContextSF extends S
                 continue;
             if (wresources[i].equals(webxml))
                 continue;
+            if (wresources[i].equals(tomcatwebxml))
+                continue;
             resource.add(wresources[i]);
         }
         return resource.toArray(new String[resource.size()]);

Modified: tomcat/trunk/java/org/apache/catalina/storeconfig/StoreFileMover.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/StoreFileMover.java?rev=1848282&r1=1848281&r2=1848282&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/StoreFileMover.java (original)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/StoreFileMover.java Thu Dec  6 10:51:04 2018
@@ -23,6 +23,8 @@ import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.sql.Timestamp;
 
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * Move server.xml or context.xml as backup
  *
@@ -30,6 +32,8 @@ import java.sql.Timestamp;
  */
 public class StoreFileMover {
 
+    protected static final StringManager sm = StringManager.getManager(Constants.Package);
+
     private String filename = "conf/server.xml";
 
     private String encoding = "UTF-8";
@@ -141,7 +145,7 @@ public class StoreFileMover {
         }
         if (!configNew.getParentFile().exists()) {
             if (!configNew.getParentFile().mkdirs()) {
-                throw new IllegalStateException("Cannot create directory " + configNew);
+                throw new IllegalStateException(sm.getString("storeFileMover.directoryCreationError", configNew));
             }
         }
         String sb = getTimeTag();
@@ -160,21 +164,18 @@ public class StoreFileMover {
         if (configOld.renameTo(configSave)) {
             if (!configNew.renameTo(configOld)) {
                 configSave.renameTo(configOld);
-                throw new IOException("Cannot rename "
-                        + configNew.getAbsolutePath() + " to "
-                        + configOld.getAbsolutePath());
+                throw new IOException(sm.getString("storeFileMover.renameError",
+                        configNew.getAbsolutePath(), configOld.getAbsolutePath()));
             }
         } else {
             if (!configOld.exists()) {
                 if (!configNew.renameTo(configOld)) {
-                    throw new IOException("Cannot move "
-                            + configNew.getAbsolutePath() + " to "
-                            + configOld.getAbsolutePath());
+                    throw new IOException(sm.getString("storeFileMover.renameError",
+                            configNew.getAbsolutePath(), configOld.getAbsolutePath()));
                 }
             } else {
-                throw new IOException("Cannot rename "
-                    + configOld.getAbsolutePath() + " to "
-                    + configSave.getAbsolutePath());
+                throw new IOException(sm.getString("storeFileMover.renameError",
+                        configOld.getAbsolutePath(), configSave.getAbsolutePath()));
             }
         }
     }

Modified: tomcat/trunk/java/org/apache/catalina/storeconfig/WatchedResourceSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/WatchedResourceSF.java?rev=1848282&r1=1848281&r2=1848282&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/WatchedResourceSF.java (original)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/WatchedResourceSF.java Thu Dec  6 10:51:04 2018
@@ -47,8 +47,8 @@ public class WatchedResourceSF extends S
                 getStoreAppender().printTagArray(aWriter, "WatchedResource",
                         indent, resources);
             }
-        } else
-            log.warn("Descriptor for element" + aElement.getClass()
-                    + ".[WatchedResource] not configured!");
+        } else {
+            log.warn(sm.getString("storeFactory.noDescriptor", aElement.getClass(), "WatchedResource"));
+        }
     }
 }
\ No newline at end of file

Modified: tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java?rev=1848282&r1=1848281&r2=1848282&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java (original)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java Thu Dec  6 10:51:04 2018
@@ -47,8 +47,8 @@ public class WrapperLifecycleSF extends
                 getStoreAppender().printTagArray(aWriter, "WrapperLifecycle",
                         indent, listeners);
             }
-        } else
-            log.warn("Descriptor for element" + aElement.getClass()
-                    + ".[WrapperLifecycle] not configured!");
+        } else {
+            log.warn(sm.getString("storeFactory.noDescriptor", aElement.getClass(), "WrapperLifecycle"));
+        }
     }
 }
\ No newline at end of file

Modified: tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperListenerSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperListenerSF.java?rev=1848282&r1=1848281&r2=1848282&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperListenerSF.java (original)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperListenerSF.java Thu Dec  6 10:51:04 2018
@@ -47,8 +47,8 @@ public class WrapperListenerSF extends S
                 getStoreAppender().printTagArray(aWriter, "WrapperListener",
                         indent, listeners);
             }
-        } else
-            log.warn("Descriptor for element" + aElement.getClass()
-                    + ".[WrapperListener] not configured!");
+        } else {
+            log.warn(sm.getString("storeFactory.noDescriptor", aElement.getClass(), "WrapperListener"));
+        }
     }
 }
\ No newline at end of file



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