added addExclude() and isExcluded() which are backed by a HashSet so that

we can have a per-app config of excluded strings.

added readProps() which parses app.properties for helma.excludeDocs setting
This commit is contained in:
stefanp 2003-03-14 11:36:48 +00:00
parent 0625420803
commit 2ea3261e16

View file

@ -2,11 +2,14 @@ package helma.doc;
import helma.framework.IPathElement; import helma.framework.IPathElement;
import helma.main.Server; import helma.main.Server;
import helma.util.SystemProperties;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
public class DocApplication extends DocDirElement { public class DocApplication extends DocDirElement {
HashSet excluded;
public static void main (String args[]) { public static void main (String args[]) {
// DocApplication app; // DocApplication app;
// app = new DocApplication (args[0], args[1]); // app = new DocApplication (args[0], args[1]);
@ -28,10 +31,41 @@ public class DocApplication extends DocDirElement {
public DocApplication (String name, File location) throws DocException { public DocApplication (String name, File location) throws DocException {
super (name, location, APPLICATION); super (name, location, APPLICATION);
readProps ();
} }
public DocApplication (String name, String appDir) throws DocException { public DocApplication (String name, String appDir) throws DocException {
super (name, new File (appDir), APPLICATION); super (name, new File (appDir), APPLICATION);
readProps ();
}
/**
* reads the app.properties file and parses for helma.excludeDocs
*/
private void readProps () {
File propsFile = new File (location, "app.properties");
SystemProperties serverProps = Server.getServer ().getProperties ();
SystemProperties appProps = new SystemProperties(propsFile.getAbsolutePath (), serverProps);
excluded = new HashSet ();
addExclude ("cvs");
addExclude (".docs");
String excludeProps = appProps.getProperty ("helma.excludeDocs");
if (excludeProps != null) {
StringTokenizer tok = new StringTokenizer (excludeProps, ",");
while (tok.hasMoreTokens ()) {
String str = tok.nextToken ().trim ();
addExclude (str);
}
}
}
public void addExclude (String str) {
excluded.add (str.toLowerCase ());
}
public boolean isExcluded (String str) {
return (excluded.contains (str.toLowerCase ()));
} }
@ -39,10 +73,11 @@ public class DocApplication extends DocDirElement {
* reads all prototypes and files of the application * reads all prototypes and files of the application
*/ */
public void readApplication () { public void readApplication () {
readProps ();
String arr[] = location.list (); String arr[] = location.list ();
children.clear (); children.clear ();
for (int i=0; i<arr.length; i++) { for (int i=0; i<arr.length; i++) {
if (Util.isExcluded (arr[i])) if (isExcluded (arr[i]))
continue; continue;
File f = new File (location.getAbsolutePath (), arr[i]); File f = new File (location.getAbsolutePath (), arr[i]);
if (!f.isDirectory ()) if (!f.isDirectory ())