mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
18.35.2016 4818be26577e76b550219cde7278282f101dafa9
Replaced uses of ConnectionUtils.getHost() and getPort() by ConnectionWrapper.getHostPort()
7 files modified
70 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java 11 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java 15 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/LDAPConnectionPool.java 15 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ImportLDIFPanel.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java 14 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java
@@ -398,17 +398,6 @@
  }
  /**
   * Returns the port number used in the provided InitialLdapContext.
   * @param ctx the context to analyze.
   * @return the port number used in the provided InitialLdapContext.
   */
  public static int getPort(InitialLdapContext ctx)
  {
    HostPort hp = getHostPort(ctx);
    return hp != null ? hp.getPort() : -1;
  }
  /**
   * Returns the host port representation of the server to which this
   * context is connected.
   * @param ctx the context to analyze.
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java
@@ -49,6 +49,7 @@
import org.opends.admin.ads.ADSContext;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.admin.ads.util.ConnectionWrapper;
import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.BrowserEvent;
@@ -65,7 +66,7 @@
import org.opends.server.types.HostPort;
import org.opends.server.types.LDAPURL;
import static org.opends.admin.ads.util.ConnectionUtils.getPort;
import static org.opends.admin.ads.util.ConnectionUtils.isSSL;
import static org.opends.server.util.ServerConstants.*;
/**
@@ -113,6 +114,7 @@
  private int displayFlags;
  private String displayAttribute;
  private final boolean showAttributeName;
  private ConnectionWrapper connConfig;
  private InitialLdapContext ctxConfiguration;
  private InitialLdapContext ctxUserData;
  private boolean followReferrals;
@@ -189,17 +191,18 @@
   */
  public void setConnections(
      ServerDescriptor server,
      InitialLdapContext ctxConfiguration,
      ConnectionWrapper ctxConfiguration,
      InitialLdapContext ctxUserData) throws NamingException {
    String rootNodeName;
    if (ctxConfiguration != null)
    {
      this.ctxConfiguration = ctxConfiguration;
      this.connConfig = ctxConfiguration;
      this.ctxConfiguration = connConfig.getLdapContext();
      this.ctxUserData = ctxUserData;
      this.ctxConfiguration.setRequestControls(getConfigurationRequestControls());
      this.ctxUserData.setRequestControls(getRequestControls());
      rootNodeName = new HostPort(server.getHostname(), getPort(ctxConfiguration)).toString();
      rootNodeName = new HostPort(server.getHostname(), connConfig.getHostPort().getPort()).toString();
    }
    else {
      rootNodeName = "";
@@ -1044,7 +1047,7 @@
   */
  LDAPURL findUrlForLocalEntry(BasicNode node) {
    if (node == rootNode) {
      return LDAPConnectionPool.makeLDAPUrl(ctxConfiguration, "");
      return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), "", isSSL(ctxConfiguration));
    }
    final BasicNode parent = (BasicNode) node.getParent();
    if (parent != null)
@@ -1052,7 +1055,7 @@
      final LDAPURL parentUrl = findUrlForDisplayedEntry(parent);
      return LDAPConnectionPool.makeLDAPUrl(parentUrl, node.getDN());
    }
    return LDAPConnectionPool.makeLDAPUrl(ctxConfiguration, node.getDN());
    return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), node.getDN(), isSSL(ctxConfiguration));
  }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/LDAPConnectionPool.java
@@ -24,13 +24,13 @@
import javax.naming.ldap.InitialLdapContext;
import javax.net.ssl.KeyManager;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.guitools.controlpanel.event.ReferralAuthenticationListener;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.HostPort;
import org.opends.server.types.LDAPURL;
import org.forgerock.opendj.ldap.SearchScope;
import com.forgerock.opendj.cli.CliConstants;
@@ -478,19 +478,20 @@
  }
  private LDAPURL makeLDAPUrl(InitialLdapContext ctx) {
    return makeLDAPUrl(ctx, "");
    return makeLDAPUrl(ConnectionUtils.getHostPort(ctx), "", isSSL(ctx));
  }
  /**
   * Make an url from the specified arguments.
   * @param ctx the connection to the server.
   * @param hostPort the host name and port of the server.
   * @param dn the base DN of the URL.
   * @param isSSL whether the connection uses SSL
   * @return an LDAP URL from the specified arguments.
   */
  public static LDAPURL makeLDAPUrl(InitialLdapContext ctx, String dn) {
    HostPort hostPort = ConnectionUtils.getHostPort(ctx);
  public static LDAPURL makeLDAPUrl(HostPort hostPort, String dn, boolean isSSL)
  {
    return new LDAPURL(
        isSSL(ctx) ? "ldaps" : LDAPURL.DEFAULT_SCHEME,
        isSSL ? "ldaps" : LDAPURL.DEFAULT_SCHEME,
               hostPort.getHost(),
               hostPort.getPort(),
               dn,
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -301,7 +301,7 @@
      InitialLdapContext ctx = connWrapper.getLdapContext();
      lastWorkingBindDN = ConnectionUtils.getBindDN(ctx);
      lastWorkingBindPwd = ConnectionUtils.getBindPassword(ctx);
      lastRemoteHostName = ConnectionUtils.getHostName(ctx);
      lastRemoteHostName = connWrapper.getHostPort().getHost();
      lastRemoteAdministrationURL = ConnectionUtils.getLdapUrl(ctx);
    }
  }
@@ -1190,7 +1190,7 @@
    if (getConnection() != null)
    {
      adminPort2 = ConnectionUtils.getPort(getConnection().getLdapContext());
      adminPort2 = getConnection().getHostPort().getPort();
    }
    return adminPort1 == adminPort2;
  }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java
