Mercurial > hg > tomcat-userconfig
view src/kryshen/catalina/startup/UserConfig.java @ 10:086a55aa2620
PasswdUserConfig. Error logging.
author | Mikhail Kryshen <mikhail@kryshen.net> |
---|---|
date | Mon, 02 Nov 2009 23:17:40 +0300 |
parents | ff1e55a2171f |
children | 3a71cbe721f9 |
line wrap: on
line source
package kryshen.catalina.startup; import java.io.File; import org.apache.catalina.startup.HostConfig; import org.apache.juli.logging.LogFactory; /** * * @author Mikhail Kryshen */ public abstract class UserConfig extends HostConfig { /** * The directory name to be searched for within each user home directory. */ private String directoryName = "public_webapps"; protected UserConfig() { log = LogFactory.getLog(UserConfig.class); } public String getDirectoryName() { return directoryName; } /** * Set the directory name for user web applications. * * @param directoryName The new directory name */ public void setDirectoryName(String directoryName) { this.directoryName = directoryName; } @Override protected void deployApps() { deployUserApps(); } @Override protected void deployApps(String name) { throw new UnsupportedOperationException ("deployApps(String) is not supported."); } protected abstract void deployUserApps(); protected void deployUserApps(String user, File home) { File base = new File(home, directoryName); if (!base.exists() || !base.isDirectory() || !base.canRead()) { return; } // TODO: deployWARs // deployWARs(appBase, appBase.list()); // Deploy expanded folders deployDirectories(user, base, base.list()); } /** * Deploy user webapp directories. */ protected void deployDirectories(String user, File base, String[] files) { if (files == null) { log.error("Error reading base directory: " + base.getPath() + "."); return; } for (int i = 0; i < files.length; i++) { if (files[i].equalsIgnoreCase("META-INF")) { continue; } if (files[i].equalsIgnoreCase("WEB-INF")) { continue; } File dir = new File(base, files[i]); if (!dir.isDirectory() || !dir.canRead()) { continue; } String contextPath; if (files[i].equals("ROOT")) { contextPath = "/~" + user; } else { contextPath = "/~" + user + '/' + files[i].replace('#', '/'); } if (isServiced(contextPath)) { continue; } deployDirectory(contextPath, dir, dir.getAbsolutePath()); } } }