Updates and migration for Jetty 7 (I2P 0.9.6)
This commit is contained in:
zzz
2013-04-15 14:09:10 +00:00
parent ce7562c547
commit ab882f8582
9 changed files with 189 additions and 112 deletions

View File

@ -1,3 +1,7 @@
0.10.0
2013-04-14
Updates and migration for Jetty 7 (I2P 0.9.6)
0.9.0
2013-01-25
Add cache-control directives

View File

@ -11,7 +11,7 @@
<delete file="plugin/i2ptunnel.config" />
<!-- get version number -->
<buildnumber file="scripts/build.number" />
<property name="release.number" value="0.9.0" />
<property name="release.number" value="0.10.0" />
<!-- make the update xpi2p -->
<!-- this contains everything except i2ptunnel.config -->

View File

@ -1,28 +1,22 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<!--
Configure a custom context for the eepsite.
This context contains only a Context with a default servlet
This context contains only a ServletContextHandler with a default servlet
to serve static html files and images.
-->
<Configure class="org.mortbay.jetty.servlet.Context">
<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
<Set name="contextPath">/</Set>
<Set name="resourceBase">$PLUGIN/eepsite/docroot/</Set>
<Call name="setInitParams">
<Arg>
<Map>
<Entry>
<Item>org.mortbay.jetty.servlet.Default.cacheControl</Item>
<Item>max-age=3600,public</Item>
</Entry>
</Map>
</Arg>
<Call name="setInitParameter">
<Arg>cacheControl</Arg>
<Arg>max-age=3600,public</Arg>
</Call>
<Call name="addServlet">
<Arg>org.mortbay.jetty.servlet.DefaultServlet</Arg>
<Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
<Arg>/</Arg>
</Call>
</Configure>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<!--
Configure a custom context for the eepsite.
@ -22,21 +22,15 @@ Configure a custom context for the eepsite.
* parameter value.
-->
<Configure class="org.mortbay.jetty.servlet.Context">
<Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
<Set name="contextPath">/cgi-bin</Set>
<Set name="resourceBase">$PLUGIN/eepsite/cgi-bin/</Set>
<Call name="setInitParams">
<Arg>
<Map>
<Entry>
<Item>Path</Item>
<Item>/usr/local/bin:/bin:/usr/bin</Item>
</Entry>
</Map>
</Arg>
<Call name="setInitParameter">
<Arg>Path</Arg>
<Arg>/usr/local/bin:/bin:/usr/bin</Arg>
</Call>
<Call name="addServlet">
<Arg>org.mortbay.servlet.CGI</Arg>
<Arg>org.eclipse.jetty.servlets.CGI</Arg>
<Arg>/</Arg>
</Call>
</Configure>

View File

