setup.jsp 7.41 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<%--
  -	$Revision: 2701 $
  -	$Date: 2005-08-19 16:48:22 -0700 (Fri, 19 Aug 2005) $
  -
  - Copyright (C) 2004-2005 Jive Software. All rights reserved.
  -
  - This software is published under the terms of the GNU Public License (GPL),
  - a copy of which is included in this distribution.
--%>

<%@ page import="org.jivesoftware.util.LocaleUtils"%>
<%@ page import="org.jivesoftware.util.ClassUtils"%>
<%@ page import="java.beans.PropertyDescriptor"%>
<%@ page import="java.io.File"%>
<%@ page import="org.jivesoftware.database.DbConnectionManager"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.sql.Statement"%>
<%@ page import="java.sql.SQLException"%>
20
<%@ page import="org.jivesoftware.wildfire.XMPPServer"%>
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page" %>

<decorator:usePage id="decoratedPage" />
<%
    // Check to see if the sidebar should be shown; default to true unless the page specifies
    // that it shouldn't be.
    String sidebar = decoratedPage.getProperty("meta.showSidebar");
    if (sidebar == null) {
        sidebar = "true";
    }
    boolean showSidebar = Boolean.parseBoolean(sidebar);
%>

<%!
    final PropertyDescriptor getPropertyDescriptor(PropertyDescriptor[] pd, String name) {
        for (int i=0; i<pd.length; i++) {
            if (name.equals(pd[i].getName())) {
                return pd[i];
            }
        }
        return null;
    }

    boolean testConnection(Map<String,String> errors) {
        boolean success = true;
        Connection con = null;
        try {
            con = DbConnectionManager.getConnection();
            if (con == null) {
                success = false;
                errors.put("general","A connection to the database could not be "
                    + "made. View the error message by opening the "
                    + "\"" + File.separator + "logs" + File.separator + "error.log\" log "
                    + "file, then go back to fix the problem.");
            }
            else {
            	// See if the Jive db schema is installed.
            	try {
            		Statement stmt = con.createStatement();
            		// Pick an arbitrary table to see if it's there.
            		stmt.executeQuery("SELECT * FROM jiveID");
            		stmt.close();
            	}
            	catch (SQLException sqle) {
                    success = false;
                    sqle.printStackTrace();
72
                    errors.put("general","The Wildfire database schema does not "
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
                        + "appear to be installed. Follow the installation guide to "
                        + "fix this error.");
            	}
            }
        }
        catch (Exception ignored) {}
        finally {
            try {
        	    con.close();
            } catch (Exception ignored) {}
        }
        return success;
    }
%>

<html>
<head>
	<title><fmt:message key="title" /> <fmt:message key="setup.title" />: <decorator:title /></title>
	<link rel="stylesheet" type="text/css" href="setup-style.css">
</head>

<body>

<span class="jive-setup-header">
<table cellpadding="8" cellspacing="0" border="0" width="100%">
<tr>
    <td>
        <fmt:message key="title" /> <fmt:message key="setup.title" />
    </td>
</tr>
</table>
</span>
<table bgcolor="#bbbbbb" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr><td><img src="../images/blank.gif" width="1" height="1" border="0" alt=""></td></tr>
</table>
<table bgcolor="#dddddd" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr><td><img src="../images/blank.gif" width="1" height="1" border="0" alt=""></td></tr>
</table>
<table bgcolor="#eeeeee" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr><td><img src="../images/blank.gif" width="1" height="1" border="0" alt=""></td></tr>
</table>

<br>

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr valign="top">
    <%  if (showSidebar) { %>
        <td width="1%" nowrap>
           <%!
                final String INCOMPLETE = "incomplete";
                final String IN_PROGRESS = "in_progress";
                final String DONE = "done";
            %>

            <%  // Get sidebar values from the session:

                String step1 = (String)session.getAttribute("jive.setup.sidebar.1");
                String step2 = (String)session.getAttribute("jive.setup.sidebar.2");
                String step3 = (String)session.getAttribute("jive.setup.sidebar.3");
                String step4 = (String)session.getAttribute("jive.setup.sidebar.4");

                if (step1 == null) { step1 = IN_PROGRESS; }
                if (step2 == null) { step2 = INCOMPLETE; }
                if (step3 == null) { step3 = INCOMPLETE; }
                if (step4 == null) { step4 = INCOMPLETE; }

                String[] items = {step1, step2, step3, step4};
                String[] names = {
                    LocaleUtils.getLocalizedString("setup.sidebar.language"),
                    LocaleUtils.getLocalizedString("setup.sidebar.settings"),
                    LocaleUtils.getLocalizedString("setup.sidebar.datasource"),
                    LocaleUtils.getLocalizedString("setup.sidebar.admin")
                };
                String[] links = {
                    "index.jsp",
                    "setup-host-settings.jsp",
                    "setup-datasource-settings.jsp",
                    "setup-admin-settings.jsp"
                };
            %>

154 155 156 157 158 159 160

        <div style="width:200px;">
            <div class="jive-setup-sidebar-top">
                <b><fmt:message key="setup.sidebar.title" /></b>
            </div>
            <div class="jive-setup-sidebar-bottom">
            <table cellpadding="5" cellspacing="0" border="0">
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
                    <%  for (int i=0; i<items.length; i++) { %>
                        <tr>
                        <%  if (INCOMPLETE.equals(items[i])) { %>

                            <td width="1%"><img src="../images/bullet-red-14x14.gif" width="14" height="14" border="0" alt="*"></td>
                            <td width="99%">
                                    <%= names[i] %>
                            </td>

                        <%  } else if (IN_PROGRESS.equals(items[i])) { %>

                            <td width="1%"><img src="../images/bullet-yellow-14x14.gif" width="14" height="14" border="0" alt="*"></td>
                            <td width="99%">
                                    <a href="<%= links[i] %>"><%= names[i] %></a>
                            </td>

                        <%  } else { %>

                            <td width="1%"><img src="../images/bullet-green-14x14.gif" width="14" height="14" border="0" alt="*"></td>
                            <td width="99%">
                                    <a href="<%= links[i] %>"><%= names[i] %></a>
                            </td>

                        <%  } %>
                        </tr>
                    <%  } %>
                    <tr><td colspan="2"><br><br><br><br></td></tr>
188 189 190 191
                </table>
            </div>
        </div>

192 193 194 195 196 197 198 199 200 201 202 203
        </td>
        <td width="1%" nowrap><img src="../images/blank.gif" width="15" height="1" border="0" alt=""></td>
    <%  } %>
    <td width="98%">

    <decorator:body/>

    </td></tr>
</table>

</body>
</html>