⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jahiaconfigurationwizard.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
// $Id: JahiaConfigurationWizard.java,v 1.22 2002/12/11 17:10:04 shuber Exp $////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////              . . . i n   j a h i a   w e   t r u s t . . .//////  JahiaConfigurationWizard////  25.01.2001  AK  added in jahia.//  26.01.2001  AK  replace sessions by context attributes, fixe some bugs,//                  create a real wizard with previous steps and next steps :o)//  29.01.2001  AK  fix database check resulting bug, change method to reset//                  jahia servlet re-init settings, and change context attributes//                  by adding package in attribute names.//  10.01.2001  AK  include design.//  26.02.2001  AK  prepare upgrade manager workplace.//  21.03.2001  AK  change backup method. flatfile and jahiafiles.//  22.03.2001  AK  detect data on database when installing.//  28.03.2001  AK  completely change the properties system.//  30.03.2001  AK  move database methods to org.jahia.admin.DatabaseConnection//                  and move database scripts methods to jahia.admin.DatabaseScripts//  16.05.2001  NK  create a default site at install.//  13.08.2001  AK  fix jahia files path checking bug.//  14.08.2001  AK  fix all jahia files dependencies.//  15.08.2001  AK  transform "database treatment" (appear if the database is//                  not empty when the installation is performed) to a internal//                  developer only feature.////  23.08.2001  AK  version 2.0//                  . quality improvement in this servlet and jsp files//                  . better exception management//                  . code improvement for quality and readability//                  . transfer getServerInformations() method as a jahia util//                  . complete and fix javadoc//                  . rename *installation* in *configuration wizard*//                  . put some constants in web.xml file for better changes//package org.jahia.bin;import java.io.*;                                           // IOException, File, FileWriterimport java.net.*;                                          // URLimport java.util.*;                                         // Properties, Enumeration, Vectorimport javax.servlet.*;					                    // ServletException, ServletContextimport javax.servlet.http.*;			                    // HttpServletRequest, HttpServletResponseimport org.jahia.bin.*;                                 // Jahiaimport org.jahia.admin.database.*;                      // Database tester, Scripts managerimport org.jahia.utils.*;                               // JahiaConsole, JahiaTools, ActionHandlerimport org.jahia.utils.keygenerator.JahiaKeyGen;        // JahiaKeyGenimport org.jahia.utils.properties.PropertiesManager;    // PropertiesManagerimport org.jahia.utils.zip.JahiaArchiveFileHandler;     // JahiaArchiveFileHandlerimport org.jahia.services.usermanager.*;                // Password encryptionimport org.jahia.exceptions.JahiaException;             // JahiaExceptionimport org.jahia.settings.*;                            // JahiaPrivateSettings/** * This servlet handles the main configuration task. * At the first launch of Jahia, the configuration wizard starts and provide * to you the capability to configure Jahia *as you want*. During the * configuration, you can set the administrator profile, change Jahia * default settings, activate the mail notification, and specify which * database you want to use with your Jahia portal. JahiaConfigurationWizard * runs only one time, at the first launch of Jahia. If you want to change * settings later, please refer to the JahiaAdministration. * * Copyright:    Copyright (c) 2002 * Company:      Jahia Ltd * * @author Alexandre Kraft * @author Khue N'Guyen * @version 2.0 */public class JahiaConfigurationWizard extends HttpServlet{    private   static        ServletContext      context                 = null;    private   static        ServletConfig       config                  = null;    private   static        PropertiesManager   properties              = null;    private   static        ActionHandler       actionHandler           = null;    private                 DatabaseConnection  db                      = new DatabaseConnection();    private                 DatabaseScripts     scripts                 = new DatabaseScripts();    private   static        HashMap             serverInfos             = null;    private   static        HashMap             values                  = new HashMap();    private   static        String              methods                 = null;    private   static        String              dbScriptsPath           = null;    private   static        String              old_database            = null;    private   static        String              servletPath             = null;    private   static        String              contentServletPath      = null;    private   static final  String              JSP                     = "/jsp/jahia/configuration_wizard/includer.jsp?jsp=";    private   static final  String              HTTP_FILES              = "/jsp/jahia/engines";    protected static final  String              CLASS_NAME              = "org.jahia.bin.JahiaConfigurationWizard";    private   static final  String              INIT_PARAM_CONTENT_SERVLET_PATH = "content_servlet_path";    /**     * Default init method, inherited from HttpServlet. This method get two     * servlet container environment properties: its *home* filesystem path and     * its type (tomcat, orion, etc), and get the local context.     * @author  Alexandre Kraft     *     * @param       config              servlet configuration (inherited).     * @exception   ServletException    a servlet exception occured during the process.     */    public void init( ServletConfig config )    throws ServletException    {        // get local context and config...        context      = config.getServletContext();        this.config  = config;        // get server informations...        serverInfos  = ServletContainerUtils.getServerInformations( config );        // get xml init parameters...        methods       = context.getRealPath( config.getInitParameter("methods") );        dbScriptsPath = context.getRealPath( config.getInitParameter("dbScriptsPath") );        old_database  = config.getInitParameter("old_database");        contentServletPath = config.getInitParameter(INIT_PARAM_CONTENT_SERVLET_PATH);        if (contentServletPath == null) {            JahiaConsole.println("JahiaConfigurationWizard.init",                                 "Missing " + INIT_PARAM_CONTENT_SERVLET_PATH + ", defaulting to /content/...");            contentServletPath = "/content/";        }        // get actionhandler...        actionHandler = new ActionHandler( methods, CLASS_NAME );        // fill in default values in *values* hashmap...        fillDefaultValues();    }    // end init( ServletConfig )    /**     * Default service method, inherited from HttpServlet. Jahia servlet must be     * inited, because JahiaConfigurationWizard needs to access to some data     * (like paths, constants, etc).     * @author  Alexandre Kraft     *     * @param       request             servlet request (inherited).     * @param       response            servlet response (inherited).     * @exception   IOException         an I/O exception occured during the process.     * @exception   ServletException    a servlet exception occured during the process.     */    public void service( HttpServletRequest   request,                         HttpServletResponse  response )    throws IOException, ServletException    {        JahiaConsole.println("JahiaConfigurationWizard.service", "Starting...");        boolean connect = false;        if (this.servletPath == null) {            servletPath = request.getServletPath();        }        // get *go* parameter...        if( request.getParameter("go") != null ) {            if( request.getParameter("go").equals("connect") ) {                connect = true;            }        }        if( Jahia.jahiaBasicFileName == null ) {                                 // the user call JahiaConfigurationWizard in standalone...            doRedirect( request, response, JSP + "error_standalone" );        } else {            if( JahiaTools.checkFileExists(Jahia.getJahiaPropertiesFileName()) && !connect ) {                doRedirect( request, response, JSP + "error_configured" );       // jahia is already installed and configured...            } else {                if( Jahia.initException != null ) {                              // jahia has an init exception, redirect on jahia to display it...                    doRedirect( request, response, contentServletPath );                } else {                    dispatcher( request, response );                             // ok good use case, continue process...                }            }        }    }    // end service( HttpServletRequest, HttpServletResponse )    public static String getServletPath() { return servletPath; }    /**     * Static method to generate URLs for the administration. This should be     * used by all JSPs and java code that is called by the administration.     * @param request the current request object, used to generate the context     * path part of the URL     *     * @param response the current response object, used to make a call to     * encodeURL to generate session information in the case that cookies cannot     * be used     * @param doAction a String representing the action we are linking to. This     * is then encoded as a ?do=doAction string     * @param extraQueryParams a string including any other parameters that will     * be directly appended after the doAction string. This is done because this     * way we offer the possibility to do an encodeURL over the whole string.     * Note that this string may be null.     *     * @return a String containing an URL with jsessionid generated and in the     * form : /contextPath/servletPath/?do=doActionextraQueryParams     */    public static String composeActionURL ( HttpServletRequest request,                                            HttpServletResponse response,                                            String doAction,                                            String extraQueryParams ) {        String internalDoAction = "";        String internalQueryParams = "";        if (doAction != null) {            internalDoAction = "/?call=" + doAction;        }        if (extraQueryParams != null) {            internalQueryParams = extraQueryParams;        }        return response.encodeURL ( request.getContextPath() +                                    getServletPath() +                                    internalDoAction +                                    internalQueryParams );    }    /**     * Forward the servlet request and servlet response objects, using the request     * dispatcher (from the ServletContext). Note: please be careful, use only     * context relative path.     * @author  Alexandre Kraft     *     * @param       request             servlet request.     * @param       response            servlet response.     * @param       target              target, context-relative path.     * @exception   IOException         an I/O exception occured during the process.     * @exception   ServletException    a servlet exception occured during the process.     */    private void doRedirect( HttpServletRequest   request,                             HttpServletResponse  response,                             String               target )    throws IOException, ServletException    {        JahiaConsole.println("JahiaConfigurationWizard.doRedirect", "Dispatching to target=[" + target +"]");        try        {            // check null jsp bottom message, and fill in if necessary...            if( request.getAttribute("msg") == null ) {                request.setAttribute("msg", Jahia.COPYRIGHT);            }            // check null jahia display message, and fill in if necessary...            if( request.getAttribute("focus") == null ) {                request.setAttribute("focus", "-none-");            }            // check null configuration step title, and fill in if necessary...            if( request.getAttribute("title") == null ) {                request.setAttribute("title", "Jahia Configuration Wizard");            }            // set input values on request...            request.setAttribute( "values", values );            // add http files path in request...            request.setAttribute( "url", request.getContextPath() + HTTP_FILES );            // get browser entity...            Integer navigator = new Integer(0);            if (request.getHeader("user-agent") != null) {                navigator = (request.getHeader("user-agent").indexOf("IE")) != -1 ? new Integer(0) : new Integer(1);            } else {                JahiaConsole.println("JahiaConfigurationWizard.doRedirect", "Couldn't reader user-agent header ! Why ?");            }            request.setAttribute("navigator", navigator);            // redirect!            context.getRequestDispatcher( target ).forward( request, response );        } catch (IOException ie) {            JahiaConsole.printe("JahiaConfigurationWizard.doRedirect", ie);        } catch (ServletException se) {            JahiaConsole.printe("JahiaConfigurationWizard.doRedirect", se);            JahiaConsole.printe("JahiaConfigurationWizard.doRedirect", se.getRootCause());        }    }    // end doRedirect( HttpServletRequest, HttpServletResponse, String )    /**     * This method is used like a dispatcher for user HTTP requests, like

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -