view src/kryshen/catalina/startup/UserConfig.java @ 8:ff1e55a2171f

Refactored.
author Mikhail Kryshen <mikhail@kryshen.net>
date Sun, 01 Nov 2009 05:41:39 +0300
parents ca0b81d28307
children 086a55aa2620
line source
1 package kryshen.catalina.startup;
3 import java.io.File;
4 import org.apache.catalina.startup.HostConfig;
6 /**
7 *
8 * @author Mikhail Kryshen
9 */
10 public abstract class UserConfig extends HostConfig {
12 @Override
13 protected void deployApps() {
14 deployUserApps();
15 }
17 @Override
18 protected void deployApps(String name) {
19 throw new UnsupportedOperationException
20 ("deployApps(String) is not supported.");
21 }
23 protected abstract void deployUserApps();
25 protected void deployUserApps(String user, File base) {
26 if (!base.exists() || !base.isDirectory() || !base.canRead()) {
27 return;
28 }
30 // TODO: deployWARs
31 // deployWARs(appBase, appBase.list());
33 // Deploy expanded folders
34 deployDirectories(user, base, base.list());
35 }
37 /**
38 * Deploy user webapp directories.
39 */
40 protected void deployDirectories(String user, File base, String[] files) {
42 if (files == null) {
43 return;
44 }
46 for (int i = 0; i < files.length; i++) {
47 if (files[i].equalsIgnoreCase("META-INF")) {
48 continue;
49 }
51 if (files[i].equalsIgnoreCase("WEB-INF")) {
52 continue;
53 }
55 File dir = new File(base, files[i]);
57 if (!dir.isDirectory() || !dir.canRead()) {
58 continue;
59 }
61 String contextPath;
63 if (files[i].equals("ROOT")) {
64 contextPath = "/~" + user;
65 } else {
66 contextPath = "/~" + user + '/' + files[i].replace('#', '/');
67 }
69 if (isServiced(contextPath)) {
70 continue;
71 }
73 deployDirectory(contextPath, dir, dir.getAbsolutePath());
74 }
75 }
76 }