setup-datasource-settings.jsp 4.32 KB
Newer Older
1 2
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
Matt Tucker's avatar
Matt Tucker committed
3 4 5 6 7 8 9 10 11 12 13 14
<%--
  -	$RCSfile$
  -	$Revision$
  -	$Date$
--%>

<%@ page import="org.jivesoftware.util.ParamUtils,
                 org.jivesoftware.messenger.JiveGlobals,
                 org.jivesoftware.database.EmbeddedConnectionProvider,
                 org.jivesoftware.database.DbConnectionManager,
                 org.jivesoftware.database.ConnectionProvider,
                 org.jivesoftware.database.ConnectionProvider,
Matt Tucker's avatar
Matt Tucker committed
15 16
                 org.jivesoftware.database.DbConnectionManager,
                 java.util.*" %>
Matt Tucker's avatar
Matt Tucker committed
17 18 19 20 21 22 23 24

<%! // Global vars

    static final String STANDARD = "standard";
    static final String JNDI = "jndi";
    static final String EMBEDDED = "embedded";
%>

Bill Lynch's avatar
Bill Lynch committed
25
<%@ include file="setup-global.jspf" %>
Matt Tucker's avatar
Matt Tucker committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

<%  // Get parameters
    String mode = ParamUtils.getParameter(request,"mode");
    boolean next = ParamUtils.getBooleanParameter(request,"next");

    // handle a mode redirect
    Map errors = new HashMap();
    if (next) {
        if (STANDARD.equals(mode)) {
            response.sendRedirect("setup-datasource-standard.jsp");
            return;
        }
        else if (JNDI.equals(mode)) {
            if (!embeddedMode) {
                response.sendRedirect("setup-datasource-jndi.jsp");
                return;
            }
        }
        else if (EMBEDDED.equals(mode)) {
            // Set the classname of the provider in the config file:
46
            JiveGlobals.setXMLProperty("connectionProvider.className",
Matt Tucker's avatar
Matt Tucker committed
47 48 49 50
                    "org.jivesoftware.database.EmbeddedConnectionProvider");
            ConnectionProvider conProvider = new EmbeddedConnectionProvider();
            DbConnectionManager.setConnectionProvider(conProvider);
            if (testConnection(errors)) {
Matt Tucker's avatar
Matt Tucker committed
51
                // Update the sidebar status
Matt Tucker's avatar
Matt Tucker committed
52 53
                session.setAttribute("jive.setup.sidebar.3","done");
                session.setAttribute("jive.setup.sidebar.4","in_progress");
Matt Tucker's avatar
Matt Tucker committed
54
                // Redirect
Matt Tucker's avatar
Matt Tucker committed
55 56 57 58 59 60 61 62
                response.sendRedirect("setup-admin-settings.jsp");
                return;
            }
        }
    }

    // Defaults
    if (mode == null) {
Matt Tucker's avatar
Matt Tucker committed
63 64 65 66 67 68 69 70
        // If the "embedded-database" directory exists, select to the embedded db as the default.
        if (new File(JiveGlobals.getMessengerHome(), "embedded-db").exists()) {
            mode = EMBEDDED;
        }
        // Otherwise default to standard.
        else {
            mode = STANDARD;
        }
Matt Tucker's avatar
Matt Tucker committed
71 72 73
    }
%>

74
<%@ include file="setup-header.jspf" %>
Matt Tucker's avatar
Matt Tucker committed
75 76 77 78 79 80

<p class="jive-setup-page-header">
Datasource Settings
</p>

<p>
81
Choose how you would like to connect to the <fmt:message key="short.title" /> database.
Matt Tucker's avatar
Matt Tucker committed
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
</p>

<%  if (errors.size() > 0) { %>

    <p class="jive-error-text">
    <%= errors.get("general") %>
    </p>

<%  } %>

<form action="setup-datasource-settings.jsp">
<input type="hidden" name="next" value="true">

<table cellpadding="3" cellspacing="2" border="0">
<tr>
    <td align="center" valign="top">
        <input type="radio" name="mode" value="<%= STANDARD %>" id="rb02"
         <%= ((STANDARD.equals(mode)) ? "checked" : "") %>>
    </td>
    <td>
        <label for="rb02"><b>Standard Database Connection</b></label> -
        Use an external database with the built-in connection pool.
    </td>
</tr>

<%  if (!embeddedMode) { %>

    <tr>
        <td align="center" valign="top">
            <input type="radio" name="mode" value="<%= JNDI %>" id="rb03"
             <%= ((JNDI.equals(mode)) ? "checked" : "") %>>
        </td>
        <td>
            <label for="rb03"><b>JNDI Datasource</b></label> -
            Use a datasource defined by your application server via JNDI.
        </td>
    </tr>

<%  } %>

<tr>
    <td align="center" valign="top">
        <input type="radio" name="mode" value="<%= EMBEDDED %>" id="rb01"
         <%= ((EMBEDDED.equals(mode)) ? "checked" : "") %>>
    </td>
    <td>
        <label for="rb01"><b>Embedded Database</b></label> -
        Use an embedded database, powered by HSQLDB. This option requires no external database
        configuration and is an easy way to get running quickly. However, this is not recommended
        for large installations.
    </td>
</tr>
</table>

<br><br>

<hr size="0">

<div align="right"><input type="submit" value=" Continue "></div>

</form>

<%@ include file="setup-footer.jsp" %>