Package KFM.preprocessor

Source Code of KFM.preprocessor.Preprocessor

/*
*  This software and supporting documentation were developed by
*
*    Siemens Corporate Technology
*    Competence Center Knowledge Management and Business Transformation
*    D-81730 Munich, Germany
*
*    Authors (representing a really great team ;-) )
*            Stefan B. Augustin, Thorbj�rn Hansen, Manfred Langen
*
*  This software is Open Source under GNU General Public License (GPL).
*  Read the text of this license in LICENSE.TXT
*  or look at www.opensource.org/licenses/
*
*  Once more we emphasize, that:
*  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  WITHOUT ANY WARRANTY
*  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE OR
*  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR
*  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
*  PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
*
*/


//  Preprocessor

// ************ package ******************************************************
package KFM.preprocessor;
// ************ imports ******************************************************

import java.io.*;
import java.util.*;
import KFM.DirNavigator.*;
import KFM.File.*;

/** The preprocessor traverses recursive a specific directory and has two jobs:
* 1) Replace all html and js comments by jsp comments and save the file as '.jsp'.
*    This is only done when called without parameter "directive=onlyJsp".
* 2) Execute all '.jsp' files in a jsp engine and save the returned
*    content without the '.jsp' ending (details see MakePortalFileWorker).
* The preprocessor is only called in batch mode. The main() method is the
* single entry point.
*
* @see KFM.preprocessor.MakePortalFileWorker
* @see KFM.DirNavigator.FileWorker
*/


public class Preprocessor {
    // ************ constants for command line args *************************
    //Configuration parameter name that switches comment replacing on and off
    private static final String cDIRECTIVE="directive";

    //Configuration parameter value that switches comment replacing on and off
    private static final String cDIRECTIVE_JSP="onlyJsp";


    /** Print usage information and exit. Called when used wrong syntax.
    */
    private static void printUsageAndExit()
    {
        System.out.println("You have to pass a start directory, a config path, a host and port for the servlet engine!");
        System.out.println("Usage: Preprocessor fileDir=<startDir> -Parampre_Dir=<configPath> host=<hostname> port=<port> [delete=<true|false>]");
        System.out.println("<startDir> is the directory you want to process recursively.");
        System.out.println("<configPath> is a path relative to /home/sipdev/KFM/config for your file ReplaceHostBean.properties,");
        System.out.println("for example <configPath> is 'dev/boje/ReplaceHostBean.properties'");
        System.out.println("<hostname> is the host where the jsp engine runs on.");
        System.out.println("<port> is the port the jsp engine listens to.");
        System.out.println("Please try it again :)");

        // Terminate program.
        System.exit(-1);
    }


    /** The central entry point for this class, used from command line.
    * For documentation of arguments see method printUsageAndExit().
    */
    public static void main (
        String[] args)
    {
        Properties tProps = new Properties();

        try{
            //Read the arguments passed in command line and
            // 1) extract HTTP params as a concatenated String
            // 2) fill tProps with the rest
            //Prints error message if mandatory arguments are missing.
            String tHttpParams = MakePortalFileWorker.processArguments(tProps, args);

            //replace comments ?
            if (tProps.getProperty(cDIRECTIVE) == null){
                ReplaceCommentFileWorker tReplFileWorker = new ReplaceCommentFileWorker();
                DirNavigator tNavigator =
                    new DirNavigator(tProps.getProperty(MakePortalFileWorker.cFilepath),
                                     tReplFileWorker);
                tNavigator.traverse();
            }

             String tTomcat = tProps.getProperty("tomcat");
            // check for tomcat
            if(tTomcat.equals("false")) MakePortalFileWorker.TOMCAT=false;

           //execute jsp
            MakePortalFileWorker tMkPortalFileWorker = new MakePortalFileWorker(tHttpParams, tProps);

            // Check if to leave comments in the file

            DirNavigator tNavigator =
                new DirNavigator(tProps.getProperty(MakePortalFileWorker.cFilepath),
                                 tMkPortalFileWorker);
            Date startDate = new Date();
            tNavigator.traverse();
            tMkPortalFileWorker.done();
            System.out.println(startDate);
            System.out.println(new Date());
            System.out.println("\nNote: " + tMkPortalFileWorker.getErrors() + " errors occured on the server side!");
        }
        catch (Exception e){
            e.printStackTrace();
        }

    }

}
TOP

Related Classes of KFM.preprocessor.Preprocessor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.