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

Jean-Noël Rouvignac
18.53.2016 c30a14be35ba387e61b960740f6afc1b9774bb3d
opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java
@@ -44,13 +44,11 @@
import java.util.Set;
import java.util.TreeSet;
import javax.naming.directory.DirContext;
import javax.naming.ldap.InitialLdapContext;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.admin.ads.util.ConnectionWrapper;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.BackendMessages;
import org.opends.messages.CoreMessages;
@@ -65,9 +63,6 @@
import org.forgerock.opendj.config.ManagedObjectDefinition;
import org.forgerock.opendj.config.ManagedObjectNotFoundException;
import org.forgerock.opendj.config.PropertyException;
import org.forgerock.opendj.config.client.ManagementContext;
import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
import org.forgerock.opendj.config.client.ldap.LDAPManagementContext;
import org.forgerock.opendj.server.config.client.BackendCfgClient;
import org.forgerock.opendj.server.config.client.CryptoManagerCfgClient;
import org.forgerock.opendj.server.config.client.ReplicationDomainCfgClient;
@@ -307,21 +302,17 @@
  /**
   * Deletes a backend on the server.
   * @param ctx the connection to the server.
   * @param connWrapper the connection to the server.
   * @param backendName the name of the backend to be deleted.
   * @param serverDisplay the server display.
   * @throws ApplicationException if something goes wrong.
   */
  public void deleteBackend(InitialLdapContext ctx, String backendName,
      String serverDisplay)
  throws ApplicationException
  public void deleteBackend(ConnectionWrapper connWrapper, String backendName, String serverDisplay)
      throws ApplicationException
  {
    try
    {
      ManagementContext mCtx = LDAPManagementContext.createFromContext(
          JNDIDirContextAdaptor.adapt(ctx));
      RootCfgClient root = mCtx.getRootConfiguration();
      root.removeBackend(backendName);
      connWrapper.getRootConfiguration().removeBackend(backendName);
    }
    catch (Throwable t)
    {
@@ -356,7 +347,7 @@
  /**
   * Creates a database backend on the server.
   *
   * @param ctx
   * @param connWrapper
   *          the connection to the server.
   * @param backendName
   *          the name of the backend to be created.
@@ -369,14 +360,13 @@
   * @throws ApplicationException
   *           if something goes wrong.
   */
  public void createBackend(DirContext ctx, String backendName, Set<String> baseDNs, String serverDisplay,
      ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg> backendType)
  public void createBackend(ConnectionWrapper connWrapper, String backendName, Set<String> baseDNs,
      String serverDisplay, ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg> backendType)
      throws ApplicationException
  {
    try
    {
      ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(ctx));
      RootCfgClient root = mCtx.getRootConfiguration();
      RootCfgClient root = connWrapper.getRootConfiguration();
      BackendCfgClient backend = root.createBackend(backendType, backendName, null);
      backend.setEnabled(true);
      backend.setBaseDN(toByteStrings(baseDNs));
@@ -403,25 +393,19 @@
  /**
   * Sets the base DNs on a given backend.
   * @param ctx the connection to the server.
   * @param connWrapper the connection to the server.
   * @param backendName the name of the backend where the base Dns must be
   * defined.
   * @param baseDNs the list of base DNs to be defined on the server.
   * @param serverDisplay the server display.
   * @throws ApplicationException if something goes wrong.
   */
  public void setBaseDns(InitialLdapContext ctx,
      String backendName,
      Set<String> baseDNs,
      String serverDisplay)
  throws ApplicationException
  public void setBaseDns(ConnectionWrapper connWrapper, String backendName, Set<String> baseDNs, String serverDisplay)
      throws ApplicationException
  {
    try
    {
      ManagementContext mCtx = LDAPManagementContext.createFromContext(
          JNDIDirContextAdaptor.adapt(ctx));
      RootCfgClient root = mCtx.getRootConfiguration();
      BackendCfgClient backend = root.getBackend(backendName);
      BackendCfgClient backend = connWrapper.getRootConfiguration().getBackend(backendName);
      backend.setBaseDN(toByteStrings(baseDNs));
      backend.commit();
    }
@@ -436,7 +420,7 @@
  /**
   * Configures the replication on a given server.
   * @param remoteCtx the connection to the server where we want to configure
   * @param connWrapper the connection to the server where we want to configure
   * the replication.
   * @param replicationServers a Map where the key value is the base dn and
   * the value is the list of replication servers for that base dn (or domain).
@@ -453,7 +437,7 @@
   * @return a ConfiguredReplication object describing what has been configured.
   */
  public ConfiguredReplication configureReplication(
      InitialLdapContext remoteCtx, Map<String,Set<String>> replicationServers,
      ConnectionWrapper connWrapper, Map<String,Set<String>> replicationServers,
      int replicationPort, boolean useSecureReplication, String serverDisplay,
      Set<Integer> usedReplicationServerIds, Set<Integer> usedServerIds)
  throws ApplicationException
@@ -464,9 +448,7 @@
    boolean secureReplicationEnabled;
    try
    {
      ManagementContext mCtx = LDAPManagementContext.createFromContext(
          JNDIDirContextAdaptor.adapt(remoteCtx));
      RootCfgClient root = mCtx.getRootConfiguration();
      RootCfgClient root = connWrapper.getRootConfiguration();
      /*
       * Configure Synchronization plugin.
@@ -654,7 +636,7 @@
  /**
   * Configures the replication on a given server.
   *
   * @param remoteCtx
   * @param connWrapper
   *          the connection to the server where we want to configure the
   *          replication.
   * @param replConf
@@ -664,13 +646,12 @@
   * @throws ApplicationException
   *           if something goes wrong.
   */
  public void unconfigureReplication(InitialLdapContext remoteCtx, ConfiguredReplication replConf, String serverDisplay)
      throws ApplicationException
  public void unconfigureReplication(ConnectionWrapper connWrapper, ConfiguredReplication replConf,
      String serverDisplay) throws ApplicationException
  {
    try
    {
      ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(remoteCtx));
      RootCfgClient root = mCtx.getRootConfiguration();
      RootCfgClient root = connWrapper.getRootConfiguration();
      final String syncProvider = "Multimaster Synchronization";
      // Unconfigure Synchronization plugin.
      if (replConf.isSynchProviderCreated())