@ -35,23 +35,23 @@
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- UNCOMMENT TO ACTIVATE
<context-param>
<param-name>org.mortbay.jetty.servlet.SessionDomain</param-name>
<param-name>org.eclipse.jetty.servlet.SessionDomain</param-name>
<param-value>127.0.0.1</param-value>
</context-param>
<context-param>
<param-name>org.mortbay.jetty.servlet.SessionPath</param-name>
<param-name>org.eclipse.jetty.servlet.SessionPath</param-name>
<param-value>/</param-value>
</context-param>
<context-param>
<param-name>org.mortbay.jetty.servlet.MaxAge</param-name>
<param-name>org.eclipse.jetty.servlet.MaxAge</param-name>
<param-value>-1</param-value>
</context-param>
-->
<context-param>
<param-name>org.mortbay.jetty.webapp.NoTLDJarPattern</param-name>
<param-name>org.eclipse.jetty.webapp.NoTLDJarPattern</param-name>
<param-value>start.jar|ant-.*\.jar|dojo-.*\.jar|jetty-.*\.jar|jsp-api-.*\.jar|junit-.*\.jar|servlet-api-.*\.jar|dnsns\.jar|rt\.jar|jsse\.jar|tools\.jar|sunpkcs11\.jar|sunjce_provider\.jar|xerces.*\.jar</param-value>
</context-param>
@ -112,7 +112,7 @@
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class>
<servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
<init-param>
<param-name>acceptRanges</param-name>
<param-value>true</param-value>
@ -306,7 +306,7 @@
<!-- Uncomment for dynamic invocation
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>org.mortbay.jetty.servlet.Invoker</servlet-class>
<servlet-class>org.eclipse.jetty.servlet.Invoker</servlet-class>
<init-param>
<param-name>verbose</param-name>
<param-value>false</param-value>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.2//EN" "http://jetty.mortbay.org/configure_1_2.dtd">
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<!-- ========================================================================= -->
<!-- This file configures the Jetty server. -->
@ -9,20 +9,20 @@
<!-- * host: Change 127.0.0.1 to 0.0.0.0 in the addListener section -->
<!-- to access the server directly (bypassing i2p) -->
<!-- from other computers. -->
<!-- * port: Default 7662 in the addConnector section -->
<!-- * docroot: Change the ResourceBase in the addContext section -->
<!-- * port: Default 7662 in the addConnector section -->
<!-- * docroot: Change the ResourceBase in the contexts/base-context.xml file -->
<!-- to serve files from a different location. -->
<!-- * threads: Raise MinThreads and/or MaxThreads in the addListener section -->
<!-- * threads: Raise maximumPoolSize in the ThreadPool section -->
<!-- if you have a high-traffic site and get a lot of warnings. -->
<!-- -->
<!-- I2P uses Jetty 6.1.26. If you need web server features not found -->
<!-- in Jetty 6, you may install and run Jetty 7 or 8 in a different JVM -->
<!-- I2P uses Jetty 7. If you need web server features not found -->
<!-- in Jetty 7, you may install and run Jetty 7 or 8 in a different JVM -->
<!-- or run any other web server such as Apache. If you do run another web -->
<!-- server instead, be sure and disable the Jetty 6 server for your -->
<!-- eepsite on http://127.0.0.1:7657/configclients.jsp . -->
<!-- -->
<!-- Jetty now uses the I2P logging system rather than wrapper.log. -->
<!-- Use the log override org.mortbay.jetty.Server to adjust the log level. -->
<!-- Use the log override org.eclipse.jetty.server.Server to adjust the log level. -->
<!-- -->
<!-- Note that the XML encoding for this file is UTF-8. -->
<!-- -->
@ -37,7 +37,7 @@
<!-- =============================================================== -->
<Configure id="Server" class="org.mortbay.jetty.Server">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Server Thread Pool -->
@ -50,7 +50,7 @@
Requests above the max will be queued
-->
<!--
<New class="org.mortbay.thread.QueuedThreadPool">
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">1</Set>
<Set name="maxThreads">16</Set>
<Set name="lowThreads">2</Set>
@ -58,17 +58,21 @@
-->
<!-- Optional Java 5 bounded threadpool with job queue
Requests above the max will be rejected
Requests above the max will be rejected and logged.
High-traffic sites should increase maximumPoolSize.
TODO: would be nice to use the 5-arg constructor but
how do you use an Enum as the TimeUnit argument?
Alternatively, make a custom class where we can
set the thread name, set daemon, etc.
See RouterConsoleRunner.
-->
<New class="org.mortbay.thread.concurrent.ThreadPool">
<Arg type="int">0</Arg>
<Set name="corePoolSize">1</Set>
<Set name="maximumPoolSize">16</Set>
<New class="org.eclipse.jetty.util.thread.ExecutorThreadPool">
<!-- corePoolSize (must be at least 3, increase if Jetty hangs) -->
<Arg type="int">4</Arg>
<!-- maximumPoolSize -->
<Arg type="int">20</Arg>
<!-- keepAliveTime (milliseconds) -->
<Arg type="long">60000</Arg>
</New>
</Set>
@ -82,10 +86,14 @@
<!-- Use this connector for many frequently idle connections
and for threadless continuations.
Not recommended on Java 5 - comment this out, and uncomment the
SocketConnector below.
Do not use for gij or JamVM - comment this out, and uncomment the
SocketConnector below.
-->
<Call name="addConnector">
<Arg>
<New class="org.mortbay.jetty.nio.SelectChannelConnector">
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host">127.0.0.1</Set>
<Set name="port">7662</Set>
<Set name="maxIdleTime">60000</Set>
@ -94,16 +102,35 @@
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">5000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
<Set name="useDirectBuffers">false</Set>
</New>
</Arg>
</Call>
<!-- Recommended to use this connector on Java 5, as
Jetty 6 and Java 5 NIO don't play well together.
-->
<!--
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.bio.SocketConnector">
<Set name="host">127.0.0.1</Set>
<Set name="port">7662</Set>
<Set name="maxIdleTime">60000</Set>
<Set name="Acceptors">1</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
</New>
</Arg>
</Call>
-->
<!-- =========================================================== -->
<!-- Set up global session ID manager -->
<!-- =========================================================== -->
<!--
<Set name="sessionIdManager">
<New class="org.mortbay.jetty.servlet.HashSessionIdManager">
<New class="org.eclipse.jetty.server.session.HashSessionIdManager">
<Set name="workerName">node1</Set>
</New>
</Set>
@ -118,74 +145,74 @@
<!-- that is hosted on the same eepsite. -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Rewrite" class="org.mortbay.jetty.handler.rewrite.RewriteHandler">
<New id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
<Set name="rewriteRequestURI">true</Set>
<Set name="rewritePathInfo">false</Set>
<Set name="originalPathAttribute">requestedPath</Set>
<Set name="rules">
<Array type="org.mortbay.jetty.handler.rewrite.Rule">
<Array type="org.eclipse.jetty.rewrite.handler.Rule">
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/a</Set>
<Set name="replacement">/tracker/announce.jsp</Set>
</New>
</Item>
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/announce</Set>
<Set name="replacement">/tracker/announce.jsp</Set>
</New>
</Item>
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/announce.jsp</Set>
<Set name="replacement">/tracker/announce.jsp</Set>
</New>
</Item>
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/announce.php</Set>
<Set name="replacement">/tracker/announce.jsp</Set>
</New>
</Item>
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/scrape</Set>
<Set name="replacement">/tracker/scrape.jsp</Set>
</New>
</Item>
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/scrape.jsp</Set>
<Set name="replacement">/tracker/scrape.jsp</Set>
</New>
</Item>
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/scrape.php</Set>
<Set name="replacement">/tracker/scrape.jsp</Set>
</New>
</Item>
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/Seedless</Set>
<Set name="replacement">/tracker/seedless.jsp</Set>
</New>
</Item>
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/Seedless/</Set>
<Set name="replacement">/tracker/seedless.jsp</Set>
</New>
</Item>
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/Seedless/index.jsp</Set>
<Set name="replacement">/tracker/seedless.jsp</Set>
</New>
</Item>
<Item>
<New class="org.mortbay.jetty.handler.rewrite.RewritePatternRule">
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
<Set name="pattern">/Seedless/seedless</Set>
<Set name="replacement">/tracker/seedless.jsp</Set>
</New>
@ -193,17 +220,17 @@
</Array>
</Set>
<Set name="handler">
<New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.mortbay.jetty.Handler">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
<Item>
<New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
</Item>
</Array>
</Set>
@ -211,7 +238,32 @@
</Set>
</New>
</Set>
<!-- =============================================================== -->
<!-- Create the deployment manager -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- The deplyment manager handles the lifecycle of deploying web -->
<!-- applications. Apps are provided by instances of the -->
<!-- AppProvider interface. Typically these are provided by -->
<!-- one or more of: -->
<!-- jetty-webapps.xml - monitors webapps for wars and dirs -->
<!-- jetty-contexts.xml - monitors contexts for context xml -->
<!-- jetty-templates.xml - monitors contexts and templates -->
<!-- =============================================================== -->
<Call name="addBean">
<Arg>
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
<Set name="contexts">
<Ref id="Contexts" />
</Set>
<Call name="setContextAttribute">
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
<Arg>.*/.*jsp-api-[^/]*\.jar$|.*/.*jsp-[^/]*\.jar$|.*/.*taglibs[^/]*\.jar$</Arg>
</Call>
</New>
</Arg>
</Call>
<!-- =========================================================== -->
<!-- Configure the context deployer -->
<!-- A context deployer will deploy contexts described in -->
@ -223,15 +275,16 @@
<!-- in the $JETTY_HOME/contexts directory -->
<!-- -->
<!-- =========================================================== -->
<Call name="addLifeCycle">
<Arg>
<New class="org.mortbay.jetty.deployer.ContextDeployer">
<Set name="contexts"><Ref id="Contexts"/></Set>
<Set name="configurationDir">$PLUGIN/contexts</Set>
<Set name="scanInterval">0</Set>
</New>
</Arg>
</Call>
<Ref id="DeploymentManager">
<Call name="addAppProvider">
<Arg>
<New class="org.eclipse.jetty.deploy.providers.ContextProvider">
<Set name="monitoredDirName">$PLUGIN/contexts</Set>
<Set name="scanInterval">120</Set>
</New>
</Arg>
</Call>
</Ref>
<!-- =========================================================== -->
<!-- Configure the webapp deployer. -->
@ -246,18 +299,18 @@
<!-- Normally only one type of deployer need be used. -->
<!-- -->
<!-- =========================================================== -->
<Call name="addLifeCycle">
<Arg>
<New class="org.mortbay.jetty.deployer.WebAppDeployer">
<Set name="contexts"><Ref id="Contexts"/></Set>
<Set name="webAppDir">$PLUGIN/eepsite/webapps</Set>
<Set name="parentLoaderPriority">false</Set>
<Set name="extract">true</Set>
<Set name="allowDuplicates">false</Set>
<Set name="defaultsDescriptor">$PLUGIN/etc/webdefault.xml</Set>
</New>
</Arg>
</Call>
<Ref id="DeploymentManager">
<Call id="webappprovider" name="addAppProvider">
<Arg>
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
<Set name="monitoredDirName">$PLUGIN/eepsite/webapps</Set>
<Set name="parentLoaderPriority">false</Set>
<Set name="extractWars">false</Set>
<Set name="defaultsDescriptor">$PLUGIN/etc/webdefault.xml</Set>
</New>
</Arg>
</Call>
</Ref>
<!-- =========================================================== -->
<!-- Configure Authentication Realms -->
@ -268,9 +321,9 @@
<!-- =========================================================== -->
<!-- UNCOMMENT TO ACTIVATE
<Set name="UserRealms">
<Array type="org.mortbay.jetty.security.UserRealm">
<Array type="org.eclipse.jetty.security.LoginService">
<Item>
<New class="org.mortbay.jetty.security.HashUserRealm">
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">Test Realm</Set>
<Set name="config">$PLUGIN/etc/realm.properties</Set>
<Set name="refreshInterval">0</Set>

