Added two options for apps.properties for directory indices and index pages:
<app>.staticIndex = true <app>.staticHome = index.html, default.htm Default values are (false) for directory listings and "index.html, index.htm" for index pages.
This commit is contained in:
parent
6f213b481c
commit
0c6d25e038
1 changed files with 39 additions and 11 deletions
|
@ -17,6 +17,7 @@
|
||||||
package helma.main;
|
package helma.main;
|
||||||
|
|
||||||
import helma.framework.core.*;
|
import helma.framework.core.*;
|
||||||
|
import helma.util.StringUtils;
|
||||||
import helma.util.SystemProperties;
|
import helma.util.SystemProperties;
|
||||||
import org.apache.xmlrpc.XmlRpcHandler;
|
import org.apache.xmlrpc.XmlRpcHandler;
|
||||||
import org.mortbay.http.*;
|
import org.mortbay.http.*;
|
||||||
|
@ -276,7 +277,10 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
String mountpoint;
|
String mountpoint;
|
||||||
String pathPattern;
|
String pathPattern;
|
||||||
String staticDir;
|
String staticDir;
|
||||||
|
String protectedStaticDir;
|
||||||
String staticMountpoint;
|
String staticMountpoint;
|
||||||
|
boolean staticIndex;
|
||||||
|
String[] staticHome;
|
||||||
String xmlrpcHandlerName;
|
String xmlrpcHandlerName;
|
||||||
String cookieDomain;
|
String cookieDomain;
|
||||||
String uploadLimit;
|
String uploadLimit;
|
||||||
|
@ -295,6 +299,16 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
staticDir = props.getProperty(name+".static");
|
staticDir = props.getProperty(name+".static");
|
||||||
staticMountpoint = getPathPattern(props.getProperty(name+".staticMountpoint",
|
staticMountpoint = getPathPattern(props.getProperty(name+".staticMountpoint",
|
||||||
joinMountpoint(mountpoint, "static")));
|
joinMountpoint(mountpoint, "static")));
|
||||||
|
staticIndex = "true".equalsIgnoreCase(props.getProperty(name+
|
||||||
|
".staticIndex"));
|
||||||
|
String home = props.getProperty(name+".staticHome");
|
||||||
|
if (home == null) {
|
||||||
|
staticHome = new String[] {"index.html", "index.htm"};
|
||||||
|
} else {
|
||||||
|
staticHome = StringUtils.split(home, ",");
|
||||||
|
}
|
||||||
|
protectedStaticDir = props.getProperty(name+".protectedStatic");
|
||||||
|
|
||||||
cookieDomain = props.getProperty(name+".cookieDomain");
|
cookieDomain = props.getProperty(name+".cookieDomain");
|
||||||
uploadLimit = props.getProperty(name+".uploadLimit");
|
uploadLimit = props.getProperty(name+".uploadLimit");
|
||||||
debug = props.getProperty(name+".debug");
|
debug = props.getProperty(name+".debug");
|
||||||
|
@ -361,10 +375,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
app.setBaseURI(mountpoint);
|
app.setBaseURI(mountpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServletHttpContext context = new ServletHttpContext();
|
HttpContext context = server.http.addContext(pathPattern);
|
||||||
|
|
||||||
context.setContextPath(pathPattern);
|
|
||||||
server.http.addContext(context);
|
|
||||||
|
|
||||||
if (encode) {
|
if (encode) {
|
||||||
// FIXME: ContentEncodingHandler is broken/removed in Jetty 4.2
|
// FIXME: ContentEncodingHandler is broken/removed in Jetty 4.2
|
||||||
|
@ -372,7 +383,9 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
Server.getLogger().log("Warning: disabling response encoding for Jetty 4.2 compatibility");
|
Server.getLogger().log("Warning: disabling response encoding for Jetty 4.2 compatibility");
|
||||||
}
|
}
|
||||||
|
|
||||||
ServletHolder holder = context.addServlet(appName, "/*",
|
ServletHandler handler = new ServletHandler();
|
||||||
|
|
||||||
|
ServletHolder holder = handler.addServlet(appName, "/*",
|
||||||
"helma.servlet.EmbeddedServletClient");
|
"helma.servlet.EmbeddedServletClient");
|
||||||
|
|
||||||
holder.setInitParameter("application", appName);
|
holder.setInitParameter("application", appName);
|
||||||
|
@ -392,8 +405,22 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
|
|
||||||
holder.setInitParameter("charset", app.getCharset());
|
holder.setInitParameter("charset", app.getCharset());
|
||||||
|
|
||||||
|
context.addHandler(handler);
|
||||||
|
|
||||||
|
if (protectedStaticDir != null) {
|
||||||
|
File protectedContent = new File(protectedStaticDir);
|
||||||
|
if (!protectedContent.isAbsolute()) {
|
||||||
|
protectedContent = new File(server.getHopHome(), protectedStaticDir);
|
||||||
|
}
|
||||||
|
context.setResourceBase(protectedContent.getAbsolutePath());
|
||||||
|
Server.getLogger().log("Serving protected static from " +
|
||||||
|
protectedContent.getAbsolutePath());
|
||||||
|
context.addHandler(new ResourceHandler());
|
||||||
|
}
|
||||||
|
|
||||||
context.start();
|
context.start();
|
||||||
|
|
||||||
|
// if there is a static direcory specified, mount it
|
||||||
if (staticDir != null) {
|
if (staticDir != null) {
|
||||||
|
|
||||||
File staticContent = new File(staticDir);
|
File staticContent = new File(staticDir);
|
||||||
|
@ -406,14 +433,15 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
Server.getLogger().log("Mounting static at " +
|
Server.getLogger().log("Mounting static at " +
|
||||||
staticMountpoint);
|
staticMountpoint);
|
||||||
|
|
||||||
HttpContext cx = server.http.addContext(staticMountpoint);
|
context = server.http.addContext(staticMountpoint);
|
||||||
|
context.setWelcomeFiles(staticHome);
|
||||||
|
|
||||||
cx.setResourceBase(staticContent.getAbsolutePath());
|
context.setResourceBase(staticContent.getAbsolutePath());
|
||||||
|
|
||||||
ResourceHandler handler = new ResourceHandler();
|
ResourceHandler rhandler = new ResourceHandler();
|
||||||
|
rhandler.setDirAllowed(staticIndex);
|
||||||
cx.addHandler(handler);
|
context.addHandler(rhandler);
|
||||||
cx.start();
|
context.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue