adopted input statement - SystemProperties moved to helma.util.
This commit is contained in:
parent
55e58ab509
commit
96abb621ec
1 changed files with 205 additions and 116 deletions
|
@ -2,17 +2,44 @@ package helma.doc;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import helma.objectmodel.*;
|
import helma.util.SystemProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of the Class
|
||||||
|
*
|
||||||
|
*@author Stefan Pollach
|
||||||
|
*@created August 20, 2001
|
||||||
|
*/
|
||||||
public class DocRun {
|
public class DocRun {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of the Field
|
||||||
|
*/
|
||||||
public static String propfile;
|
public static String propfile;
|
||||||
|
/**
|
||||||
|
* Description of the Field
|
||||||
|
*/
|
||||||
public static SystemProperties sysProps, dbProps;
|
public static SystemProperties sysProps, dbProps;
|
||||||
|
/**
|
||||||
|
* Description of the Field
|
||||||
|
*/
|
||||||
public static String actionExtension;
|
public static String actionExtension;
|
||||||
|
/**
|
||||||
|
* Description of the Field
|
||||||
|
*/
|
||||||
public static String scriptExtension;
|
public static String scriptExtension;
|
||||||
|
/**
|
||||||
|
* Description of the Field
|
||||||
|
*/
|
||||||
public static String templateExtension;
|
public static String templateExtension;
|
||||||
|
/**
|
||||||
|
* Description of the Field
|
||||||
|
*/
|
||||||
public static String skinExtension = ".skin";
|
public static String skinExtension = ".skin";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of the Field
|
||||||
|
*/
|
||||||
public static String hopHomeDir;
|
public static String hopHomeDir;
|
||||||
|
|
||||||
private static Hashtable options;
|
private static Hashtable options;
|
||||||
|
@ -20,119 +47,181 @@ public class DocRun {
|
||||||
String appName;
|
String appName;
|
||||||
DocApplication app;
|
DocApplication app;
|
||||||
|
|
||||||
public static void main ( String args[] ) {
|
|
||||||
|
/**
|
||||||
|
* Constructor for the DocRun object
|
||||||
|
*
|
||||||
|
*@param appDir Description of Parameter
|
||||||
|
*@exception DocException Description of Exception
|
||||||
|
*/
|
||||||
|
public DocRun(String appDir) throws DocException {
|
||||||
|
File d = new File(appDir);
|
||||||
|
if (!d.exists()) {
|
||||||
|
throw new DocException(d.toString() + " doesn't exist");
|
||||||
|
}
|
||||||
|
if (!d.isDirectory()) {
|
||||||
|
throw new DocException(d.toString() + " is not a directory");
|
||||||
|
}
|
||||||
|
log("parsing application " + d.getName() + " located in " + d.getAbsolutePath());
|
||||||
|
log("writing output to " + getOption("-d", new File(hopHomeDir, "/appdocs/" + d.getName()).getAbsolutePath()));
|
||||||
|
app = new DocApplication(d.getName(), d.getAbsolutePath());
|
||||||
|
DocWriter.start(getOption("-d", new File(hopHomeDir, "/appdocs/" + d.getName()).getAbsolutePath()), app);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the option attribute of the DocRun class
|
||||||
|
*
|
||||||
|
*@param name Description of Parameter
|
||||||
|
*@return The option value
|
||||||
|
*/
|
||||||
|
public static String getOption(String name) {
|
||||||
|
return getOption(name, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the option attribute of the DocRun class
|
||||||
|
*
|
||||||
|
*@param name Description of Parameter
|
||||||
|
*@param def Description of Parameter
|
||||||
|
*@return The option value
|
||||||
|
*/
|
||||||
|
public static String getOption(String name, String def) {
|
||||||
|
if (options.containsKey(name)) {
|
||||||
|
return (String) options.get(name);
|
||||||
|
} else {
|
||||||
|
return (def);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of the Method
|
||||||
|
*
|
||||||
|
*@param args Description of Parameter
|
||||||
|
*/
|
||||||
|
public static void main(String args[]) {
|
||||||
boolean usageError = false;
|
boolean usageError = false;
|
||||||
// parse options from command line
|
// parse options from command line
|
||||||
options = new Hashtable();
|
options = new Hashtable();
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
String name = "";
|
String name = "";
|
||||||
for ( int i=0; i<args.length; i++ ) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
if ( args[i].startsWith("-") ) {
|
if (args[i].startsWith("-")) {
|
||||||
if ( i>0 ) {
|
if (i > 0) {
|
||||||
if ( buf.toString().length()==0 )
|
if (buf.toString().length() == 0) {
|
||||||
usageError = true;
|
usageError = true;
|
||||||
else
|
} else {
|
||||||
options.put(name,buf.toString() );
|
options.put(name, buf.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
name = args[i];
|
name = args[i];
|
||||||
buf = new StringBuffer();
|
buf = new StringBuffer();
|
||||||
} else {
|
} else {
|
||||||
buf.append( ( (buf.toString().length()>0) ? " ":"" ) + args[i]);
|
buf.append(((buf.toString().length() > 0) ? " " : "") + args[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options.put(name,buf.toString()); // include last option
|
options.put(name, buf.toString());
|
||||||
|
// include last option
|
||||||
// now check parameter
|
// now check parameter
|
||||||
if ( options.containsKey("-h") ) {
|
if (options.containsKey("-h")) {
|
||||||
hopHomeDir = (String)options.get("-h");
|
hopHomeDir = (String) options.get("-h");
|
||||||
} else {
|
} else {
|
||||||
hopHomeDir = System.getProperty("user.dir");
|
hopHomeDir = System.getProperty("user.dir");
|
||||||
}
|
}
|
||||||
readHopProperties(hopHomeDir);
|
readHopProperties(hopHomeDir);
|
||||||
String parAppDir = "";
|
String parAppDir = "";
|
||||||
if ( options.containsKey("-a") ) {
|
if (options.containsKey("-a")) {
|
||||||
parAppDir = (String)options.get("-a");
|
parAppDir = (String) options.get("-a");
|
||||||
} else {
|
} else {
|
||||||
usageError = true;
|
usageError = true;
|
||||||
}
|
}
|
||||||
if ( usageError==true ) {
|
if (usageError == true) {
|
||||||
help();
|
help();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
new DocRun(parAppDir);
|
new DocRun(parAppDir);
|
||||||
} catch ( DocException e ) {
|
} catch (DocException e) {
|
||||||
System.out.println("doc error: " + e.getMessage());
|
System.out.println("doc error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void help() {
|
|
||||||
System.out.println ("usage: java helma.doc.DocApplication -a appdir [-f] [-h hopdir] [-d docdir] [-i ignore]");
|
|
||||||
System.out.println (" -a appdir Specify source directory");
|
|
||||||
System.out.println (" -h hopdir Specify hop home directory");
|
|
||||||
System.out.println (" -d docdir Specify destination directory");
|
|
||||||
System.out.println (" -f true Link functions to source code");
|
|
||||||
System.out.println (" -i ignore Specify prototypes to ignore (like: \"-i CVS mistsack\")");
|
|
||||||
System.out.println (" -debug");
|
|
||||||
System.out.println ("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean prototypeAllowed(String name) {
|
|
||||||
String ig = " " + getOption("-i").toLowerCase() + " ";
|
|
||||||
if ( ig.equals("") ) return true;
|
|
||||||
name = name.toLowerCase();
|
|
||||||
if ( ig.indexOf(" "+name+" ")>-1 )
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reads server.properties, apps.properties and db.properties from hop-home-directory
|
* Description of the Method
|
||||||
* TBD: should be cleaned up to work exactly like the helma server
|
*/
|
||||||
* @param homeDir hop-home-directory with server.properties-file
|
public static void help() {
|
||||||
|
System.out.println("usage: java helma.doc.DocApplication -a appdir [-f] [-h hopdir] [-d docdir] [-i ignore]");
|
||||||
|
System.out.println(" -a appdir Specify source directory");
|
||||||
|
System.out.println(" -h hopdir Specify hop home directory");
|
||||||
|
System.out.println(" -d docdir Specify destination directory");
|
||||||
|
System.out.println(" -f true Link functions to source code");
|
||||||
|
System.out.println(" -i ignore Specify prototypes to ignore (like: \"-i CVS mistsack\")");
|
||||||
|
System.out.println(" -debug");
|
||||||
|
System.out.println("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of the Method
|
||||||
|
*
|
||||||
|
*@param name Description of Parameter
|
||||||
|
*@return Description of the Returned Value
|
||||||
|
*/
|
||||||
|
public static boolean prototypeAllowed(String name) {
|
||||||
|
String ig = " " + getOption("-i").toLowerCase() + " ";
|
||||||
|
if (ig.equals("")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
name = name.toLowerCase();
|
||||||
|
if (ig.indexOf(" " + name + " ") > -1) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reads server.properties, apps.properties and db.properties from
|
||||||
|
* hop-home-directory TBD: should be cleaned up to work exactly like the
|
||||||
|
* helma server
|
||||||
|
*
|
||||||
|
*@param hopHomeDir Description of Parameter
|
||||||
*/
|
*/
|
||||||
public static void readHopProperties(String hopHomeDir) {
|
public static void readHopProperties(String hopHomeDir) {
|
||||||
propfile = new File (hopHomeDir, "server.properties").getAbsolutePath();
|
propfile = new File(hopHomeDir, "server.properties").getAbsolutePath();
|
||||||
sysProps = new SystemProperties (propfile);
|
sysProps = new SystemProperties(propfile);
|
||||||
dbProps = new SystemProperties ( new File(hopHomeDir,"db.properties").getAbsolutePath() );
|
dbProps = new SystemProperties(new File(hopHomeDir, "db.properties").getAbsolutePath());
|
||||||
actionExtension = sysProps.getProperty("actionExtension",".hac");
|
actionExtension = sysProps.getProperty("actionExtension", ".hac");
|
||||||
scriptExtension = sysProps.getProperty("scriptExtension",".js");
|
scriptExtension = sysProps.getProperty("scriptExtension", ".js");
|
||||||
templateExtension = sysProps.getProperty("templateExtension",".hsp");
|
templateExtension = sysProps.getProperty("templateExtension", ".hsp");
|
||||||
}
|
}
|
||||||
|
|
||||||
public DocRun (String appDir) throws DocException {
|
|
||||||
File d = new File(appDir);
|
|
||||||
if ( !d.exists() )
|
|
||||||
throw new DocException( d.toString() + " doesn't exist");
|
|
||||||
if ( !d.isDirectory() )
|
|
||||||
throw new DocException( d.toString() + " is not a directory");
|
|
||||||
log ( "parsing application " + d.getName() + " located in " + d.getAbsolutePath() );
|
|
||||||
log ( "writing output to " + getOption("-d", new File(hopHomeDir,"/appdocs/"+d.getName()).getAbsolutePath()) );
|
|
||||||
app = new DocApplication(d.getName(),d.getAbsolutePath() );
|
|
||||||
DocWriter.start( getOption("-d", new File(hopHomeDir,"/appdocs/"+d.getName()).getAbsolutePath()), app);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getOption(String name) {
|
|
||||||
return getOption(name,"");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getOption(String name, String def) {
|
|
||||||
if ( options.containsKey(name) )
|
|
||||||
return(String)options.get(name);
|
|
||||||
else
|
|
||||||
return(def);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of the Method
|
||||||
|
*
|
||||||
|
*@param msg Description of Parameter
|
||||||
|
*/
|
||||||
public static void debug(String msg) {
|
public static void debug(String msg) {
|
||||||
if ( options.containsKey("-debug") )
|
if (options.containsKey("-debug")) {
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void log( String msg ) {
|
|
||||||
|
/**
|
||||||
|
* Description of the Method
|
||||||
|
*
|
||||||
|
*@param msg Description of Parameter
|
||||||
|
*/
|
||||||
|
public static void log(String msg) {
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue