From 56bcc2f1b8abbaba6f695f07af3c5bf69dd60173 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 06 May 2013 07:04:09 +0000
Subject: [PATCH] OPENDJ-892 (CR-1644) Listen address and port for the HTTP connection handler should be displayed in status command output
---
opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java | 80 ++++++++++---------
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ConnectionHandlerDescriptor.java | 13 +++
opends/src/messages/messages/admin_tool.properties | 2
opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java | 94 +++++++++++------------
opends/src/server/org/opends/server/tools/status/StatusCli.java | 41 ++++------
5 files changed, 118 insertions(+), 112 deletions(-)
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ConnectionHandlerDescriptor.java b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ConnectionHandlerDescriptor.java
index 4720f90..ec9ec55 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ConnectionHandlerDescriptor.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ConnectionHandlerDescriptor.java
@@ -23,8 +23,8 @@
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
+ * Portions Copyright 2013 ForgeRock AS
*/
-
package org.opends.guitools.controlpanel.datamodel;
import static org.opends.messages.AdminToolMessages.*;
@@ -85,6 +85,14 @@
*/
LDAPS(INFO_CTRL_PANEL_CONN_HANDLER_LDAPS.get()),
/**
+ * HTTP protocol.
+ */
+ HTTP(INFO_CTRL_PANEL_CONN_HANDLER_HTTP.get()),
+ /**
+ * HTTP secure protocol.
+ */
+ HTTPS(INFO_CTRL_PANEL_CONN_HANDLER_HTTPS.get()),
+ /**
* JMX protocol.
*/
JMX(INFO_CTRL_PANEL_CONN_HANDLER_JMX.get()),
@@ -226,6 +234,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int hashCode()
{
return hashCode;
@@ -234,6 +243,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return toString;
@@ -242,6 +252,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean equals(Object o)
{
boolean equals = false;
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java b/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
index 9fa53ab..7cfaf03 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
@@ -288,15 +288,13 @@
{
ex.add(oe);
}
- String[] connectionHandlers = root.listConnectionHandlers();
- for (int i=0; i<connectionHandlers.length; i++)
+ for (String connHandler : root.listConnectionHandlers())
{
try
{
ConnectionHandlerCfgClient connectionHandler =
- root.getConnectionHandler(connectionHandlers[i]);
- ls.add(getConnectionHandler(connectionHandler,
- connectionHandlers[i]));
+ root.getConnectionHandler(connHandler);
+ ls.add(getConnectionHandler(connectionHandler, connHandler));
}
catch (OpenDsException oe)
{
@@ -305,12 +303,11 @@
}
isSchemaEnabled = root.getGlobalConfiguration().isCheckSchema();
- String[] backendNames = root.listBackends();
- for (int i=0; i<backendNames.length; i++)
+ for (String backendName : root.listBackends())
{
try
{
- BackendCfgClient backend = root.getBackend(backendNames[i]);
+ BackendCfgClient backend = root.getBackend(backendName);
Set<BaseDNDescriptor> baseDNs = new HashSet<BaseDNDescriptor>();
for (DN dn : backend.getBaseDN())
{
@@ -327,12 +324,11 @@
{
type = BackendDescriptor.Type.LOCAL_DB;
LocalDBBackendCfgClient db = (LocalDBBackendCfgClient)backend;
- String[] indexNames = db.listLocalDBIndexes();
try
{
- for (int j=0; j<indexNames.length; j++)
+ for (String indexName : db.listLocalDBIndexes())
{
- LocalDBIndexCfgClient index = db.getLocalDBIndex(indexNames[j]);
+ LocalDBIndexCfgClient index = db.getLocalDBIndex(indexName);
indexes.add(new IndexDescriptor(
index.getAttribute().getNameOrOID(), index.getAttribute(),
null, index.getIndexType(), index.getIndexEntryLimit()));
@@ -342,23 +338,19 @@
{
ex.add(oe);
}
- indexes.add(
- new IndexDescriptor("dn2id", null, null,
- new TreeSet<IndexType>(), -1));
- indexes.add(
- new IndexDescriptor("id2children", null, null,
- new TreeSet<IndexType>(), -1));
- indexes.add(
- new IndexDescriptor("id2subtree", null, null,
- new TreeSet<IndexType>(), -1));
+ indexes.add(new IndexDescriptor("dn2id", null, null,
+ new TreeSet<IndexType>(), -1));
+ indexes.add(new IndexDescriptor("id2children", null, null,
+ new TreeSet<IndexType>(), -1));
+ indexes.add(new IndexDescriptor("id2subtree", null, null,
+ new TreeSet<IndexType>(), -1));
- String[] vlvIndexNames = db.listLocalDBVLVIndexes();
try
{
- for (int j=0; j<vlvIndexNames.length; j++)
+ for (String vlvIndexName : db.listLocalDBVLVIndexes())
{
LocalDBVLVIndexCfgClient index =
- db.getLocalDBVLVIndex(vlvIndexNames[j]);
+ db.getLocalDBVLVIndex(vlvIndexName);
String s = index.getSortOrder();
List<VLVSortOrder> sortOrder = getVLVSortOrder(s);
vlvIndexes.add(new VLVIndexDescriptor(index.getName(), null,
@@ -470,10 +462,10 @@
String[] domains = sync.listReplicationDomains();
if (domains != null)
{
- for (int i=0; i<domains.length; i++)
+ for (String domain2 : domains)
{
ReplicationDomainCfgClient domain =
- sync.getReplicationDomain(domains[i]);
+ sync.getReplicationDomain(domain2);
DN dn = domain.getBaseDN();
for (BackendDescriptor backend : bs)
{
@@ -504,9 +496,9 @@
String[] rootUsers = rootDN.listRootDNUsers();
if (rootUsers != null)
{
- for (int i=0; i < rootUsers.length; i++)
+ for (String rootUser2 : rootUsers)
{
- RootDNUserCfgClient rootUser = rootDN.getRootDNUser(rootUsers[i]);
+ RootDNUserCfgClient rootUser = rootDN.getRootDNUser(rootUser2);
as.addAll(rootUser.getAlternateBindDN());
}
}
@@ -929,13 +921,24 @@
{
protocol = ConnectionHandlerDescriptor.Protocol.LDAP;
}
- SortedSet<InetAddress> v = ldap.getListenAddress();
- if (v != null)
- {
- addresses.addAll(v);
- }
+ addAll(addresses, ldap.getListenAddress());
port = ldap.getListenPort();
}
+ else if (connHandler instanceof HTTPConnectionHandlerCfgClient)
+ {
+ HTTPConnectionHandlerCfgClient http =
+ (HTTPConnectionHandlerCfgClient) connHandler;
+ if (http.isUseSSL())
+ {
+ protocol = ConnectionHandlerDescriptor.Protocol.HTTPS;
+ }
+ else
+ {
+ protocol = ConnectionHandlerDescriptor.Protocol.HTTP;
+ }
+ addAll(addresses, http.getListenAddress());
+ port = http.getListenPort();
+ }
else if (connHandler instanceof JMXConnectionHandlerCfgClient)
{
JMXConnectionHandlerCfgClient jmx =
@@ -948,11 +951,7 @@
{
protocol = ConnectionHandlerDescriptor.Protocol.JMX;
}
- SortedSet<InetAddress> v = jmx.getListenAddress();
- if (v != null)
- {
- addresses.addAll(v);
- }
+ addAll(addresses, jmx.getListenAddress());
port = jmx.getListenPort();
}
else if (connHandler instanceof LDIFConnectionHandlerCfgClient)
@@ -965,11 +964,7 @@
protocol = ConnectionHandlerDescriptor.Protocol.SNMP;
SNMPConnectionHandlerCfgClient snmp =
(SNMPConnectionHandlerCfgClient)connHandler;
- SortedSet<InetAddress> v = snmp.getListenAddress();
- if (v != null)
- {
- addresses.addAll(v);
- }
+ addAll(addresses, snmp.getListenAddress());
port = snmp.getListenPort();
}
else
@@ -982,6 +977,14 @@
name, emptySet);
}
+ private <T> void addAll(Collection<T> target, Collection<T> source)
+ {
+ if (source != null)
+ {
+ target.addAll(source);
+ }
+ }
+
private ConnectionHandlerDescriptor getConnectionHandler(
AdministrationConnectorCfgClient adminConnector) throws OpenDsException
{
@@ -994,12 +997,7 @@
ConnectionHandlerDescriptor.State state =
ConnectionHandlerDescriptor.State.ENABLED;
-
- SortedSet<InetAddress> v = adminConnector.getListenAddress();
- if (v != null)
- {
- addresses.addAll(v);
- }
+ addAll(addresses, adminConnector.getListenAddress());
int port = adminConnector.getListenPort();
Set<CustomSearchResult> emptySet = Collections.emptySet();
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java b/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java
index e115c27..18db094 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java
@@ -32,6 +32,7 @@
import java.net.InetAddress;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -57,6 +58,7 @@
import org.opends.server.admin.std.server.BackupBackendCfg;
import org.opends.server.admin.std.server.ConnectionHandlerCfg;
import org.opends.server.admin.std.server.CryptoManagerCfg;
+import org.opends.server.admin.std.server.HTTPConnectionHandlerCfg;
import org.opends.server.admin.std.server.JMXConnectionHandlerCfg;
import org.opends.server.admin.std.server.LDAPConnectionHandlerCfg;
import org.opends.server.admin.std.server.LDIFBackendCfg;
@@ -143,15 +145,13 @@
{
ex.add(ce);
}
- String[] connectionHandlers = root.listConnectionHandlers();
- for (int i=0; i<connectionHandlers.length; i++)
+ for (String connHandler : root.listConnectionHandlers())
{
try
{
ConnectionHandlerCfg connectionHandler =
- root.getConnectionHandler(connectionHandlers[i]);
- ls.add(getConnectionHandler(connectionHandler,
- connectionHandlers[i]));
+ root.getConnectionHandler(connHandler);
+ ls.add(getConnectionHandler(connectionHandler, connHandler));
}
catch (OpenDsException oe)
{
@@ -160,12 +160,11 @@
}
isSchemaEnabled = root.getGlobalConfiguration().isCheckSchema();
- String[] backendNames = root.listBackends();
- for (int i=0; i<backendNames.length; i++)
+ for (String backendName : root.listBackends())
{
try
{
- BackendCfg backend = root.getBackend(backendNames[i]);
+ BackendCfg backend = root.getBackend(backendName);
Set<BaseDNDescriptor> baseDNs = new HashSet<BaseDNDescriptor>();
for (DN dn : backend.getBaseDN())
{
@@ -182,12 +181,11 @@
{
type = BackendDescriptor.Type.LOCAL_DB;
LocalDBBackendCfg db = (LocalDBBackendCfg)backend;
- String[] indexNames = db.listLocalDBIndexes();
try
{
- for (int j=0; j<indexNames.length; j++)
+ for (String indexName : db.listLocalDBIndexes())
{
- LocalDBIndexCfg index = db.getLocalDBIndex(indexNames[j]);
+ LocalDBIndexCfg index = db.getLocalDBIndex(indexName);
indexes.add(new IndexDescriptor(
index.getAttribute().getNameOrOID(), index.getAttribute(),
null, index.getIndexType(), index.getIndexEntryLimit()));
@@ -204,13 +202,12 @@
indexes.add(new IndexDescriptor("id2subtree", null, null,
new TreeSet<IndexType>(), -1));
- String[] vlvIndexNames = db.listLocalDBVLVIndexes();
try
{
- for (int j=0; j<vlvIndexNames.length; j++)
+ for (String vlvIndexName : db.listLocalDBVLVIndexes())
{
LocalDBVLVIndexCfg index =
- db.getLocalDBVLVIndex(vlvIndexNames[j]);
+ db.getLocalDBVLVIndex(vlvIndexName);
String s = index.getSortOrder();
List<VLVSortOrder> sortOrder = getVLVSortOrder(s);
vlvIndexes.add(new VLVIndexDescriptor(index.getName(), null,
@@ -320,10 +317,10 @@
String[] domains = sync.listReplicationDomains();
if (domains != null)
{
- for (int i=0; i<domains.length; i++)
+ for (String domain2 : domains)
{
ReplicationDomainCfg domain =
- sync.getReplicationDomain(domains[i]);
+ sync.getReplicationDomain(domain2);
DN dn = domain.getBaseDN();
for (BackendDescriptor backend : bs)
{
@@ -355,9 +352,9 @@
as.clear();
if (rootUsers != null)
{
- for (int i=0; i < rootUsers.length; i++)
+ for (String rootUser2 : rootUsers)
{
- RootDNUserCfg rootUser = rootDN.getRootDNUser(rootUsers[i]);
+ RootDNUserCfg rootUser = rootDN.getRootDNUser(rootUser2);
as.addAll(rootUser.getAlternateBindDN());
}
}
@@ -425,13 +422,23 @@
{
protocol = ConnectionHandlerDescriptor.Protocol.LDAP;
}
- SortedSet<InetAddress> v = ldap.getListenAddress();
- if (v != null)
- {
- addresses.addAll(v);
- }
+ addAll(addresses, ldap.getListenAddress());
port = ldap.getListenPort();
}
+ else if (connHandler instanceof HTTPConnectionHandlerCfg)
+ {
+ HTTPConnectionHandlerCfg http = (HTTPConnectionHandlerCfg) connHandler;
+ if (http.isUseSSL())
+ {
+ protocol = ConnectionHandlerDescriptor.Protocol.HTTPS;
+ }
+ else
+ {
+ protocol = ConnectionHandlerDescriptor.Protocol.HTTP;
+ }
+ addAll(addresses, http.getListenAddress());
+ port = http.getListenPort();
+ }
else if (connHandler instanceof JMXConnectionHandlerCfg)
{
JMXConnectionHandlerCfg jmx = (JMXConnectionHandlerCfg)connHandler;
@@ -443,11 +450,7 @@
{
protocol = ConnectionHandlerDescriptor.Protocol.JMX;
}
- SortedSet<InetAddress> v = jmx.getListenAddress();
- if (v != null)
- {
- addresses.addAll(v);
- }
+ addAll(addresses, jmx.getListenAddress());
port = jmx.getListenPort();
}
else if (connHandler instanceof LDIFConnectionHandlerCfg)
@@ -459,11 +462,7 @@
{
protocol = ConnectionHandlerDescriptor.Protocol.SNMP;
SNMPConnectionHandlerCfg snmp = (SNMPConnectionHandlerCfg)connHandler;
- SortedSet<InetAddress> v = snmp.getListenAddress();
- if (v != null)
- {
- addresses.addAll(v);
- }
+ addAll(addresses, snmp.getListenAddress());
port = snmp.getListenPort();
}
else
@@ -476,6 +475,14 @@
name, emptySet);
}
+ private <T> void addAll(Collection<T> target, Collection<T> source)
+ {
+ if (source != null)
+ {
+ target.addAll(source);
+ }
+ }
+
private ConnectionHandlerDescriptor getConnectionHandler(
AdministrationConnectorCfg adminConnector) throws OpenDsException
{
@@ -488,12 +495,7 @@
ConnectionHandlerDescriptor.State state =
ConnectionHandlerDescriptor.State.ENABLED;
-
- SortedSet<InetAddress> v = adminConnector.getListenAddress();
- if (v != null)
- {
- addresses.addAll(v);
- }
+ addAll(addresses, adminConnector.getListenAddress());
int port = adminConnector.getListenPort();
Set<CustomSearchResult> emptySet = Collections.emptySet();
return new ConnectionHandlerDescriptor(addresses, port, protocol, state,
diff --git a/opends/src/messages/messages/admin_tool.properties b/opends/src/messages/messages/admin_tool.properties
index 0f8f779..61045c2 100644
--- a/opends/src/messages/messages/admin_tool.properties
+++ b/opends/src/messages/messages/admin_tool.properties
@@ -1006,6 +1006,8 @@
INFO_CTRL_PANEL_CONN_HANDLER_LDAP=LDAP
INFO_CTRL_PANEL_CONN_HANDLER_LDAPS=LDAPS
INFO_CTRL_PANEL_CONN_HANDLER_LDAP_STARTTLS=LDAP (allows StartTLS)
+INFO_CTRL_PANEL_CONN_HANDLER_HTTP=HTTP
+INFO_CTRL_PANEL_CONN_HANDLER_HTTPS=HTTPS
INFO_CTRL_PANEL_CONN_HANDLER_JMX=JMX
INFO_CTRL_PANEL_CONN_HANDLER_JMXS=JMX (secure)
INFO_CTRL_PANEL_CONN_HANDLER_LDIF=LDIF
diff --git a/opends/src/server/org/opends/server/tools/status/StatusCli.java b/opends/src/server/org/opends/server/tools/status/StatusCli.java
index e5ff0a3..07d7b40 100644
--- a/opends/src/server/org/opends/server/tools/status/StatusCli.java
+++ b/opends/src/server/org/opends/server/tools/status/StatusCli.java
@@ -28,6 +28,11 @@
package org.opends.server.tools.status;
+import static org.opends.messages.AdminToolMessages.*;
+import static org.opends.messages.QuickSetupMessages.*;
+import static org.opends.messages.ToolMessages.*;
+import static org.opends.quicksetup.util.Utils.*;
+
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
@@ -35,7 +40,6 @@
import java.net.URI;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
@@ -56,21 +60,13 @@
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.util.ControlPanelLog;
import org.opends.guitools.controlpanel.util.Utilities;
-
-import static org.opends.quicksetup.util.Utils.*;
-
+import org.opends.messages.Message;
+import org.opends.messages.MessageBuilder;
+import org.opends.server.admin.AdministrationConnector;
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode;
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.config.ConfigException;
-
-import org.opends.messages.Message;
-import org.opends.messages.MessageBuilder;
-import org.opends.server.admin.AdministrationConnector;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.messages.AdminToolMessages.*;
-import static org.opends.messages.QuickSetupMessages.*;
-
import org.opends.server.tools.ClientException;
import org.opends.server.tools.ToolConstants;
import org.opends.server.tools.dsconfig.LDAPManagementContextFactory;
@@ -504,9 +500,9 @@
Message title = INFO_SERVER_STATUS_TITLE.get();
if (!isScriptFriendly())
{
- for (int i=0; i<labels.length; i++)
+ for (Message label : labels)
{
- labelWidth = Math.max(labelWidth, labels[i].length());
+ labelWidth = Math.max(labelWidth, label.length());
}
getOutputStream().println();
getOutputStream().println(centerTitle(title));
@@ -829,15 +825,7 @@
}
Set<ConnectionHandlerDescriptor> allHandlers = desc.getConnectionHandlers();
-
- Set<ConnectionHandlerDescriptor> connectionHandlers =
- new LinkedHashSet<ConnectionHandlerDescriptor>();
- for (ConnectionHandlerDescriptor listener: allHandlers)
- {
- connectionHandlers.add(listener);
- }
-
- if (connectionHandlers.size() == 0)
+ if (allHandlers.size() == 0)
{
if (desc.getStatus() == ServerDescriptor.ServerStatus.STARTED)
{
@@ -861,7 +849,7 @@
{
ConnectionHandlerTableModel connHandlersTableModel =
new ConnectionHandlerTableModel(false);
- connHandlersTableModel.setData(connectionHandlers);
+ connHandlersTableModel.setData(allHandlers);
writeConnectionHandlersTableModel(connHandlersTableModel, desc);
}
}
@@ -1273,6 +1261,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isAdvancedMode() {
return false;
}
@@ -1282,6 +1271,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isInteractive() {
return argParser.isInteractive();
}
@@ -1301,6 +1291,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isQuiet() {
return false;
}
@@ -1310,6 +1301,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isScriptFriendly() {
return argParser.isScriptFriendly();
}
@@ -1319,6 +1311,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isVerbose() {
return true;
}
--
Gitblit v1.10.0