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

david_page
29.37.2007 13cf7a78d32db416c8d5fddf7beea2b4f4901633
In Installer#updateADS::

1. replace getNewServerAdsProperties(getUserData()) with ServerDescriptor to:
a. align with new ReplicationCliMain
b. allow implementing publicKeyCertificate entry independent of CLI/GUI.

2. inline getRemoteServerProperties (single caller)
1 files modified
85 ■■■■ changed files
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java 85 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -1875,15 +1875,13 @@
    InitialLdapContext localCtx = null; // Bound to local server.
    ADSContext adsContext = null; // Bound to ADS host (via one of above).
    /* Outer try-catch-finally to convert ADSContextException to
       ApplicationException and clean up JNDI contexts. */
    /* Outer try-catch-finally to convert occurences of NamingException and
       ADSContextException to ApplicationException and clean up JNDI contexts.*/
    try
    {
      if (remoteServer)
      {
        /* In case the user specified an existing topology... */
        try
        {
          String ldapUrl = getLdapUrl(auth);
          String dn = auth.getDn();
          String pwd = auth.getPwd();
@@ -1909,34 +1907,19 @@
               INFO_PROGRESS_CREATING_ADS_ON_REMOTE.get(getHostDisplay(auth))));
            adsContext.createAdminData(null);
            adsContext.registerServer(
                    getRemoteServerProperties(adsContext.getDirContext()));
          ServerDescriptor server
                  = ServerDescriptor.createStandalone(remoteCtx);
          server.updateAdsPropertiesWithServerProperties();
          adsContext.registerServer(server.getAdsProperties());
            createdRemoteAds = true;
            notifyListeners(getFormattedDone());
            notifyListeners(getLineBreak());
            checkAbort();
          }
        }
        catch (NoPermissionException x)
        {
          throw new ApplicationException(
                  ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR,
                  INFO_CANNOT_CONNECT_TO_REMOTE_PERMISSIONS.get(
                          getHostDisplay(auth)), x);
        }
        catch (NamingException ne)
        {
          throw new ApplicationException(
                  ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR,
                  INFO_CANNOT_CONNECT_TO_REMOTE_GENERIC.get(
                          getHostDisplay(auth), ne.getLocalizedMessage()), ne);
        }
      }
      /* Act on local server depending on if using remote or local ADS */
      notifyListeners(getFormattedWithPoints(INFO_PROGRESS_CREATING_ADS.get()));
      try
      {
        localCtx = createLocalContext();
        if (remoteServer)
        {
@@ -1950,20 +1933,12 @@
          adsContext = new ADSContext(localCtx); // adsContext owns localCtx
          adsContext.createAdminData(null);
        }
      }
      catch (NamingException t)
      {
        Message failedMsg = getThrowableMsg(
                INFO_ERROR_CONNECTING_TO_LOCAL.get(), t);
        throw new ApplicationException(
                ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR,
                failedMsg, t);
      }
      assert null != adsContext ; // Bound either to local or remote ADS.
      /* Register new server in ADS. */
      if (0 != adsContext.registerOrUpdateServer(getNewServerAdsProperties(
              getUserData())))
      ServerDescriptor server = ServerDescriptor.createStandalone(localCtx);
      server.updateAdsPropertiesWithServerProperties();
      if (0 != adsContext.registerOrUpdateServer(server.getAdsProperties()))
      {
        LOG.log(Level.WARNING, "Server was already registered. Updating " +
                "server registration.");
@@ -2005,6 +1980,41 @@
        }
      }
    }
    catch (NoPermissionException ne)
    {
      if (remoteServer)
      {
        throw new ApplicationException(
                ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR,
                INFO_CANNOT_CONNECT_TO_REMOTE_PERMISSIONS.get(
                        getHostDisplay(auth)), ne);
      }
      else
      {
        // TODO: INFO for local PERMISSIONS exception?
        Message failedMsg = getThrowableMsg(
                INFO_ERROR_CONNECTING_TO_LOCAL.get(), ne);
        throw new ApplicationException(
                ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR,
                failedMsg, ne);
      }
    }
    catch (NamingException ne)
    {
      if (remoteServer)
      {
        throw new ApplicationException(
                ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR,
                INFO_CANNOT_CONNECT_TO_REMOTE_GENERIC.get(
                        getHostDisplay(auth), ne.getLocalizedMessage()), ne);
      }
      else
      {
        throw new ApplicationException(
                ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR,
                getThrowableMsg(INFO_ERROR_CONNECTING_TO_LOCAL.get(), ne), ne);
      }
    }
    catch (ADSContextException ace)
    {
      throw new ApplicationException(
@@ -3295,13 +3305,6 @@
    return 15 * 1024 * 1024;
  }
  private Map<ADSContext.ServerProperty, Object> getRemoteServerProperties(
      InitialLdapContext ctx) throws NamingException
  {
    ServerDescriptor server = ServerDescriptor.createStandalone(ctx);
    server.updateAdsPropertiesWithServerProperties();
    return server.getAdsProperties();
  }
  /**
   * Update the UserInstallData with the contents we discover in the ADS.