upgrade.jsp

来自「Jive是基于JSP/JAVA技术构架的一个大型BBS论坛系统,这是Jive论坛」· JSP 代码 · 共 883 行 · 第 1/3 页

JSP
883
字号
<%/** *	$RCSfile: upgrade.jsp,v $ *	$Revision: 1.8 $ *	$Date: 2002/08/10 20:18:39 $ */%><%@ page import="java.io.*,                 java.sql.*,                 java.util.*,                 com.jivesoftware.forum.*,                 com.jivesoftware.forum.database.*,                 com.jivesoftware.forum.util.*" %><%! // Global vars, methods, etc    static final String HSQL_1 = "CREATE TABLE JIVEATTACHMENT "        + "(ATTACHMENTID INTEGER NOT NULL, "        + "MESSAGEID INTEGER NOT NULL, "        + "FILENAME VARCHAR NOT NULL, "        + "FILESIZE INTEGER NOT NULL, "        + "CONTENTTYPE VARCHAR NOT NULL, "        + "CREATIONDATE VARCHAR NOT NULL, "        + "MODIFIEDDATE VARCHAR NOT NULL)";    static final String HSQL_2 = "CREATE UNIQUE INDEX JIVEATTACHMENT_PK ON JIVEATTACHMENT(ATTACHMENTID)";    static final String HSQL_3 = "CREATE INDEX JIVEATTACHMENT_MESSAGEID_IDX ON JIVEATTACHMENT (MESSAGEID)";    static final String HSQL_4 = "INSERT INTO JIVEID VALUES(13,1)";    // New after 2.5:    static final String HSQL_5 = "INSERT INTO jiveID(idType, id) VALUES(14,2)";    static final String HSQL_6 = "CREATE TABLE jiveCategory ( "        + "categoryID        INTEGER NOT NULL, "        + "name              VARCHAR(255) NOT NULL, "        + "description       VARCHAR(4000) NULL, "        + "creationDate      VARCHAR(15) NOT NULL, "        + "modifiedDate      VARCHAR(15) NOT NULL, "        + "lft               INTEGER NOT NULL, "        + "rgt               INTEGER NOT NULL, "        + "CONSTRAINT jiveCategory_pk PRIMARY KEY (categoryID))";    static final String HSQL_7 = "CREATE INDEX jiveCategory_lft_idx ON jiveCategory (lft)";    static final String HSQL_8 = "CREATE INDEX jiveCategory_rgt_idx ON jiveCategory (rgt)";    static final String HSQL_9 = "CREATE TABLE jiveCategoryProp ( "        + "categoryID        INTEGER NOT NULL, "        + "name              VARCHAR(100) NOT NULL, "        + "propValue         VARCHAR(4000) NOT NULL, "        + "CONSTRAINT jiveCategoryProp_pk PRIMARY KEY (categoryID,name))";    static final String HSQL_10 = "CREATE TABLE jiveAttachmentProp ( "        + "attachmentID     INTEGER NOT NULL, "        + "name        VARCHAR(100) NOT NULL, "        + "propValue   VARCHAR(4000) NOT NULL, "        + "CONSTRAINT jiveAttachmentProp_pk PRIMARY KEY (attachmentID, name))";    static final String HSQL_11 = "INSERT INTO jiveCategory VALUES(1, \"root\", \"\", \"0\", \"0\", 1, 2)";    static final String HSQL_12 = "ALTER TABLE jiveForum ADD COLUMN categoryID BIGINT NOT NULL DEFAULT 1";    static final String HSQL_13 = "ALTER TABLE jiveForum ADD COLUMN categoryIndex INT NOT NULL";    static final String HSQL_14 = "ALTER TABLE jiveForum ADD INDEX jiveForum_cat_idx(categoryID)";    static final String HSQL_15 = "ALTER TABLE jiveUserPerm ADD COLUMN categoryID BIGINT NULL";    static final String HSQL_16 = "ALTER TABLE jiveUserPerm ADD INDEX jiveUserPerm_categoryID_idx (categoryID)";    static final String HSQL_17 = "ALTER TABLE jiveGroupPerm ADD COLUMN categoryID BIGINT NULL";    static final String HSQL_18 = "ALTER TABLE jiveGroupPerm ADD INDEX jiveGroupPerm_categoryID_idx (categoryID)";    static final String HSQL_19 = "ALTER TABLE jiveGroupPerm DROP PRIMARY KEY";    static final String[] HSQL_QUERIES = {HSQL_1, HSQL_2, HSQL_3, HSQL_4,        HSQL_5, HSQL_6, HSQL_7, HSQL_8, HSQL_9, HSQL_10, HSQL_11, HSQL_12,        HSQL_13, HSQL_14, HSQL_15, HSQL_16, HSQL_17, HSQL_18, HSQL_19 };    static final HashMap oldUserProps = new HashMap();    static {        oldUserProps.put("occupation","jiveOccupation");        oldUserProps.put("location","jiveLocation");        oldUserProps.put("homepage","jiveHomepage");        oldUserProps.put("jive.timeZoneID","jiveTimeZoneID");        oldUserProps.put("jive.threadRange","jiveThreadRange");        oldUserProps.put("jive.messageRange","jiveMessageRange");        oldUserProps.put("alwaysEmailNotify","jiveAutoAddEmailWatch");        oldUserProps.put("autoAddMessageWatch","jiveAutoWatchNewTopics");        oldUserProps.put("autoAddThreadWatch","jiveAutoWatchReplies");    }    static final HashMap skinProps = new HashMap();    static {        skinProps.put("skin.default.fontFace", "arial,sans-serif");        skinProps.put("skin.default.buttonFontFace", "verdana,arial,sans-serif");        skinProps.put("skin.default.headerFontFace", "verdana,arial,sans-serif");        skinProps.put("skin.default.fontSize", "-1");        skinProps.put("skin.default.buttonFontSize", "-2");        skinProps.put("skin.default.headerFontSize", "-2");        skinProps.put("skin.default.homeURL", "index.jsp");        skinProps.put("skin.default.bgColor", "#ffffff");        skinProps.put("skin.default.textColor", "#000000");        skinProps.put("skin.default.linkColor", "#003399");        skinProps.put("skin.default.vLinkColor", "#003399");        skinProps.put("skin.default.aLinkColor", "#99ccff");        skinProps.put("skin.default.tableBorderColor", "#cccccc");        skinProps.put("skin.default.tableHeaderBgColor", "#336699");        skinProps.put("skin.default.tableHeaderTextColor", "#ffffff");        skinProps.put("skin.default.tableRowColor1", "#eeeeee");        skinProps.put("skin.default.tableRowColor2", "#d9e4f9");        skinProps.put("skin.default.paginatorTextColor", "#333333");        skinProps.put("skin.default.paginatorTableBgColor", "#eeeeee");        skinProps.put("skin.default.sidebarHeaderBgColor", "#eeeeee");        skinProps.put("skin.default.sidebarHeaderTextColor", "#000000");        skinProps.put("skin.default.sidebarBgColor", "#ffffff");        skinProps.put("skin.default.prefsHeaderBgColor", "#eeeeee");        skinProps.put("skin.default.prefsHeaderTextColor", "#000000");        skinProps.put("skin.default.prefsBgColor", "#ffffff");        skinProps.put("skin.default.communityDescription", "Welcome to our online community. Please choose from one of the forums below or log-in to your user account to start using this service.");        skinProps.put("skin.default.headerLogo", "<img src=\"images/logo.gif\" width=\"242\" height=\"38\" alt=\"Community Forums\" border=\"0\">");        skinProps.put("skin.default.headerBorderColor", "#003366");        skinProps.put("skin.default.headerBgColor", "#336699");        skinProps.put("skin.default.threadMode", "flat"); // other value is "threaded"        skinProps.put("skin.default.debug", "false");        skinProps.put("skin.default.trackIP", "true");        // New after 2.5:        skinProps.put("skin.default.categoryTextColor", "#000000");        skinProps.put("skin.default.categoryCellBgColor", "#eeeeee");        skinProps.put("skin.default.categoryFontFace", "arial,sans-serif");        skinProps.put("newAccountCreationEnabled", "true");        skinProps.put("showLastPostLink", "true");        skinProps.put("useDefaultWelcomeText", "true");        skinProps.put("useDefaultHeaderImage", "true");    }%><%@ include file="global.jsp" %><%  // Check if the setup tool has been run    if (!"true".equals(JiveGlobals.getJiveProperty("setup"))) {        // redirect to the front page of the setup tool. That will redirect        // correctly to the setup tool        response.sendRedirect("index.jsp");        return;    }    // Get parameters    boolean doUpgrade = ParamUtils.getBooleanParameter(request,"doUpgrade");    boolean finished = ParamUtils.getBooleanParameter(request,"finished");%><%@ include file="header.jsp" %><p><b>Jive Forums 2.5 Upgrade Utility</b><hr size="0"><font size="-1">This utility will upgrade your Jive Forums version 2.0.x, 2.1.x, 2.2.x to 2.5.</font><p><%  // Check that we're running Jive Forums 2.5 at a minimum.    double version = 0.0;    try {        String ver = JiveGlobals.getJiveVersion();        ver = ver.substring(0, ver.lastIndexOf("."));        version = Double.parseDouble(ver);    }    catch (Exception ignored) {}    if (version < 2.5) {%>    <font size="-1">    <font color="#ff0000">Error:</font>    Jive Forums 2.5 is not installed. Please complete the 2.5 installation    and setup process before running this script.    </font>    <%@ include file="footer.jsp" %><%      out.flush();        return;    }        // Also, checkout if we're running basic:    boolean isBasic = JiveGlobals.getJiveEdition() == JiveGlobals.BASIC;%><%  // Figure out the current state of things.    // Global error vars    boolean errors = false;    boolean dbConnectionError = false;    boolean hsqlIsUsed = false;    boolean dbIsUpdated = false;    boolean oldPropsExist = false;    boolean gatewayFileUpdated = false;    boolean filterListUpdated = false;    boolean skinPropsUpdated = false;    boolean jiveHomeIsValid = false;    // New for 2.5    boolean updateCategories = false;    // Check to see if HSQL is being used.    if ("org.hsqldb.jdbcDriver".equals(JiveGlobals.getJiveProperty("database.defaultProvider.driver")))    {        // Check that the server URL correlates to the correct jiveHome dir. It        // should be jdbc:hsqldb:[jiveHome]/database/jive        String hsqlServerURL = JiveGlobals.getJiveHome() + "/database/jive";        hsqlServerURL.replace('/', File.separatorChar);        hsqlServerURL = "jdbc:hsqldb:"+ hsqlServerURL;        if (hsqlServerURL.equals(JiveGlobals.getJiveProperty("database.defaultProvider.serverURL"))) {            // Checks pass, we're using HSQL            hsqlIsUsed = true;        }    }    // Check the database to see if the jiveAttachment table and the jiveID    // attachment entry exist.    Connection con = null;    if (isBasic) {        dbIsUpdated = true;    } else {        try {            con = ConnectionManager.getConnection();            if (con == null) {                dbConnectionError = true;            }            else {            	try {                    // See if the jiveAttachment table is installed            		java.sql.Statement stmt = con.createStatement();            		// Pick an arbitrary table to see if it's there.            		stmt.executeQuery("SELECT count(*) FROM jiveAttachment");            		// Pick an arbitrary table to see if it's there.            		ResultSet rs = stmt.executeQuery("SELECT * FROM jiveID WHERE idType=13");                    if (rs.next()) {                        // New since Jive 2.5                        ResultSet rs2 = stmt.executeQuery("SELECT * FROM jiveID WHERE idType=14");                        if (rs2.next()) {                            dbIsUpdated = true;                        }                    }                    rs.close();            		stmt.close();            	}                catch (Exception e2) {}            }        }        catch (Exception e) {}        finally {            try { con.close(); } catch (Exception e) {}        }    }    // Check to see if old property names exist    con = null;    try {        con = ConnectionManager.getConnection();        java.sql.Statement stmt = con.createStatement();        for (Iterator iter=oldUserProps.keySet().iterator(); iter.hasNext();) {            String oldProp = (String)iter.next();            try {                ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM " +                    "jiveUserProp WHERE name='" + oldProp + "'");                rs.next();                int count = rs.getInt(1);                if (count > 0) {                    oldPropsExist = true;                    break;                }            }            catch (Exception e2) {}        }        stmt.close();    }    catch (Exception e) {}    finally {        try { con.close(); } catch (Exception e) {}    }    if (finished) {        oldPropsExist = false;    }    // Check to see if we need to updated the jive_gateways.xml file:    File gatewayFile = new File(JiveGlobals.getJiveHome(), "jive_gateways.xml");    File gatewayFileBak = new File(JiveGlobals.getJiveHome(), "jive_gateways.xml.bak");    if (isBasic) {        gatewayFileUpdated = true;    } else {        if (!gatewayFile.exists() || gatewayFileBak.exists()) {            gatewayFileUpdated = true;        }    }    // Check for the installed filter    ForumMessageFilter[] filters = forumFactory.getAvailableFilters();    for (int i=0; i<filters.length; i++) {        if (filters[i].getClass().getName().equals("com.jivesoftware.forum.filter.QuoteFilter")) {            filterListUpdated = true;            break;        }    }    for (int i=0; i<filters.length; i++) {        if (filters[i].getClass().getName().equals("com.jivesoftware.forum.filter.CodeHighlighter")) {            filterListUpdated = false;            break;        }    }

⌨️ 快捷键说明

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