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

Jean-Noël Rouvignac
05.52.2016 664eac71955fcceba752801c55b091a197546b84
Partial OPENDJ-2625 Convert all code that uses JNDI to use the SDK instead

Replace all mentions of "DirContext" by "Connection"
1 files renamed
17 files modified
123 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/admin/ads/TopologyCacheException.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java 16 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteIndexTask.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/Task.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java 13 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LoginPanel.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/RootMonitoringPanel.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/BrowserNodeInfo.java 27 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromConnection.java 7 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java 10 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/ui/LoginDialog.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/admin/ads/TopologyCacheException.java
@@ -41,7 +41,7 @@
    GENERIC_CREATING_CONNECTION,
    /** Error reading the configuration of a particular server. */
    GENERIC_READING_SERVER,
    /** The DN provided in the DirContext of ADS is not of a global administrator. */
    /** The DN provided in the connection of ADS is not of a global administrator. */
    NOT_GLOBAL_ADMINISTRATOR,
    /** Not enough permissions to read the server configuration. */
    NO_PERMISSIONS,
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -54,7 +54,7 @@
import org.opends.guitools.controlpanel.task.Task;
import org.opends.guitools.controlpanel.task.Task.State;
import org.opends.guitools.controlpanel.task.Task.Type;
import org.opends.guitools.controlpanel.util.ConfigFromDirContext;
import org.opends.guitools.controlpanel.util.ConfigFromConnection;
import org.opends.guitools.controlpanel.util.ConfigFromFile;
import org.opends.guitools.controlpanel.util.ConfigReader;
import org.opends.guitools.controlpanel.util.Utilities;
@@ -316,7 +316,7 @@
   * @throws LdapException
   *           if there is a problem updating the connection pool.
   */
  public void setUserDataDirContext(ConnectionWrapper conn) throws LdapException
  public void setUserDataConnection(ConnectionWrapper conn) throws LdapException
  {
    if (userDataConn != null)
    {
@@ -334,7 +334,7 @@
   *
   * @return the connection to be used by the ControlPanelInfo to retrieve user data.
   */
  public ConnectionWrapper getUserDataDirContext()
  public ConnectionWrapper getUserDataConnection()
  {
    return userDataConn;
  }
@@ -453,7 +453,7 @@
        {
          if (isLocal)
          {
            connWrapper = Utilities.getAdminDirContext(this, lastWorkingBindDN, lastWorkingBindPwd);
            connWrapper = Utilities.getAdminConnection(this, lastWorkingBindDN, lastWorkingBindPwd);
          }
          else if (lastRemoteHostPort != null)
          {
@@ -507,13 +507,13 @@
      if (reader != null)
      {
        desc.setAuthenticated(reader instanceof ConfigFromDirContext);
        desc.setAuthenticated(reader instanceof ConfigFromConnection);
        desc.setJavaVersion(reader.getJavaVersion());
        desc.setOpenConnections(reader.getOpenConnections());
        desc.setTaskEntries(reader.getTaskEntries());
        if (reader instanceof ConfigFromDirContext)
        if (reader instanceof ConfigFromConnection)
        {
          ConfigFromDirContext rCtx = (ConfigFromDirContext)reader;
          ConfigFromConnection rCtx = (ConfigFromConnection)reader;
          desc.setRootMonitor(rCtx.getRootMonitor());
          desc.setEntryCachesMonitor(rCtx.getEntryCaches());
          desc.setJvmMemoryUsageMonitor(rCtx.getJvmMemoryUsage());
@@ -565,7 +565,7 @@
  private ConfigReader newRemoteConfigReader()
  {
    ConfigFromDirContext reader = new ConfigFromDirContext();
    ConfigFromConnection reader = new ConfigFromConnection();
    reader.setIsLocal(isLocal);
    reader.readConfiguration(connWrapper);
    return reader;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -34,7 +34,7 @@
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.guitools.controlpanel.util.ConfigFromDirContext;
import org.opends.guitools.controlpanel.util.ConfigFromConnection;
import org.opends.quicksetup.UserData;
import org.opends.server.tools.tasks.TaskEntry;
import org.opends.server.types.Schema;
@@ -694,8 +694,8 @@
      {
        String start = rootMonitor.getAttribute(START_DATE.getAttributeName()).firstValueAsString();
        String current = rootMonitor.getAttribute(CURRENT_DATE.getAttributeName()).firstValueAsString();
        Date startTime = ConfigFromDirContext.utcParser.parse(start);
        Date currentTime = ConfigFromDirContext.utcParser.parse(current);
        Date startTime = ConfigFromConnection.utcParser.parse(start);
        Date currentTime = ConfigFromConnection.utcParser.parse(current);
        return currentTime.getTime() - startTime.getTime();
      }
      catch (Throwable t)
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteIndexTask.java
@@ -256,10 +256,10 @@
   * Deletes an index. The code assumes that the server is running and that the
   * provided connection is active.
   *
   * @param connWrapper
   *          the connection to the server.
   * @param index
   *          the index to be deleted.
   * @param ctx
   *          the connection to the server.
   * @throws OpenDsException
   *           if an error occurs.
   */
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java
@@ -197,9 +197,9 @@
          // is what we use to clone connections and to launch scripts.
          // The environment will also be used if we want to reconnect.
          rebind(getInfo().getConnection());
          if (getInfo().getUserDataDirContext() != null)
          if (getInfo().getUserDataConnection() != null)
          {
            rebind(getInfo().getUserDataDirContext());
            rebind(getInfo().getUserDataConnection());
          }
        }
        state = State.FINISHED_SUCCESSFULLY;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/Task.java
@@ -677,7 +677,7 @@
  {
    ConnectionWrapper conn = useAdminConnector
        ? getInfo().getConnection()
        : getInfo().getUserDataDirContext();
        : getInfo().getUserDataConnection();
    List<String> args = new ArrayList<>();
    if (isServerRunning() && conn != null)
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java
@@ -1194,10 +1194,9 @@
          updateNumSubordinateHacker(desc);
          if (setConnection)
          {
            if (getInfo().getUserDataDirContext() == null)
            if (getInfo().getUserDataConnection() == null)
            {
              ConnectionWrapper connUserData = createUserDataDirContext(conn.getBindDn(), conn.getBindPassword());
              getInfo().setUserDataDirContext(connUserData);
              getInfo().setUserDataConnection(createUserDataConnection(conn.getBindDn(), conn.getBindPassword()));
            }
            Runnable runnable = new Runnable()
            {
@@ -1206,7 +1205,7 @@
              {
                ControlPanelInfo info = getInfo();
                controller.setConnections(
                    info.getServerDescriptor(), info.getConnection(), info.getUserDataDirContext());
                    info.getServerDescriptor(), info.getConnection(), info.getUserDataConnection());
                applyButtonClicked();
              }
            };
@@ -1391,13 +1390,13 @@
   * @throws ConfigReadException
   *           if an error occurs reading the configuration.
   */
  private ConnectionWrapper createUserDataDirContext(final DN bindDN, final String bindPassword)
  private ConnectionWrapper createUserDataConnection(final DN bindDN, final String bindPassword)
      throws IOException, ConfigReadException
  {
    createdUserDataConn = null;
    try
    {
      createdUserDataConn = Utilities.getUserDataDirContext(getInfo(), bindDN, bindPassword);
      createdUserDataConn = Utilities.getUserDataConnection(getInfo(), bindDN, bindPassword);
    }
    catch (LdapException e)
    {
@@ -1520,7 +1519,7 @@
      {
        logger.info(LocalizableMessage.raw("Accepting certificate presented by host " + host));
        getInfo().getTrustManager().acceptCertificate(chain, authType, host);
        createdUserDataConn = createUserDataDirContext(bindDN, bindPassword);
        createdUserDataConn = createUserDataConnection(bindDN, bindPassword);
      }
      else
      {
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
@@ -541,7 +541,7 @@
            if (isLocal)
            {
              usedHostPort = info.getAdminConnectorHostPort();
              conn = Utilities.getAdminDirContext(info, bindDn, bindPwd);
              conn = Utilities.getAdminConnection(info, bindDn, bindPwd);
            }
            else
            {
@@ -563,7 +563,7 @@
            closeInfoConnections();
            info.setIsLocal(isLocal);
            info.setConnection(conn);
            info.setUserDataDirContext(null);
            info.setUserDataConnection(null);
            info.regenerateDescriptor();
            return conn;
          } catch (Throwable t)
@@ -913,6 +913,6 @@
  private void closeInfoConnections()
  {
    StaticUtils.close(getInfo().getConnection());
    StaticUtils.close(getInfo().getUserDataDirContext());
    StaticUtils.close(getInfo().getUserDataConnection());
  }
}
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LoginPanel.java
@@ -188,9 +188,9 @@
          {
            ControlPanelInfo info = getInfo();
            usedHostPort = info.getAdminConnectorHostPort();
            conn = Utilities.getAdminDirContext(info, DN.valueOf(dn.getText()), String.valueOf(pwd.getPassword()));
            conn = Utilities.getAdminConnection(info, DN.valueOf(dn.getText()), String.valueOf(pwd.getPassword()));
            org.forgerock.util.Utils.closeSilently(info.getConnection(), info.getUserDataDirContext());
            org.forgerock.util.Utils.closeSilently(info.getConnection(), info.getUserDataConnection());
            try
            {
              Thread.sleep(500);
@@ -208,7 +208,7 @@
              }
            });
            info.setConnection(conn);
            info.setUserDataDirContext(null);
            info.setUserDataConnection(null);
            info.regenerateDescriptor();
            return conn;
          } catch (Throwable t)
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java
@@ -269,9 +269,9 @@
      }
    }
    private void createVLVIndexOnline(ConnectionWrapper ctx) throws Exception
    private void createVLVIndexOnline(ConnectionWrapper conn) throws Exception
    {
      final BackendCfgClient backend = ctx.getRootConfiguration().getBackend(backendName.getText());
      final BackendCfgClient backend = conn.getRootConfiguration().getBackend(backendName.getText());
      createBackendVLVIndexOnline((PluggableBackendCfgClient) backend);
    }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/RootMonitoringPanel.java
@@ -27,7 +27,7 @@
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.util.ConfigFromDirContext;
import org.opends.guitools.controlpanel.util.ConfigFromConnection;
import org.opends.guitools.controlpanel.util.Utilities;
import static org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes.*;
@@ -156,8 +156,8 @@
      {
        String start = sr.getAttribute(START_DATE.getAttributeName()).firstValueAsString();
        String current = sr.getAttribute(CURRENT_DATE.getAttributeName()).firstValueAsString();
        Date startTime = ConfigFromDirContext.utcParser.parse(start);
        Date currentTime = ConfigFromDirContext.utcParser.parse(current);
        Date startTime = ConfigFromConnection.utcParser.parse(start);
        Date currentTime = ConfigFromConnection.utcParser.parse(current);
        long upSeconds = (currentTime.getTime() - startTime.getTime()) / 1000;
        long upDays = upSeconds / 86400;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java
@@ -657,7 +657,7 @@
    /**
     * Modifies index using the provided connection.
     *
     * @param ctx
     * @param connWrapper
     *          the connection to be used to update the index configuration.
     * @throws Exception
     *           if there is an error updating the server.
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/BrowserNodeInfo.java
@@ -32,31 +32,28 @@
  /**
   * Returns  <CODE>true</CODE> if the displayed entry is the top entry of a
   * suffix and <CODE>false</CODE> otherwise.
   * @return <CODE>true</CODE> if the displayed entry is the top entry of a
   * suffix and <CODE>false</CODE> otherwise.
   * Returns whether the displayed entry is the top entry of a suffix.
   * @return {@code true} if the displayed entry is the top entry of a suffix,
   *         {@code false} otherwise.
   */
  boolean isSuffix();
  /**
   * Returns <CODE>true</CODE> if the displayed entry is the root node of the
   * server (the dn="" entry) and <CODE>false</CODE> otherwise.
   * @return <CODE>true</CODE> if the displayed entry is the root node of the
   * server (the dn="" entry) and <CODE>false</CODE> otherwise.
   * Returns whether the displayed entry is the root node of the
   * server (the dn="" entry)..
   * @return {@code true} if the displayed entry is the root node of the
   * server (the dn="" entry) and {@code false} otherwise.
   */
  boolean isRootNode();
  /**
   * Returns <CODE>true</CODE> if the displayed entry is not located on the
   * Returns whether the displayed entry is not located on the
   * current server. An entry is declared 'remote' when the host/port of
   * getURL() is different from the host/port of the DirContext associated to
   * the browser controller. Returns <CODE>false</CODE> otherwise.
   * @return <CODE>true</CODE> if the displayed entry is not located on the
   * current server. An entry is declared 'remote' when the host/port of
   * getURL() is different from the host/port of the DirContext associated to
   * the browser controller. Returns <CODE>false</CODE> otherwise.
   * getURL() is different from the host/port of the connection associated to
   * the browser controller.
   * @return {@code true} if the displayed entry is not located on the
   * current server, {@code false} otherwise.
   */
  boolean isRemote();
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromConnection.java
File was renamed from opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
@@ -86,11 +86,8 @@
import org.opends.server.types.OpenDsException;
import org.opends.server.util.ServerConstants;
/**
 * A class that reads the configuration and monitoring information using a
 * DirContext through LDAP.
 */
public class ConfigFromDirContext extends ConfigReader
/** A class that reads the configuration and monitoring information using an LDAP connection. */
public class ConfigFromConnection extends ConfigReader
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -2119,7 +2119,7 @@
   * or the provided credentials do not have enough rights.
   * @throws ConfigReadException if there is an error reading the configuration.
   */
  public static ConnectionWrapper getAdminDirContext(ControlPanelInfo controlInfo, DN bindDN, String pwd)
  public static ConnectionWrapper getAdminConnection(ControlPanelInfo controlInfo, DN bindDN, String pwd)
      throws IOException, ConfigReadException
  {
    return createConnection(controlInfo.getAdminConnectorHostPort(), LDAPS, bindDN, pwd, controlInfo);
@@ -2138,7 +2138,7 @@
   * or the provided credentials do not have enough rights.
   * @throws ConfigReadException if there is an error reading the configuration.
   */
  public static ConnectionWrapper getUserDataDirContext(ControlPanelInfo controlInfo,
  public static ConnectionWrapper getUserDataConnection(ControlPanelInfo controlInfo,
      DN bindDN, String pwd) throws IOException, ConfigReadException
  {
    if (controlInfo.connectUsingStartTLS())
@@ -2413,7 +2413,7 @@
      }
      Long l = Long.parseLong(monitoringValue);
      Date date = new Date(l);
      return ConfigFromDirContext.formatter.format(date);
      return ConfigFromConnection.formatter.format(date);
    }
    else if (attr.isTime())
    {
@@ -2427,8 +2427,8 @@
    {
      try
      {
        Date date = ConfigFromDirContext.utcParser.parse(monitoringValue);
        return ConfigFromDirContext.formatter.format(date);
        Date date = ConfigFromConnection.utcParser.parse(monitoringValue);
        return ConfigFromConnection.formatter.format(date);
      }
      catch (Throwable t)
      {
opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/ui/LoginDialog.java
@@ -388,7 +388,7 @@
            throw new ApplicationException(ReturnCode.APPLICATION_ERROR,
                ERR_COULD_NOT_FIND_VALID_LDAPURL.get(), null);
          }
          connWrapper = org.opends.guitools.controlpanel.util.Utilities.getAdminDirContext(info, dn, pwd);
          connWrapper = org.opends.guitools.controlpanel.util.Utilities.getAdminConnection(info, dn, pwd);
          return true; // server is running
        }
        catch (LdapException e)
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -117,7 +117,7 @@
import org.opends.admin.ads.util.ServerLoader;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
import org.opends.guitools.controlpanel.util.ConfigFromDirContext;
import org.opends.guitools.controlpanel.util.ConfigFromConnection;
import org.opends.guitools.controlpanel.util.ConfigFromFile;
import org.opends.guitools.controlpanel.util.ControlPanelLog;
import org.opends.guitools.controlpanel.util.ProcessReader;
@@ -1979,7 +1979,7 @@
  {
    List<TaskEntry> taskEntries = new ArrayList<>();
    List<Exception> exceptions = new ArrayList<>();
    ConfigFromDirContext cfg = new ConfigFromDirContext();
    ConfigFromConnection cfg = new ConfigFromConnection();
    cfg.updateTaskInformation(conn, exceptions, taskEntries);
    for (Exception ode : exceptions)
    {
opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
@@ -303,7 +303,7 @@
      if (managementContextOpened)
      {
        try (ConnectionWrapper conn = Utilities.getAdminDirContext(controlInfo, bindDn, bindPwd))
        try (ConnectionWrapper conn = Utilities.getAdminConnection(controlInfo, bindDn, bindPwd))
        {
          controlInfo.setConnection(conn);
          controlInfo.regenerateDescriptor();