Author: pero Date: Fri Apr 14 10:48:28 2006 New Revision: 394151 URL: http://svn.apache.org/viewcvs?rev=394151&view=rev Log: Make sure that context config files are writeable. But a bug with referenced war files outsite Host appBase exists. Currently context docBase from those apps point to extract webapps/app directory. StoreConfig can't detect the orginal war file and redeployment crashed!
Modified: tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StandardContextSF.java tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StoreContextAppender.java tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StoreFactoryBase.java tomcat/container/tc5.5.x/webapps/docs/changelog.xml Modified: tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StandardContextSF.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StandardContextSF.java?rev=394151&r1=394150&r2=394151&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StandardContextSF.java (original) +++ tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StandardContextSF.java Fri Apr 14 10:48:28 2006 @@ -108,6 +108,13 @@ if (!config.isAbsolute()) { config = new File(System.getProperty("catalina.base"), configFile); + } + 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() @@ -146,21 +153,27 @@ protected void storeWithBackup(StandardContext aContext) throws Exception { StoreFileMover mover = getConfigFileWriter((Context) aContext); if (mover != null) { + // Bugzilla 37781 Check to make sure we can write this output file + if ((mover.getConfigOld() == null) + || (!mover.getConfigOld().isFile()) + || (!mover.getConfigOld().canWrite())) { + log.error("Cannot move orignal context output file at " + + mover.getConfigOld()); + throw new IOException("Context orginal file at " + + mover.getConfigOld() + + " is null, not a file or not writable."); + } + 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() + " )"); - - // Bugzilla 37781 Check to make sure we can write this output file - if ((mover.getConfigSave() == null) || - (! mover.getConfigSave().isFile()) || - (! mover.getConfigSave().canWrite())) { - log.error("Cannot write context output file at " - + mover.getConfigSave() + ", not saving."); - throw new IOException("Context save file at " - + mover.getConfigSave() - + " is null, not a file, or not writable."); - } PrintWriter writer = mover.getWriter(); try { Modified: tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StoreContextAppender.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StoreContextAppender.java?rev=394151&r1=394150&r2=394151&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StoreContextAppender.java (original) +++ tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StoreContextAppender.java Fri Apr 14 10:48:28 2006 @@ -21,14 +21,18 @@ import org.apache.catalina.Container; import org.apache.catalina.core.StandardContext; import org.apache.catalina.core.StandardHost; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** - * store StandardContext Attributes ... TODO DefaultContext Handling + * store StandardContext Attributes ... * * @author Peter Rossbach * */ public class StoreContextAppender extends StoreAppender { + + private static Log log = LogFactory.getLog(StoreContextAppender.class); /* * Print Context Values. <ul><li> Spezial handling to default workDir. Modified: tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StoreFactoryBase.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StoreFactoryBase.java?rev=394151&r1=394150&r2=394151&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StoreFactoryBase.java (original) +++ tomcat/container/tc5.5.x/modules/storeconfig/src/share/org/apache/catalina/storeconfig/StoreFactoryBase.java Fri Apr 14 10:48:28 2006 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2001,2004 The Apache Software Foundation. + * Copyright 1999-2001,2004-2006 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. @@ -16,6 +16,7 @@ package org.apache.catalina.storeconfig; +import java.io.IOException; import java.io.PrintWriter; import org.apache.catalina.util.StringManager; @@ -149,9 +150,9 @@ * Store only elements from storeChilds methods that are not a transient * child. * - * @param aWriter - * @param indent - * @param aTagElement + * @param aWriter current output writer + * @param indent indentation level + * @param aTagElement current tomcat element * @throws Exception */ protected void storeElement(PrintWriter aWriter, int indent, @@ -173,13 +174,21 @@ } /* - * Save a array of elements @param aWriter @param indent @param elements + * Save a array of elements + * @param aWriter current output writer + * @param indent indentation level + * @param elements list of child elments to store! */ protected void storeElementArray(PrintWriter aWriter, int indent, Object[] elements) throws Exception { if (elements != null) { for (int i = 0; i < elements.length; i++) { - storeElement(aWriter, indent, elements[i]); + try { + storeElement(aWriter, indent, elements[i]); + } catch (IOException ioe) { + // ingore childs report error them self! + // see StandartContext.storeWithBackup() + } } } } Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=394151&r1=394150&r2=394151&view=diff ============================================================================== --- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original) +++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Fri Apr 14 10:48:28 2006 @@ -156,7 +156,7 @@ manager app support and dialog box enhancements. Thanks to George Sexton for the patch. (yoavs) </fix> <fix> - <bug>37781</bug>: Make sure context config file is writeable, suggested by George Sexton. (yoavs) + <bug>37781</bug>: Make sure context config file is writeable, suggested by George Sexton. (yoavs,pero) </fix> </changelog> </subsection> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]