@@ -70,6 +70,8 @@
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.guitools.controlpanel.browser.BrowserController;
@@ -94,8 +96,6 @@
import org.opends.quicksetup.ui.CertificateDialog;
import org.opends.quicksetup.util.UIKeyStore;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.LDAPException;
import org.opends.server.types.SearchFilter;
@@ -1214,9 +1214,9 @@
              {
                try
                {
                  ControlPanelInfo info = getInfo();
                  controller.setConnections(
                      getInfo().getServerDescriptor(), getInfo().getConnection().getLdapContext(),
                      getInfo().getUserDataDirContext());
                      info.getServerDescriptor(), info.getConnection(), info.getUserDataDirContext());
                  applyButtonClicked();
                }
                catch (NamingException ne)
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ImportLDIFPanel.java
@@ -45,7 +45,6 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.DN;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.admin.ads.util.ConnectionWrapper;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
@@ -835,7 +834,7 @@
      args.add("--hostName");
      args.add(getInfo().getServerDescriptor().getHostname());
      args.add("--port");
      args.add(String.valueOf(ConnectionUtils.getPort(getInfo().getConnection().getLdapContext())));
      args.add(String.valueOf(getInfo().getConnection().getHostPort().getPort()));
      for (DN baseDN : replicatedBaseDNs)
      {
        args.add("--baseDN");
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -5367,8 +5367,8 @@
          ERROR_READING_TOPOLOGY_CACHE, tce);
    }
    addToSets(serverDesc1, uData.getServer1(), ctx1.getLdapContext(), twoReplServers, usedReplicationServerIds);
    addToSets(serverDesc2, uData.getServer2(), ctx2.getLdapContext(), twoReplServers, usedReplicationServerIds);
    addToSets(serverDesc1, uData.getServer1(), ctx1, twoReplServers, usedReplicationServerIds);
    addToSets(serverDesc2, uData.getServer2(), ctx2, twoReplServers, usedReplicationServerIds);
    for (String baseDN : uData.getBaseDNs())
    {
@@ -5494,7 +5494,7 @@
    }
  }
  private void addToSets(ServerDescriptor serverDesc, EnableReplicationServerData serverData, InitialLdapContext ctx,
  private void addToSets(ServerDescriptor serverDesc, EnableReplicationServerData serverData, ConnectionWrapper conn,
      final Set<String> twoReplServers, final Set<Integer> usedReplicationServerIds)
  {
    if (serverDesc.isReplicationServer())
@@ -5504,7 +5504,7 @@
    }
    else if (serverData.configureReplicationServer())
    {
      twoReplServers.add(getReplicationServer(getHostName(ctx), serverData.getReplicationPort()));
      twoReplServers.add(getReplicationServer(conn.getHostPort().getHost(), serverData.getReplicationPort()));
    }
  }
@@ -9091,7 +9091,7 @@
    Collection<ReplicaDescriptor> replicas = getReplicas(ctxDomain.getLdapContext());
    int replicationPort = getReplicationPort(ctxOther);
    boolean isReplicationServerConfigured = replicationPort != -1;
    String replicationServer = getReplicationServer(getHostName(ctxOther.getLdapContext()), replicationPort);
    String replicationServer = getReplicationServer(ctxOther.getHostPort().getHost(), replicationPort);
    for (ReplicaDescriptor replica : replicas)
    {
      if (!isReplicationServerConfigured)
@@ -9128,11 +9128,11 @@
  {
    int replicationPort1 = getReplicationPort(ctx1);
    boolean isReplicationServer1Configured = replicationPort1 != -1;
    String replicationServer1 = getReplicationServer(getHostName(ctx1.getLdapContext()), replicationPort1);
    String replicationServer1 = getReplicationServer(ctx1.getHostPort().getHost(), replicationPort1);
    int replicationPort2 = getReplicationPort(ctx2);
    boolean isReplicationServer2Configured = replicationPort2 != -1;
    String replicationServer2 = getReplicationServer(getHostName(ctx2.getLdapContext()), replicationPort2);
    String replicationServer2 = getReplicationServer(ctx2.getHostPort().getHost(), replicationPort2);
    TopologyCache cache1 = isReplicationServer1Configured ? createTopologyCache(ctx1) : null;
    TopologyCache cache2 = isReplicationServer2Configured ? createTopologyCache(ctx2) : null;