setup-host-settings.jsp 6.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
<%--
  -	$RCSfile$
  -	$Revision: 1638 $
  -	$Date: 2005-07-18 10:16:48 -0700 (Mon, 18 Jul 2005) $
--%>

<%@ page import="org.jivesoftware.util.ParamUtils,
                 org.jivesoftware.util.JiveGlobals,
                 java.util.Map,
                 java.util.HashMap,
                 java.net.InetAddress,
12
                 org.jivesoftware.openfire.XMPPServer"
13
%>
14
<%@ page import="java.net.UnknownHostException" %>
15 16 17 18

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>

19 20 21 22 23 24 25
<%
	// Redirect if we've already run setup:
	if (!XMPPServer.getInstance().isSetupMode()) {
        response.sendRedirect("setup-completed.jsp");
        return;
    }
%>
26

27 28
<% // Get parameters
    String domain = ParamUtils.getParameter(request, "domain");
29 30
    int embeddedPort = ParamUtils.getIntParameter(request, "embeddedPort", Integer.MIN_VALUE);
    int securePort = ParamUtils.getIntParameter(request, "securePort", Integer.MIN_VALUE);
31 32 33 34 35
    boolean sslEnabled = ParamUtils.getBooleanParameter(request, "sslEnabled", true);

    boolean doContinue = request.getParameter("continue") != null;

    // handle a continue request:
36
    Map<String, String> errors = new HashMap<String, String>();
37 38 39
    if (doContinue) {
        // Validate parameters
        if (domain == null) {
40
            errors.put("domain", "domain");
41 42
        }
        if (XMPPServer.getInstance().isStandAlone()) {
43
            if (embeddedPort == Integer.MIN_VALUE) {
44
                errors.put("embeddedPort", "embeddedPort");
45
            }
46 47 48 49 50 51
            // Force any negative value to -1.
            else if (embeddedPort < 0) {
                embeddedPort = -1;
            }

            if (securePort == Integer.MIN_VALUE) {
52
                errors.put("securePort", "securePort");
53 54 55 56 57
            }
            // Force any negative value to -1.
            else if (securePort < 0) {
                securePort = -1;
            }
58
        } else {
59 60 61 62 63
            embeddedPort = -1;
            securePort = -1;
        }
        // Continue if there were no errors
        if (errors.size() == 0) {
64
            Map<String, String> xmppSettings = new HashMap<String, String>();
65

66 67 68
            xmppSettings.put("xmpp.domain", domain);
            xmppSettings.put("xmpp.socket.ssl.active", "" + sslEnabled);
            xmppSettings.put("xmpp.auth.anonymous", "true");
69 70
            session.setAttribute("xmppSettings", xmppSettings);

71 72 73
            Map<String, String> xmlSettings = new HashMap<String, String>();
            xmlSettings.put("adminConsole.port", Integer.toString(embeddedPort));
            xmlSettings.put("adminConsole.securePort", Integer.toString(securePort));
74 75
            session.setAttribute("xmlSettings", xmlSettings);

76
            // Successful, so redirect
77 78 79 80 81 82 83 84 85 86 87 88 89 90
            response.sendRedirect("setup-datasource-settings.jsp");
            return;
        }
    }

    // Load the current values:
    if (!doContinue) {
        domain = JiveGlobals.getProperty("xmpp.domain");
        embeddedPort = JiveGlobals.getXMLProperty("adminConsole.port", 9090);
        securePort = JiveGlobals.getXMLProperty("adminConsole.securePort", 9091);
        sslEnabled = JiveGlobals.getBooleanProperty("xmpp.socket.ssl.active", true);

        // If the domain is still blank, guess at the value:
        if (domain == null) {
91 92 93 94 95 96
            try {
                domain = InetAddress.getLocalHost().getHostName().toLowerCase();
            } catch (UnknownHostException e) {
                e.printStackTrace();
                domain = "127.0.0.1";
            }
97 98 99 100
        }
    }
%>

101
<html>
102
<head>
103 104
    <title><fmt:message key="setup.host.settings.title" /></title>
    <meta name="currentStep" content="1"/>
105
</head>
106
<body>
107 108


109 110 111
	<h1>
	<fmt:message key="setup.host.settings.title" />
	</h1>
112

113 114 115
	<p>
	<fmt:message key="setup.host.settings.info" />
	</p>
116

117 118 119 120
	<!-- BEGIN jive-contentBox -->
	<div class="jive-contentBox">

		<form action="setup-host-settings.jsp" name="f" method="post">
121

Ryan Graham's avatar
Ryan Graham committed
122
<table cellpadding="3" cellspacing="0" border="0">
123
<tr valign="top">
124
    <td width="1%" nowrap align="right">
125 126 127 128 129
        <fmt:message key="setup.host.settings.domain" />
    </td>
    <td width="99%">
        <input type="text" size="30" maxlength="150" name="domain"
         value="<%= ((domain != null) ? domain : "") %>">
130
	    <span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.host.settings.hostname" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', 8000);"></span>
131 132 133 134 135
        <%  if (errors.get("domain") != null) { %>
            <span class="jive-error-text">
            <fmt:message key="setup.host.settings.invalid_domain" />
            </span>
        <%  } %>
136 137 138 139
    </td>
</tr>
<% if (XMPPServer.getInstance().isStandAlone()){ %>
<tr valign="top">
140
    <td width="1%" nowrap align="right">
141 142 143 144
        <fmt:message key="setup.host.settings.port" />
    </td>
    <td width="99%">
        <input type="text" size="6" maxlength="6" name="embeddedPort"
145
         value="<%= ((embeddedPort != Integer.MIN_VALUE) ? ""+embeddedPort : "9090") %>">
146
        <span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.host.settings.port_number" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', 8000);"></span>
147 148 149 150 151
        <%  if (errors.get("embeddedPort") != null) { %>
            <span class="jive-error-text">
            <fmt:message key="setup.host.settings.invalid_port" />
            </span>
        <%  } %>
152 153 154
    </td>
</tr>
<tr valign="top">
155
    <td width="1%" nowrap align="right">
156 157 158 159
        <fmt:message key="setup.host.settings.secure_port" />
    </td>
    <td width="99%">
        <input type="text" size="6" maxlength="6" name="securePort"
160
         value="<%= ((securePort != Integer.MIN_VALUE) ? ""+securePort : "9091") %>">
161
        <span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.host.settings.secure_port_number" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', 8000);"></span>
162 163 164 165 166
         <%  if (errors.get("securePort") != null) { %>
            <span class="jive-error-text">
            <fmt:message key="setup.host.settings.invalid_port" />
            </span>
        <%  } %>
167 168 169 170 171 172 173 174
    </td>
</tr>
<% } %>
</table>

<br><br>


175 176 177 178 179 180 181 182
		<div align="right">
			<input type="Submit" name="continue" value="<fmt:message key="global.continue" />" id="jive-setup-save" border="0">
		</div>
	</form>

	</div>
	<!-- END jive-contentBox -->

183 184 185 186 187 188

<script language="JavaScript" type="text/javascript">
// give focus to domain field
document.f.domain.focus();
</script>

189

190 191
</body>
</html>