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/ConfigFromDirContext.java | 94 +++++++++++++++++++++++------------------------
1 files changed, 46 insertions(+), 48 deletions(-)
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();
--
Gitblit v1.10.0