adding GenHTMLsingle; works; GenHTML, too
authorwneuper
Mon, 25 Aug 2008 14:05:21 +0200
changeset 391229d5d67c74a1
parent 3911 dad646edb2a7
child 3913 90bd669c4509
adding GenHTMLsingle; works; GenHTML, too
src/java/isac/browserdialog/BrowserDialog.java
src/java/isac/util/GenHTMLsinglePaths.java
src/java/isac/util/genhtml/GenHTML.java
src/java/isac/util/genhtml/GenHTMLsingle.java
     1.1 --- a/src/java/isac/browserdialog/BrowserDialog.java	Sun Aug 24 20:19:56 2008 +0200
     1.2 +++ b/src/java/isac/browserdialog/BrowserDialog.java	Mon Aug 25 14:05:21 2008 +0200
     1.3 @@ -284,6 +284,7 @@
     1.4          String type = ""; // taken from here............^^^ (mustbe same^^^)
     1.5          // filename and exp_key -- ".xxx" should be the same
     1.6  
     1.7 +        //WN080825 StringTokenizer better ?
     1.8          link_array = to_interpret.split("#");
     1.9          link = link_array[0];
    1.10          if (link_array.length == 2) {
     2.1 --- a/src/java/isac/util/GenHTMLsinglePaths.java	Sun Aug 24 20:19:56 2008 +0200
     2.2 +++ b/src/java/isac/util/GenHTMLsinglePaths.java	Mon Aug 25 14:05:21 2008 +0200
     2.3 @@ -17,6 +17,7 @@
     2.4                  Properties p = new Properties();
     2.5                  p.load(is);
     2.6                  FILE_TO_CHECK = p.getProperty("FILE_TO_CHECK");
     2.7 +                GENHTML_DESTINATON_PATH = p.getProperty("GENHTML_DESTINATON_PATH");
     2.8              }
     2.9          } catch (Exception e) {
    2.10              FILE_TO_CHECK = "";
    2.11 @@ -26,4 +27,6 @@
    2.12  
    2.13      public static String FILE_TO_CHECK = "";
    2.14  
    2.15 +    public static String GENHTML_DESTINATON_PATH = "";
    2.16 +
    2.17  }
    2.18 \ No newline at end of file
     3.1 --- a/src/java/isac/util/genhtml/GenHTML.java	Sun Aug 24 20:19:56 2008 +0200
     3.2 +++ b/src/java/isac/util/genhtml/GenHTML.java	Mon Aug 25 14:05:21 2008 +0200
     3.3 @@ -50,10 +50,8 @@
     3.4  
     3.5      static final int SIMPLE_PBL_NODE = 5;
     3.6  
     3.7 -    // storage-destination for the generated html-files
     3.8 -    static String destination_ = KEStorePaths.GENHTML_DESTINATON_PATH;
     3.9 -
    3.10 -    private static FileWriter error_log;
    3.11 +    // made an argument of loadContent for usage by GenHTMLsingle
    3.12 +    //private static FileWriter error_log;
    3.13  
    3.14      public static void main(String[] args) {
    3.15  
    3.16 @@ -63,8 +61,10 @@
    3.17              System.exit(1);
    3.18          }
    3.19          KEStorePaths.setConstants(args[0]);
    3.20 -
    3.21 +        
    3.22 +        
    3.23          // storage-destination of the problems occuring in the xml files
    3.24 +        FileWriter error_log = null;
    3.25          try {
    3.26              error_log = new FileWriter(KEStorePaths.GENHTML_DESTINATON_PATH
    3.27                      + "GENHTML_error_log.txt");
    3.28 @@ -72,64 +72,65 @@
    3.29              e.printStackTrace();
    3.30          }
    3.31  
    3.32 +        String destination = "";
    3.33          if (args.length > 0)
    3.34 -            destination_ = KEStorePaths.GENHTML_DESTINATON_PATH;
    3.35 +            destination = KEStorePaths.GENHTML_DESTINATON_PATH;
    3.36          GenHTML genhtml = new GenHTML();
    3.37  
    3.38 -        genhtml.buildHierarchy("met/code.html");
    3.39 -        genhtml.buildHierarchy("met/index.html");
    3.40 -        genhtml.buildHierarchy("met/heading.html");
    3.41 -        genhtml.buildHierarchy("met/menu_empty.html");
    3.42 -        genhtml.buildHierarchy("met/main.html");
    3.43 +        genhtml.buildHierarchy(destination, "met/code.html");
    3.44 +        genhtml.buildHierarchy(destination, "met/index.html");
    3.45 +        genhtml.buildHierarchy(destination, "met/heading.html");
    3.46 +        genhtml.buildHierarchy(destination, "met/menu_empty.html");
    3.47 +        genhtml.buildHierarchy(destination, "met/main.html");
    3.48  
    3.49 -        genhtml.buildHierarchy("pbl/code.html");
    3.50 -        genhtml.buildHierarchy("pbl/index.html");
    3.51 -        genhtml.buildHierarchy("pbl/heading.html");
    3.52 -        genhtml.buildHierarchy("pbl/menu_empty.html");
    3.53 -        genhtml.buildHierarchy("pbl/main.html");
    3.54 +        genhtml.buildHierarchy(destination, "pbl/code.html");
    3.55 +        genhtml.buildHierarchy(destination, "pbl/index.html");
    3.56 +        genhtml.buildHierarchy(destination, "pbl/heading.html");
    3.57 +        genhtml.buildHierarchy(destination, "pbl/menu_empty.html");
    3.58 +        genhtml.buildHierarchy(destination, "pbl/main.html");
    3.59  
    3.60 -        genhtml.buildHierarchy("thy/code.html");
    3.61 -        genhtml.buildHierarchy("thy/index.html");
    3.62 -        genhtml.buildHierarchy("thy/heading.html");
    3.63 -        genhtml.buildHierarchy("thy/menu_empty.html");
    3.64 -        genhtml.buildHierarchy("thy/main.html");
    3.65 +        genhtml.buildHierarchy(destination, "thy/code.html");
    3.66 +        genhtml.buildHierarchy(destination, "thy/index.html");
    3.67 +        genhtml.buildHierarchy(destination, "thy/heading.html");
    3.68 +        genhtml.buildHierarchy(destination, "thy/menu_empty.html");
    3.69 +        genhtml.buildHierarchy(destination, "thy/main.html");
    3.70  
    3.71 -        genhtml.buildHierarchy("exp/code.html");
    3.72 -        genhtml.buildHierarchy("exp/index.html");
    3.73 -        genhtml.buildHierarchy("exp/heading.html");
    3.74 -        genhtml.buildHierarchy("exp/menu_empty.html");
    3.75 -        genhtml.buildHierarchy("exp/main.html");
    3.76 +        genhtml.buildHierarchy(destination, "exp/code.html");
    3.77 +        genhtml.buildHierarchy(destination, "exp/index.html");
    3.78 +        genhtml.buildHierarchy(destination, "exp/heading.html");
    3.79 +        genhtml.buildHierarchy(destination, "exp/menu_empty.html");
    3.80 +        genhtml.buildHierarchy(destination, "exp/main.html");
    3.81  
    3.82          Set exp_set = genhtml.loadFileList("exp");
    3.83          Iterator exp_it = exp_set.iterator();
    3.84          int index = exp_set.size();
    3.85          while (exp_it.hasNext()) {
    3.86 -            System.out.println("exp to generate:" + (index--));
    3.87 -            genhtml.loadContent("exp/" + exp_it.next());
    3.88 +            //System.out.println("exp to generate:" + (index--));
    3.89 +            genhtml.loadContent(error_log, destination, "exp/" + exp_it.next());
    3.90          }
    3.91  
    3.92          Set pbl_set = genhtml.loadFileList("pbl");
    3.93          index = pbl_set.size();
    3.94          Iterator pbl_it = pbl_set.iterator();
    3.95          while (pbl_it.hasNext()) {
    3.96 -            System.out.println("pbl to generate:" + (index--));
    3.97 -            genhtml.loadContent("pbl/" + pbl_it.next());
    3.98 +            //System.out.println("pbl to generate:" + (index--));
    3.99 +            genhtml.loadContent(error_log, destination, "pbl/" + pbl_it.next());
   3.100          }
   3.101  
   3.102          Set thy_set = genhtml.loadFileList("thy");
   3.103          index = thy_set.size();
   3.104          Iterator thy_it = thy_set.iterator();
   3.105          while (thy_it.hasNext()) {
   3.106 -            System.out.println("thy to generate:" + (index--));
   3.107 -            genhtml.loadContent("thy/" + thy_it.next());
   3.108 +            //System.out.println("thy to generate:" + (index--));
   3.109 +            genhtml.loadContent(error_log, destination, "thy/" + thy_it.next());
   3.110          }
   3.111  
   3.112          Set met_set = genhtml.loadFileList("met");
   3.113          index = met_set.size();
   3.114          Iterator met_it = met_set.iterator();
   3.115          while (met_it.hasNext()) {
   3.116 -            System.out.println("met to generate:" + (index--));
   3.117 -            genhtml.loadContent("met/" + met_it.next());
   3.118 +            //System.out.println("met to generate:" + (index--));
   3.119 +            genhtml.loadContent(error_log, destination, "met/" + met_it.next());
   3.120          }
   3.121  
   3.122          try {
   3.123 @@ -175,8 +176,13 @@
   3.124  
   3.125      /**
   3.126       * Loads all hierarchies which are displayed on the web-browser
   3.127 +     * 
   3.128 +     * @param destination
   3.129 +     *            path to kbase
   3.130 +     * @param path
   3.131 +     *            is exp/exp_filname.xxx | thy/thy_filname.xxx | ...
   3.132       */
   3.133 -    protected void buildHierarchy(String path) {
   3.134 +    protected void buildHierarchy(String destination, String path) {
   3.135  
   3.136          String session = ""; // /FIXME why is here an empty
   3.137          // session ID??? -> Problem with
   3.138 @@ -244,8 +250,7 @@
   3.139                  // Perform the transformation, sending the output to the
   3.140                  // response.
   3.141                  // java.io.PrintWriter out = response.getWriter();
   3.142 -                FileWriter out = new FileWriter(destination_ + type + "/"
   3.143 -                        + path);
   3.144 +                FileWriter out = new FileWriter(destination + type + "/" + path);
   3.145                  out.write(header);
   3.146                  Encoder.encodeInformation(xslSource, xmlSource, out);
   3.147                  out.write(footer);
   3.148 @@ -265,8 +270,7 @@
   3.149                  // fixed path /isac/util/genhtml/jscript/
   3.150                  InputStream istream = getClass().getResourceAsStream(
   3.151                          "/isac/util/genhtml/jscript/" + path);
   3.152 -                FileWriter out = new FileWriter(destination_ + type + "/"
   3.153 -                        + path);
   3.154 +                FileWriter out = new FileWriter(destination + type + "/" + path);
   3.155                  int input;
   3.156                  while ((input = istream.read()) != -1) {
   3.157                      out.write(input);
   3.158 @@ -298,7 +302,7 @@
   3.159                  + string + "</DESCRIPTION></ERROR>";
   3.160      }
   3.161  
   3.162 -    protected void loadFile(String path) {
   3.163 +    protected void loadFile(String destination, String path) {
   3.164          StringTokenizer tokens = new StringTokenizer(path, "/");
   3.165          // (String)request.getSession().getAttribute("session_id");
   3.166          // if(session==null)
   3.167 @@ -323,12 +327,12 @@
   3.168  
   3.169                  // Perform the transformation, sending the output to the
   3.170                  // response.
   3.171 -                java.io.FileWriter out = new FileWriter(destination_ + type
   3.172 +                java.io.FileWriter out = new FileWriter(destination + type
   3.173                          + "/" + path);
   3.174                  Encoder.encodeHierarchy(type, xmlSource, out);
   3.175                  return;
   3.176              } else if (path.trim().endsWith("heading.html")) {
   3.177 -                java.io.FileWriter out = new FileWriter(destination_ + type
   3.178 +                java.io.FileWriter out = new FileWriter(destination + type
   3.179                          + "/" + path);
   3.180                  out.write(getHeader(session_id));
   3.181                  return;
   3.182 @@ -342,7 +346,7 @@
   3.183  
   3.184                  // Perform the transformation, sending the output to the
   3.185                  // response.
   3.186 -                java.io.FileWriter out = new FileWriter(destination_ + type
   3.187 +                java.io.FileWriter out = new FileWriter(destination + type
   3.188                          + "/" + path);
   3.189  
   3.190                  Encoder.encodeHContent(type, xmlSource, out);
   3.191 @@ -363,7 +367,7 @@
   3.192              InputStream istream = getClass().getResourceAsStream(
   3.193              // fixed path /isac/BrowserServlet/jscript/ OUT OF DATE
   3.194                      "/isac/BrowserServlet/jscript/" + path);
   3.195 -            java.io.FileWriter out = new FileWriter(destination_ + type + "/"
   3.196 +            java.io.FileWriter out = new FileWriter(destination + type + "/"
   3.197                      + path);
   3.198              int input;
   3.199              while ((input = istream.read()) != -1) {
   3.200 @@ -399,12 +403,22 @@
   3.201          return headercontent;
   3.202      }
   3.203  
   3.204 -    protected void loadContent(String path) {
   3.205 +    /**
   3.206 +     * process one xml-file: read from KEStore, translate into .html, update
   3.207 +     * error_log
   3.208 +     * 
   3.209 +     * @param error_log
   3.210 +     *            required for usage from other classes
   3.211 +     * @param destination
   3.212 +     *            required for usage from other classes
   3.213 +     * @param path
   3.214 +     *            the end of, following destination
   3.215 +     */
   3.216 +    protected void loadContent(FileWriter error_log, String destination,
   3.217 +            String path) {
   3.218  
   3.219          if (!path.endsWith(".xml"))
   3.220              path += ".xml";
   3.221 -        // if(!path.startsWith("thy_isac_RootEq-rls"))
   3.222 -        // return;
   3.223          StringTokenizer tokens = new StringTokenizer(path, "/");
   3.224          String session = "";
   3.225  
   3.226 @@ -433,7 +447,7 @@
   3.227  
   3.228              parameter.add(command);
   3.229              if (!tokens.hasMoreElements()) {
   3.230 -                out = new FileWriter(destination_ + file_name + ".html");
   3.231 +                out = new FileWriter(destination + file_name + ".html");
   3.232                  out.write(header);
   3.233                  out.write("no details");
   3.234                  return;
   3.235 @@ -445,11 +459,11 @@
   3.236                  return;
   3.237              }
   3.238  
   3.239 -            // System.out.println("destination_:" + destination_);
   3.240 -            out = new FileWriter(destination_ + file_name + ".html");
   3.241 -            out_author = new FileWriter(destination_ + file_name
   3.242 +            // System.out.println("destination_: '" + destination + "'");
   3.243 +            out = new FileWriter(destination + file_name + ".html");
   3.244 +            out_author = new FileWriter(destination + file_name
   3.245                      + "_author.html");
   3.246 -            out_nomodel = new FileWriter(destination_ + file_name
   3.247 +            out_nomodel = new FileWriter(destination + file_name
   3.248                      + "_nomodel.html");
   3.249  
   3.250              // loading the content from the xml
     4.1 --- a/src/java/isac/util/genhtml/GenHTMLsingle.java	Sun Aug 24 20:19:56 2008 +0200
     4.2 +++ b/src/java/isac/util/genhtml/GenHTMLsingle.java	Mon Aug 25 14:05:21 2008 +0200
     4.3 @@ -17,14 +17,14 @@
     4.4  
     4.5  /**
     4.6   * check one xml-file specified in the properties and, if ok, generate the
     4.7 - * respective html-files using the KEStore.properties.
     4.8 + * respective html-files using the KEStore.properties. WN080825.
     4.9 + * 
    4.10 + * FIXME find a better way to reuse GenHTML#loadContent( FileWriter!!!...
    4.11   * 
    4.12   * !!!!! start KEStore before running GenHTML !!!!!
    4.13   */
    4.14  public class GenHTMLsingle {
    4.15  
    4.16 -    private static FileWriter error_log;
    4.17 -
    4.18      public static void main(String[] args) {
    4.19  
    4.20          // read arguments of main
    4.21 @@ -68,15 +68,29 @@
    4.22                  System.err.println("No XML-file: " + filename
    4.23                          + " - SYSTEM EXITING");
    4.24                  System.exit(-1);
    4.25 +            } else {
    4.26 +                // remove extension ".xml"
    4.27                  filename = filename.substring(0, filename.length() - 4);
    4.28              }
    4.29          }
    4.30  
    4.31          // destination for reporting HTML-errors in the xml-file
    4.32          GenHTML genhtml = new GenHTML();
    4.33 +        String destination = "";
    4.34 +        if ((GenHTMLsinglePaths.GENHTML_DESTINATON_PATH = properties
    4.35 +                .getProperty("GENHTML_DESTINATON_PATH")) == null) {
    4.36 +            System.err
    4.37 +                    .println("No value for GENHTML_DESTINATON_PATH found in property-file"
    4.38 +                            + " - SYSTEM EXITING");
    4.39 +            System.exit(-1);
    4.40 +        } else {
    4.41 +            destination = GenHTMLsinglePaths.GENHTML_DESTINATON_PATH;
    4.42 +        }
    4.43 +
    4.44 +        FileWriter error_log = null;
    4.45          try {
    4.46 -            error_log = new FileWriter(KEStorePaths.GENHTML_DESTINATON_PATH
    4.47 -                    + "GENHTML_error-" + filename.replaceAll(".xml", ".txt"));
    4.48 +            error_log = new FileWriter(destination + "GENHTML_error-"
    4.49 +                    + filename + ".txt");
    4.50          } catch (IOException e) {
    4.51              e.printStackTrace();
    4.52          }
    4.53 @@ -84,7 +98,7 @@
    4.54          // check the xml-file using all other properties from KEStore.properties
    4.55          String type = filename.substring(0, 3);// exp | met | pbl | thy
    4.56          System.out.println(type + " to generate:");
    4.57 -        genhtml.loadContent(type + "/" + filename);
    4.58 +        genhtml.loadContent(error_log, destination, type + "/" + filename);
    4.59  
    4.60          try {
    4.61              error_log.close();