- Fix help.jsp mapping to language

- Fix nowebapp.jsp for non-started webapps
- Fix nowebapp.jsp for url /foo for non-started webapp foo
This commit is contained in:
zzz
2011-12-24 05:26:56 +00:00
parent 5a4becba68
commit 0fb9096096
6 changed files with 24 additions and 45 deletions

View File

@ -76,9 +76,7 @@ public class LocaleWebAppHandler extends WebAppContext
if (lang != null && lang.length() > 0 && !lang.equals("en")) {
String testPath = pathInContext.substring(0, len - 4) + '_' + lang + ".jsp";
// Do we have a servlet for the new path that isn't the catchall *.jsp?
//Map.Entry servlet = getHolderEntry(testPath);
///////////////////////////////
Map.Entry servlet = null;
Map.Entry servlet = getServletHandler().getHolderEntry(testPath);
if (servlet != null) {
String servletPath = (String) servlet.getKey();
if (servletPath != null && !servletPath.startsWith("*")) {

View File

@ -42,6 +42,7 @@ import org.mortbay.jetty.security.ConstraintMapping;
import org.mortbay.jetty.security.SecurityHandler;
import org.mortbay.jetty.security.SslSelectChannelConnector;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.jetty.servlet.SessionHandler;
import org.mortbay.jetty.webapp.WebAppContext;
import org.mortbay.thread.QueuedThreadPool;
@ -197,6 +198,7 @@ public class RouterConsoleRunner {
* SessionHandler
* SecurityHandler
* ServletHandler
* servlets...
* WebAppContext
* ...
* DefaultHandler
@ -267,7 +269,8 @@ public class RouterConsoleRunner {
_webAppsDir += '/';
List<String> notStarted = new ArrayList();
WebAppContext baseHandler = null;
WebAppContext rootWebApp = null;
ServletHandler rootServletHandler = null;
try {
int boundAddresses = 0;
@ -347,16 +350,17 @@ public class RouterConsoleRunner {
return;
}
baseHandler = new LocaleWebAppHandler(I2PAppContext.getGlobalContext(),
rootWebApp = new LocaleWebAppHandler(I2PAppContext.getGlobalContext(),
"/", _webAppsDir + ROUTERCONSOLE + ".war");
File tmpdir = new SecureDirectory(workDir, ROUTERCONSOLE + "-" +
(_listenPort != null ? _listenPort : _sslListenPort));
tmpdir.mkdir();
baseHandler.setTempDirectory(tmpdir);
baseHandler.setSessionHandler(new SessionHandler());
baseHandler.setServletHandler(new ServletHandler());
initialize(baseHandler);
chColl.addHandler(baseHandler);
rootWebApp.setTempDirectory(tmpdir);
rootWebApp.setSessionHandler(new SessionHandler());
rootServletHandler = new ServletHandler();
rootWebApp.setServletHandler(rootServletHandler);
initialize(rootWebApp);
chColl.addHandler(rootWebApp);
File dir = new File(_webAppsDir);
String fileNames[] = dir.list(WarFilenameFilter.instance());
@ -404,15 +408,23 @@ public class RouterConsoleRunner {
me.printStackTrace();
}
if (baseHandler != null) {
if (rootServletHandler != null && notStarted.size() > 0) {
// map each not-started webapp to the error page
ServletHolder noWebApp = rootServletHandler.getServlet("net.i2p.router.web.jsp.nowebapp_jsp");
for (int i = 0; i < notStarted.size(); i++) {
// we want a new handler for each one since if the webapp is started we remove the handler???
try {
/////////////////////////////////////////////////
//baseHandler.mapPathToServlet('/' + notStarted.get(i) + "/*",
// "net.i2p.router.web.jsp.nowebapp_jsp");
if (noWebApp != null) {
String path = '/' + notStarted.get(i);
// LocaleWebAppsHandler adds a .jsp
rootServletHandler.addServletWithMapping(noWebApp, path + ".jsp");
rootServletHandler.addServletWithMapping(noWebApp, path + "/*");
} else {
System.err.println("Can't find nowebapp.jsp?");
}
} catch (Throwable me) {
System.err.println(me);
me.printStackTrace();
}
}
}

View File

@ -1,8 +0,0 @@
<html><head><title>I2PSnark Anonymous BitTorrent Client Disabled</title>
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
</head>
<body>
The I2PSnark Anonymous BitTorrent Client is not running. Please visit the <a href="/configclients#webapp">config clients page</a>
to start it.
</body></html>

View File

@ -1,7 +0,0 @@
<html><head><title>I2P Tunnel Manager Not Running</title>
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
</head>
<body>
The I2P Tunnel Manager is not currently running. Please visit the <a href="/configclients#webapp">Client Configuration</a> page to start it.
</body></html>

View File

@ -1,8 +0,0 @@
<html><head><title>SusiDNS Disabled</title>
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
</head>
<body>
SusiDNS is not running. Go to <a href="/configclients#webapp">the config clients page</a>
to start it.
</body></html>

View File

@ -1,8 +0,0 @@
<html><head><title>SusiMail Disabled</title>
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
</head>
<body>
SusiMail is not running. Go to <a href="/configclients#webapp">the config clients page</a>
to start it.
</body></html>