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

📄 jahiaconfigurationwizard.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            } else if ( request.getParameter("go").equals("change") ){                displayTemplates( request, response );            }        }        // force objects to garbage collector...        msg   = null;    }    // end processTemplates( HttpServletRequest, HttpServletResponse )   /**     * Get an enumeration containing all the templates archives files paths.     * @author  Alexandre Kraft     *     * @return  Enumeration containing all scripts in File objects.     */    private Enumeration listTemplatesFiles()    throws IOException    {        Vector vec  = new Vector();        String path = ((String)values.get("server_jahiafiles_default")).substring(8, ((String)values.get("server_jahiafiles_default")).length()) + File.separator + "var" + File.separator + "shared_templates";        File   file = new File( context.getRealPath(path) );        File[] list = file.listFiles();        for(int i=0; i<list.length; i++) {            if(!list[i].isDirectory() && list[i].getName().endsWith(".jar")) {                String name = list[i].getName().substring( 0, list[i].getName().lastIndexOf(".") );                vec.add( name );            }        }        return vec.elements();    }    // listTemplatesFiles()    /**     * This method display the values confirmation (before save options) page.     * @author  Alexandre Kraft     *     * @param       request             servlet request.     * @param       response            servlet response.     * @exception   IOException         an I/O exception occured during the process.     * @exception   ServletException    a servlet exception occured during the process.     */    public void displayValues( HttpServletRequest   request,                               HttpServletResponse  response )    throws IOException, ServletException    {        // set configuration step title...        request.setAttribute( "title", "Confirm your values" );        // forward to the jsp...        doRedirect( request, response, JSP + "values" );    }    // end displayValues( HttpServletRequest, HttpServletResponse )    /**     * Save the values from the HashMap in the database and properties file,     * since the user has confirmed the values displayed in the page. Launch     * some methods to compose the final jahia properties file, insert     * database tables, data and remove old templates xml files if necessary.     * @author  Alexandre Kraft     *     * @param   request       Servlet request.     * @param   response      Servlet response.     */    public void processValues( HttpServletRequest   request,                               HttpServletResponse  response )    throws IOException, ServletException    {        // by default, the user makes at least one error :o)        boolean error   = true;        String  msg     = null;        // try to execute the last operations... any error will stop the process        try        {            // overwrite the database if the user has not specified the opposite...            if( !old_database.equals("true") )            {                createDBTables();                insertDBCustomContent();                insertDBDefaultContent();                // it also include templates...                copyDefaultTemplates( "myjahiasite" );                //copySharedTemplates( "myjahiasite" );                // and also the default site property...                properties.setProperty( "defautSite", "myjahiasite" );                // and also the xml templates files...                folderXMLtemplates();            }            // copy the shared components            copySharedComponents("myjahiasite");            // move jahia files on their final directories...  if needed.            moveJahiaFiles();            // close the connection with the database connection admin manager...            db.databaseClose();            // set new properties...            setPropertiesObject();            // store jahia.properties file...            properties.storeProperties( Jahia.getJahiaPropertiesFileName() );            // okay, everthing is okay... set error to false            error = false;        } catch (Exception e) {            JahiaConsole.printe("JahiaConfigurationWizard.processValues", e);            msg   = e.getMessage();        }        // call the appropriate method...        if( error ) {                                       // process generates errors...            request.setAttribute( "errormsg", msg );            displayError( request, response );        } else {            displayFinalStep( request, response );          // everything is okay, continue...        }        // force objects to garbage collector...        msg   = null;    }    // end processValues( HttpServletRequest, HttpServletResponse )    /**     * This method display some errors during the save process.     * @author  Alexandre Kraft     *     * @param       request             servlet request.     * @param       response            servlet response.     * @exception   IOException         an I/O exception occured during the process.     * @exception   ServletException    a servlet exception occured during the process.     */    public void displayError( HttpServletRequest   request,                              HttpServletResponse  response )    throws IOException, ServletException    {        // set configuration step title...        request.setAttribute( "title", "Error" );        // forward to the jsp...        doRedirect( request, response, JSP + "error_save" );    }    // end displayError( HttpServletRequest, HttpServletResponse )    /**     * This method display the final step (congratulations).     * @author  Alexandre Kraft     *     * @param       request             servlet request.     * @param       response            servlet response.     * @exception   IOException         an I/O exception occured during the process.     * @exception   ServletException    a servlet exception occured during the process.     */    public void displayFinalStep( HttpServletRequest   request,                                  HttpServletResponse  response )    throws IOException, ServletException    {        // set configuration step title...        request.setAttribute( "title", "Congratulations!" );        // forward to the jsp...        doRedirect( request, response, JSP + "congratulations" );    }    // end displayFinalStep( HttpServletRequest, HttpServletResponse )    /**     * This method redirect to jahia and bypass the login.     * @author  Alexandre Kraft     *     * @param       request             servlet request.     * @param       response            servlet response.     * @exception   IOException         an I/O exception occured during the process.     * @exception   ServletException    a servlet exception occured during the process.     */    public void redirectToJahia( HttpServletRequest   request,                                 HttpServletResponse  response )    throws IOException, ServletException    {        // add attributes to the request to *bypass* the login engine in the administration...        request.setAttribute( CLASS_NAME + ".directAdministration",  "true" );        request.setAttribute( CLASS_NAME + ".rootName",  (String)values.get("root_user") );        request.setAttribute( CLASS_NAME + ".rootPass",  (String)values.get("root_pwd") );        // forward to jahia !!        doRedirect( request, response, contentServletPath );    }    // end redirectToJahia( HttpServletRequest, HttpServletResponse )    /**     * Check *slashs* validity of the inputs values from the server     * settings page (servlet container home, host url, path jahia files).     * @author  Alexandre Kraft     */    private void checkServerSlashs()    {        if( !((String)values.get("server_home")).endsWith(File.separator) ) {          // server home must ends with file separator            values.put( "server_home",                        ((String)values.get("server_home"))+File.separator );        }        if( ((String)values.get("server_url")).endsWith("/") ) {                       // host url must ends without "/"            values.put( "server_url",                        ((String)values.get("server_url")).substring(0,                            ((String)values.get("server_url")).length()-1 ) );        }        if( ((String)values.get("server_jahiafiles")).endsWith(File.separator) ) {     // jahia files must ends without file separator            values.put( "server_jahiafiles",                        ((String)values.get("server_jahiafiles")).substring(0,                            ((String)values.get("server_jahiafiles")).length()-1 ) );        }    }    // end checkServerSlashs()    /**     * Check the Servlet Container home disk path indicates by the user on     * the server settings page, throws custom exceptions.     * @author  Alexandre Kraft     *     * @exception   Exception       an exception occured during the process.     *     * @todo FIXME (shuber) this is TERRIBLY container specific and only works on Tomcat.     * We deactivate this call for the moment because in Tomcat's server.xml     * we may put deployment directories elsewhere...     */    private void tryServerHome()    throws Exception    {        /*        // set catalina.jar path...        StringBuffer catalina = new StringBuffer( ((String)values.get("server_home")) );        catalina.append( File.separator );        catalina.append( "server" );        catalina.append( File.separator );        catalina.append( "lib" );        catalina.append( File.separator );        catalina.append( "catalina.jar" );        File lib = new File( catalina.toString() );        if( !lib.exists() ) {            throw new Exception( "Please verify your servlet container home disk path." );        }        */    }    // end tryServerHome()    /**     * Try to establish a connection with the host url indicates by the user     * on the server settings page, and check some error(s) (like HTTP-403, etc).     * @author  Alexandre Kraft     *     * @exception   Exception       an exception occured during the process.     */    private void tryHostURL()    throws Exception    {        URL          url      = null;        InputStream  istream  = null;        try        {            url      = new URL( ((String)values.get("server_url")) );            istream  = url.openStream();            istream.close();        } catch (Exception e) {            JahiaConsole.printe( "Cannot connect to your server URL at " + url , e);            throw new Exception( "Cannot connect to your server URL at " + url );        }

⌨️ 快捷键说明

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