upgrade.jsp

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

JSP
883
字号
    // Check if the skin properties need to be updated    boolean allPropsExist = true;    for (Iterator iter=skinProps.keySet().iterator(); iter.hasNext();) {        String skinProp = (String)iter.next();        if (JiveGlobals.getJiveProperty(skinProp) == null) {            allPropsExist = false;        }    }    skinPropsUpdated = allPropsExist;    // Check to see that the correct jiveHome directories exist    File jiveHome = new File(JiveGlobals.getJiveHome());    File attachDir = new File(jiveHome, "attachments");    File imagesDir = new File(attachDir, "images");    File spellDir = new File(jiveHome, "spelling");    File statsDir = new File(jiveHome, "stats");    File resourcesDir = new File(statsDir, "resources");    boolean jiveHomeDirsExist = false;    if (isBasic) {        jiveHomeDirsExist = jiveHome.exists();    }    else {        jiveHomeDirsExist = jiveHome.exists() && attachDir.exists()            && imagesDir.exists() && spellDir.exists()            && statsDir.exists() && resourcesDir.exists();    }    // Check to see that jiveHome directories are valid    boolean jiveHomeDirsValid = false;    if (isBasic) {        jiveHomeDirsValid = jiveHomeDirsExist            && jiveHome.canRead() && jiveHome.canWrite();    }    else {        jiveHomeDirsValid = jiveHomeDirsExist            && jiveHome.canRead() && jiveHome.canWrite()            && attachDir.canRead() && attachDir.canWrite()            && imagesDir.canRead()            && spellDir.canRead() && spellDir.canWrite()            && statsDir.canRead() && statsDir.canWrite()            && resourcesDir.canRead();    }        // New since 2.5:    // Check if categories need to be updated. 1) check for invalid dates    // on the root cat && check for cat indexes out of whack    ForumCategory rootCat = forumFactory.getRootForumCategory();    if (rootCat.getCreationDate().getTime() == 0L            || rootCat.getModifiedDate().getTime() == 0L) {        updateCategories = true;    }    // Determine if there were errors    errors = !jiveHomeDirsExist || (!hsqlIsUsed && !dbIsUpdated);    // Create the upgrade object    Upgrade upgrade = Upgrade.getInstance(forumFactory);%><%  if (!doUpgrade) { %>    <font size="-1">    Before continuing, be sure to backup your database.    <%  if (hsqlIsUsed) { %>        To backup the embedded database, copy all the files in        <font color="#006600"><b><%= JiveGlobals.getJiveHome() + File.separator + "database" %></b></font>        to another location.    <%  } else { %>        Please consult the documentation that comes with your database for more        details.    <%  } %>    </font><p><%  } %><%  // Show an error if the database update script has not been run.    if (errors) { %>    <%  if (!dbIsUpdated && !hsqlIsUsed) { %>    <img src="setup/images/x.gif" width="13" height="13" alt="x" border="0">    <font size="-1">    Your database needs to be updated before this upgrade tool can run. Please run    the database upgrade script located in the    <font color="#006600"><b>database/upgrade</b></font> directory of this distribution.    <p>    </font>    <%  }        if (!jiveHomeDirsExist) {    %>    <img src="setup/images/x.gif" width="13" height="13" alt="x" border="0">    <font size="-1">    The <font color="#006600"><b><%= JiveGlobals.getJiveHome() %></b></font>    directory and its subdirectories are not setup correctly. Please verify    you have copied all the appropriate files from the distribution to the    jiveHome directory.    <p>    </font>    <%  } %><%  }    // no errors, so continue    else {%>    <%  if (!doUpgrade) {            int upgradeCount = 0;    %>    <font size="-1">    <b>Upgrade Summary</b> - The upgrade script will do the following things:    </font>    <ol>        <form action="upgrade.jsp">        <input type="hidden" name="doUpgrade" value="true">        <font size="-1">        <%  if (oldPropsExist) {                upgradeCount++;                UserManager userManager = forumFactory.getUserManager();                upgrade.setUpdateUserProp(true);        %>        <li><input type="checkbox" name="upgradeOldProps" checked id="uop">        <label for="uop">Update old extended user properties</label>. This will        check for old property names of all <%= userManager.getUserCount() %>        users.        <p>        <%  } %>        <%  if (hsqlIsUsed && !dbIsUpdated) {                upgradeCount++;                upgrade.setUpdateHSQL(true);        %>        <li>HSQL (the Jive Forums embedded database) is being used and will be        upgraded.        <p>        <%  } %>        <%  if (!gatewayFileUpdated) {                upgradeCount++;                upgrade.setUpdateGatewayFile(true);        %>        <li>The jive_gateways.xml file will be reset.        <br><input type="checkbox" name="backupGatewayFile" checked>            Backup my old jive_gateways.xml file (saved as jive_gateways.xml.bak).        <p>        <%  } %>        <%  if (!skinPropsUpdated) {                upgradeCount++;                upgrade.setUpdateSkinProp(true);        %>        <li>The default skin settings will be updated (old values will be            perserved).        <p>        <%  } %>        <%  if (!filterListUpdated) {                upgradeCount++;                upgrade.setUpdateFilter(true);        %>        <li>New message filters will be installed in the filter list.        <p>        <%  } %>        <%  if (!jiveHomeDirsValid) {                upgradeCount++;                upgrade.setUpdateJiveHome(true);        %>        <li>Check for a valid <font color="#006600"><b>jiveHome</b></font>        directory and permission settings.        <p>        <%  } %>        <%  if (updateCategories) {                upgradeCount++;                upgrade.setUpdateCategories(true);        %>        <li>Update forum indexes in the root category and update the            timestamps of the root category.        <p>        <%  } %>        <%  if (upgradeCount == 0) { %>        <i>Your Jive Forums installation is up to date.</i>        <%  } %>    </ol>    <%  if (upgradeCount == 0) { %>        </form>        <form action="index.jsp">        <center>        <input type="submit" value="Back to Admin Tool">        </center>        </form>    <%  } else { %>    Please note, running this upgrade process might take a few minutes.    Please be patient. <p>    <center>    <input type="submit" value="Start Upgrade">    </center>    </font>    </form>    <%  } %>    <%  } // end if !doUpgrade        else {            if (doUpgrade && !upgrade.isRunning()) {                // Turn off some features of the upgrade if the user disabled them:                boolean upgradeOldProps = ParamUtils.getBooleanParameter(request,"upgradeOldProps");                upgrade.setUpdateUserProp(upgradeOldProps);                upgrade.setUserPropUpdated(true);                boolean backupGatewayFile = ParamUtils.getBooleanParameter(request,"backupGatewayFile");                upgrade.setBackupGatewayFile(backupGatewayFile);                upgrade.doUpgrade();            }            if (upgrade.isRunning()) {%>            <font size="-1">            <center>            Jive Forums upgrade script is currently running. Please be            patient...            </center>            </font>            <script language="JavaScript" type="text/javascript">            <!--            function reloadPage() {                location.href='upgrade.jsp?doUpgrade=true';            }            setTimeout(reloadPage,2000);            //-->            </script>            <meta http-equiv="refresh" content="3; URL=upgrade.jsp?doUpgrade=true">    <%      } else {                response.sendRedirect("upgrade.jsp?finished=true");            }        }    }%><%! // Singleton class for running all upgrade code in a thread    private static class Upgrade {        // booleans to indicate status of what is done        private boolean updateHSQL = false;        private boolean isHSQLUpdated = false;        private boolean updateUserProp = false;        private boolean isUserPropUpdated = false;        private boolean updateSkinProp = false;        private boolean isSkinPropUpdated = false;        private boolean updateJiveHome = false;        private boolean isJiveHomeUpdated = false;        private boolean updateGatewayFile = false;        private boolean isGatewayFileUpdated = false;        private boolean backupGatewayFile = false;        private boolean updateFilter = false;        private boolean isFilterUpdated = false;        private boolean updateCategories = false;        private boolean isCategoriesUpdated = false; // bad grammar :)        // Indicates if the upgrade is currently running        boolean isRunning = false;        public boolean isRunning() {            return isRunning;        }        public void setUpdateHSQL(boolean updateHSQL) {            this.updateHSQL = updateHSQL;        }        public boolean isHSQLUpdated() {            return isHSQLUpdated;        }        public void setUpdateUserProp(boolean updateUserProp) {            this.updateUserProp = updateUserProp;        }        public boolean isUserPropUpdated() {            return isUserPropUpdated;        }        public void setUserPropUpdated(boolean isUserPropUpdated) {            this.isUserPropUpdated = isUserPropUpdated;        }        public void setUpdateSkinProp(boolean updateSkinProp) {            this.updateSkinProp = updateSkinProp;        }        public boolean isSkinPropUpdated() {

⌨️ 快捷键说明

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