View File

@ -7,5 +7,4 @@ author=zzz
updateURL=http://stats.i2p/i2p/plugins/zzzot-update.xpi2p
websiteURL=http://zzz.i2p/forums/16
license=Apache 2.0
min-jetty-version=6
max-jetty-version=6.99999
min-jetty-version=7

View File

@ -11,10 +11,10 @@
<pathelement location="${i2plib}/mstreaming.jar" />
<pathelement location="${ant.home}/lib/ant.jar"/>
<pathelement location="${jettylib}/org.mortbay.jetty.jar"/>
<pathelement location="${jettylib}/jasper-compiler.jar" />
<pathelement location="${jettylib}/jasper-runtime.jar" />
<pathelement location="${jettylib}/javax.servlet.jar" />
<pathelement location="${jettylib}/jetty-util.jar" />
<pathelement location="${jettylib}/jetty-xml.jar" />
<pathelement location="${jettylib}/commons-logging.jar" />
<pathelement location="${jettylib}/commons-el.jar" />
</path>
@ -34,7 +34,7 @@
debug="true" deprecation="on" source="1.5" target="1.5"
destdir="./build/obj"
includeAntRuntime="false"
classpath="${i2plib}/i2p.jar:${i2plib}/i2ptunnel.jar:${i2plib}/i2psnark.jar:${i2plib}/mstreaming.jar:${i2plib}/systray.jar:${jettylib}/org.mortbay.jetty.jar:${jettylib}/jetty-util.jar" >
classpath="${i2plib}/i2p.jar:${i2plib}/i2ptunnel.jar:${i2plib}/i2psnark.jar:${i2plib}/mstreaming.jar:${i2plib}/systray.jar:${jettylib}/org.mortbay.jetty.jar:${jettylib}/jetty-util.jar:${jettylib}/jetty-xml.jar" >
<compilerarg line="${javac.compilerargs}" />
</javac>
</target>

View File

@ -33,8 +33,8 @@ import net.i2p.util.Log;
import net.i2p.i2ptunnel.TunnelController;
import net.i2p.apps.systray.UrlLauncher;
import org.mortbay.jetty.Server;
import org.mortbay.xml.XmlConfiguration;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.xml.XmlConfiguration;
/**
* This handles the starting and stopping of an eepsite tunnel and jetty
@ -54,7 +54,7 @@ public class ZzzOTController {
private static ZzzOT _zzzot;
private static Object _lock = new Object();
private static final String BACKUP = "jetty5.xml";
private static final String BACKUP_SUFFIX = ".jetty6";
private static final String[] xmlFiles = {
"jetty.xml", "contexts/base-context.xml", "contexts/cgi-context.xml",
"etc/realm.properties", "etc/webdefault.xml" };
@ -193,32 +193,63 @@ public class ZzzOTController {
private static void migrateJettyXML(File pluginDir) {
// contexts dir does not exist in Jetty 5
File file = new File(pluginDir, "contexts");
if (file.exists())
return;
file.mkdir();
file = new File(pluginDir, "etc");
file.mkdir();
file = new File(pluginDir, "jetty.xml");
if (file.exists()) {
File backup = new File(pluginDir, BACKUP);
if (backup.exists()) {
I2PAppContext ctx = I2PAppContext.getGlobalContext();
backup = new File(pluginDir, BACKUP + ctx.random().nextInt());
}
boolean ok = FileUtil.copy(file, backup, false, true);
if (!ok) {
_log.error("WARNING: Failed to back up " + file + " to " + backup);
}
}
if (!shouldMigrate(file))
return;
for (int i = 0; i < xmlFiles.length; i++) {
migrateJettyFile(pluginDir, xmlFiles[i]);
backupAndMigrateFile(pluginDir, xmlFiles[i]);
}
}
/**
* @return should we copy over all the files, based on the contents of this one
* @since 0.10 (Jetty 7)
*/
private static boolean shouldMigrate(File f) {
String xml = FileUtil.readTextFile(f.getAbsolutePath(), 100, true);
if (xml == null)
return true;
return xml.contains("class=\"org.mortbay.jetty.Server\"");
}
/**
* Backup a file and migrate new XML
* @return success
* @since Jetty 7
*/
private static boolean backupAndMigrateFile(File toDir, String filename) {
File to = new File(toDir, filename);
boolean rv = backupFile(to);
boolean rv2 = migrateJettyFile(toDir, filename);
return rv && rv2;
}
/**
* Backup a file
* @return success
* @since Jetty 7
*/
private static boolean backupFile(File from) {
if (!from.exists())
return true;
File to = new File(from.getAbsolutePath() + BACKUP_SUFFIX);
if (to.exists())
to = new File(to.getAbsolutePath() + "." + System.currentTimeMillis());
boolean rv = FileUtil.copy(from, to, false, true);
if (rv)
System.err.println("Backed up file " + from + " to " + to);
else
System.err.println("WARNING: Failed to back up file " + from + " to " + to);
return rv;
}
/**
* Migate a single jetty config file, replacing $PLUGIN as we copy it.
*/
private static void migrateJettyFile(File pluginDir, String name) {
private static boolean migrateJettyFile(File pluginDir, String name) {
File templateDir = new File(pluginDir, "templates");
File fileTmpl = new File(templateDir, name);
File outFile = new File(pluginDir, name);
@ -230,8 +261,10 @@ public class ZzzOTController {
props = props.replace("$PLUGIN", pluginDir.getAbsolutePath());
os = new FileOutputStream(outFile);
os.write(props.getBytes("UTF-8"));
return true;
} catch (IOException ioe) {
_log.error(outFile + " migrate failed", ioe);
return false;
} finally {
if (os != null) try { os.close(); } catch (IOException ioe) {}
}