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

Jean-Noel Rouvignac
15.44.2015 ef171d1e8556bc183ee08e9f79c24e41c99a8976
opendj-server-legacy/src/main/java/org/opends/admin/ads/ServerDescriptor.java
@@ -58,9 +58,7 @@
import org.opends.server.config.ConfigConstants;
import org.opends.server.schema.SchemaConstants;
/**
 * The object of this class represent an OpenDS server.
 */
/** The object of this class represent an OpenDS server. */
public class ServerDescriptor
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
@@ -109,10 +107,7 @@
    IS_REPLICATION_ENABLED,
    /** The associated value is a Boolean. */
    IS_REPLICATION_SECURE,
    /**
     * List of servers specified in the Replication Server configuration.
     * This is a Set of String.
     */
    /** List of servers specified in the Replication Server configuration. This is a Set of String. */
    EXTERNAL_REPLICATION_SERVERS,
    /** The associated value is an Integer. */
    REPLICATION_SERVER_ID,
@@ -255,12 +250,8 @@
   */
  public boolean isReplicationSecure()
  {
    if (isReplicationServer())
    {
      return Boolean.TRUE.equals(serverProperties.get(
          ServerProperty.IS_REPLICATION_SECURE));
    }
    return false;
    return isReplicationServer()
        && Boolean.TRUE.equals(serverProperties.get(ServerProperty.IS_REPLICATION_SECURE));
  }
  /**
@@ -281,11 +272,11 @@
  public String getHostName()
  {
    String host = (String)serverProperties.get(ServerProperty.HOST_NAME);
    if (host == null)
    if (host != null)
    {
      return (String) adsProperties.get(ADSContext.ServerProperty.HOST_NAME);
      return host;
    }
    return host;
    return (String) adsProperties.get(ADSContext.ServerProperty.HOST_NAME);
  }
  /**
@@ -421,7 +412,7 @@
      for (ADSContext.ServerProperty prop : enabledAttrs)
      {
        Object v = adsProperties.get(prop);
        if ((v != null) && "true".equalsIgnoreCase(String.valueOf(v)))
        if (v != null && "true".equalsIgnoreCase(String.valueOf(v)))
        {
          ADSContext.ServerProperty portProp = getPortProperty(prop);
          Object p = adsProperties.get(portProp);
@@ -495,7 +486,7 @@
  public String getId()
  {
    StringBuilder buf = new StringBuilder();
    if (serverProperties.size() > 0)
    if (!serverProperties.isEmpty())
    {
      buf.append(serverProperties.get(ServerProperty.HOST_NAME));
      ServerProperty [] props =
@@ -544,8 +535,7 @@
   */
  public byte[] getInstancePublicKeyCertificate()
  {
    return((byte[])
          serverProperties.get(ServerProperty.INSTANCE_PUBLIC_KEY_CERTIFICATE));
    return (byte[]) serverProperties.get(ServerProperty.INSTANCE_PUBLIC_KEY_CERTIFICATE);
  }
  /**
@@ -637,12 +627,11 @@
    ArrayList<?> array = (ArrayList<?>)serverProperties.get(
        ServerProperty.STARTTLS_ENABLED);
    boolean startTLSEnabled = false;
    if ((array != null) && !array.isEmpty())
    if (array != null && !array.isEmpty())
    {
      startTLSEnabled = Boolean.TRUE.equals(array.get(array.size() -1));
    }
    adsProperties.put(ADSContext.ServerProperty.STARTTLS_ENABLED,
        startTLSEnabled ? "true" : "false");
    adsProperties.put(ADSContext.ServerProperty.STARTTLS_ENABLED, Boolean.toString(startTLSEnabled));
    adsProperties.put(ADSContext.ServerProperty.ID, getHostPort(true));
    adsProperties.put(ADSContext.ServerProperty.INSTANCE_PUBLIC_KEY_CERTIFICATE,
                      getInstancePublicKeyCertificate());
@@ -1230,8 +1219,7 @@
      }
      catch (NameNotFoundException x) {
        if (0 == i) {
          /* Poke CryptoManager to initialize truststore. Note the special
             attribute in the request. */
          // Poke CryptoManager to initialize truststore. Note the special attribute in the request.
          final Attributes attrs = new BasicAttributes();
          final Attribute oc = new BasicAttribute("objectclass");
          oc.add("top");
@@ -1279,7 +1267,7 @@
  /**
   Seeds the bound instance's local ads-truststore with a set of instance
   key-pair public key certificates. The result is the instance will trust any
   instance posessing the private key corresponding to one of the public-key
   instance possessing the private key corresponding to one of the public-key
   certificates. This trust is necessary at least to initialize replication,
   which uses the trusted certificate entries in the ads-truststore for server
   authentication.
@@ -1310,9 +1298,7 @@
      keyAttrs.put(new BasicAttribute(
              ADSContext.ServerProperty.INSTANCE_PUBLIC_KEY_CERTIFICATE.
                      getAttributeName() + ";binary", keyEntry.getValue()));
      final LdapName keyDn = new LdapName((new StringBuilder(rdnAttr.getID()))
              .append("=").append(Rdn.escapeValue(rdnAttr.get())).append(",")
              .append(TRUSTSTORE_DN).toString());
      final LdapName keyDn = new LdapName(rdnAttr.getID() + "=" + Rdn.escapeValue(rdnAttr.get()) + "," + TRUSTSTORE_DN);
      try {
        ctx.createSubcontext(keyDn, keyAttrs).close();
      }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java
@@ -40,10 +40,13 @@
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicReference;
import javax.naming.ldap.InitialLdapContext;
import javax.swing.SwingUtilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
@@ -51,13 +54,14 @@
import org.opends.guitools.controlpanel.ui.ProgressDialog;
import org.opends.guitools.controlpanel.util.ConfigReader;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
import org.opends.server.admin.client.ldap.LDAPManagementContext;
import org.opends.server.admin.server.ServerManagementContext;
import org.opends.server.admin.std.client.*;
import org.opends.server.admin.std.client.LocalDBBackendCfgClient;
import org.opends.server.admin.std.client.ReplicationDomainCfgClient;
import org.opends.server.admin.std.client.ReplicationSynchronizationProviderCfgClient;
import org.opends.server.admin.std.client.RootCfgClient;
import org.opends.server.admin.std.server.ReplicationDomainCfg;
import org.opends.server.admin.std.server.ReplicationSynchronizationProviderCfg;
import org.opends.server.admin.std.server.RootCfg;
@@ -68,10 +72,7 @@
import org.opends.server.types.DN;
import org.opends.server.types.OpenDsException;
/**
 * The task used to delete a set of base DNs or backends.
 *
 */
/** The task used to delete a set of base DNs or backends. */
public class DeleteBaseDNAndBackendTask extends Task
{
  private Set<String> backendSet;
@@ -131,14 +132,7 @@
  /** {@inheritDoc} */
  public Type getType()
  {
    if (baseDNsToDelete.size() > 0)
    {
      return Type.DELETE_BASEDN;
    }
    else
    {
      return Type.DELETE_BACKEND;
    }
    return !baseDNsToDelete.isEmpty() ? Type.DELETE_BASEDN : Type.DELETE_BACKEND;
  }
  /** {@inheritDoc} */
@@ -152,7 +146,7 @@
  {
    StringBuilder sb = new StringBuilder();
    if (baseDNsToDelete.size() > 0)
    if (!baseDNsToDelete.isEmpty())
    {
      ArrayList<String> dns = new ArrayList<>();
      for (Set<BaseDNDescriptor> set : baseDNsToDelete.values())
@@ -280,8 +274,8 @@
                getObfuscatedCommandLineArguments(
                    getDSConfigCommandLineArguments(baseDNs));
              args.removeAll(getConfigCommandLineArguments());
              printEquivalentCommandLine(getConfigCommandLinePath(baseDNs),
                  args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_BASE_DN.get());
              printEquivalentCommandLine(getConfigCommandLinePath(), args,
                  INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_BASE_DN.get());
            }
          });
        }
@@ -361,8 +355,8 @@
                getObfuscatedCommandLineArguments(
                    getDSConfigCommandLineArguments(backend));
              args.removeAll(getConfigCommandLineArguments());
              printEquivalentCommandLine(getConfigCommandLinePath(backend),
                 args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_BACKEND.get());
              printEquivalentCommandLine(getConfigCommandLinePath(), args,
                  INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_BACKEND.get());
            }
          });
        }
@@ -532,41 +526,17 @@
  }
  /**
   * Returns the path of the command line to be used to delete the specified
   * backend.
   * @param backend the backend to be deleted.
   * @return the path of the command line to be used to delete the specified
   * backend.
   * Returns the path of the command line to be used.
   *
   * @return the path of the command line to be used
   */
  private String getConfigCommandLinePath(BackendDescriptor backend)
  private String getConfigCommandLinePath()
  {
    if (isServerRunning())
    {
      return getCommandLinePath("dsconfig");
    }
    else
    {
      return null;
    }
  }
  /**
   * Returns the path of the command line to be used to delete the specified
   * base DNs.
   * @param baseDNs the base DNs to be deleted.
   * @return the path of the command line to be used to delete the specified
   * base DNs.
   */
  private String getConfigCommandLinePath(Set<BaseDNDescriptor> baseDNs)
  {
    if (isServerRunning())
    {
      return getCommandLinePath("dsconfig");
    }
    else
    {
      return null;
    }
    return null;
  }
  /** {@inheritDoc} */
@@ -641,7 +611,7 @@
  {
    if (baseDN.getType() == BaseDNDescriptor.Type.REPLICATED)
    {
      final String[] domainName = {null};
      final AtomicReference<String> domainName = new AtomicReference<>();
      try
      {
@@ -666,15 +636,13 @@
            String[] domains = sync.listReplicationDomains();
            if (domains != null)
            {
              for (int i=0; i<domains.length; i++)
              for (String dName : domains)
              {
                ReplicationDomainCfgClient domain =
                  sync.getReplicationDomain(domains[i]);
                DN dn = domain.getBaseDN();
                if (dn.equals(baseDN.getDn()))
                ReplicationDomainCfgClient domain = sync.getReplicationDomain(dName);
                if (baseDN.getDn().equals(domain.getBaseDN()))
                {
                  domainName[0] = domains[i];
                  sync.removeReplicationDomain(domains[i]);
                  domainName.set(dName);
                  sync.removeReplicationDomain(dName);
                  sync.commit();
                  break;
                }
@@ -701,14 +669,13 @@
            String[] domains = sync.listReplicationDomains();
            if (domains != null)
            {
              for (int i=0; i<domains.length; i++)
              for (String dName : domains)
              {
                ReplicationDomainCfg domain =
                  sync.getReplicationDomain(domains[i]);
                ReplicationDomainCfg domain = sync.getReplicationDomain(dName);
                DN dn = domain.getBaseDN();
                if (dn.equals(baseDN.getDn()))
                {
                  domainName[0] = domains[i];
                  domainName.set(dName);
                  DN entryDN = domain.dn();
                  Utilities.deleteConfigSubtree(
                      DirectoryServer.getConfigHandler(), entryDN);
@@ -721,9 +688,8 @@
      }
      finally
      {
        // This is not super clean, but this way we calculate the domain name
        // only once.
        if (isServerRunning() && (domainName[0] != null))
        // This is not super clean, but this way we calculate the domain name only once.
        if (isServerRunning() && domainName.get() != null)
        {
          SwingUtilities.invokeLater(new Runnable()
          {
@@ -731,12 +697,11 @@
            {
              List<String> args =
                getObfuscatedCommandLineArguments(
                    getCommandLineArgumentsToDisableReplication(domainName[0]));
                    getCommandLineArgumentsToDisableReplication(domainName.get()));
              args.removeAll(getConfigCommandLineArguments());
              args.add(getNoPropertiesFileArgument());
              printEquivalentCommandLine(
                  getConfigCommandLinePath(baseDN.getBackend()),
                  args, INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_DOMAIN.get(baseDN.getDn()));
              printEquivalentCommandLine(getConfigCommandLinePath(), args,
                  INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_DOMAIN.get(baseDN.getDn()));
              }
          });
        }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractNewEntryPanel.java
@@ -24,7 +24,6 @@
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
@@ -35,6 +34,7 @@
import javax.swing.SwingUtilities;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.guitools.controlpanel.browser.BrowserController;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.task.NewEntryTask;
@@ -42,7 +42,6 @@
import org.opends.guitools.controlpanel.ui.nodes.BasicNode;
import org.opends.guitools.controlpanel.util.BackgroundTask;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.util.LDIFException;
@@ -51,21 +50,14 @@
/**
 * Abstract class used to re-factor some code among the different panels that
 * are used to create a new entry.
 *
 */
public abstract class AbstractNewEntryPanel extends StatusGenericPanel
{
  private static final long serialVersionUID = 6894546787832469213L;
  /**
   * The parent node that was selected when the user clicked on the new entry
   * action.
   */
  /** The parent node that was selected when the user clicked on the new entry action. */
  protected BasicNode parentNode;
  /**
   * The browser controller.
   */
  /** The browser controller. */
  protected BrowserController controller;
  /**
@@ -243,12 +235,10 @@
   */
  protected Entry getEntry() throws LDIFException, IOException
  {
    Entry entry;
    LDIFImportConfig ldifImportConfig = null;
    try
    {
      String ldif = getLDIF();
      if (ldif.trim().length() == 0)
      {
        throw new LDIFException(ERR_LDIF_REPRESENTATION_REQUIRED.get());
@@ -256,18 +246,16 @@
      ldifImportConfig = new LDIFImportConfig(new StringReader(ldif));
      LDIFReader reader = new LDIFReader(ldifImportConfig);
      entry = reader.readEntry(checkSchema());
      Entry entry = reader.readEntry(checkSchema());
      if (entry == null)
      {
        throw new LDIFException(ERR_LDIF_REPRESENTATION_REQUIRED.get());
      }
      else
      if (entry.getObjectClasses().isEmpty())
      {
        if (entry.getObjectClasses().size() == 0)
        {
          throw new LDIFException(ERR_OBJECTCLASS_FOR_ENTRY_REQUIRED.get());
        }
        throw new LDIFException(ERR_OBJECTCLASS_FOR_ENTRY_REQUIRED.get());
      }
      return entry;
    }
    finally
    {
@@ -276,7 +264,6 @@
        ldifImportConfig.close();
      }
    }
    return entry;
  }
  /**
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
@@ -804,7 +804,7 @@
    for (DefaultMutableTreeNode parent : categoryNodes)
    {
      if (nodes.get(i).size() == 0)
      if (nodes.get(i).isEmpty())
      {
        if (parent.getParent() != null)
        {
opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/Installer.java
@@ -337,7 +337,7 @@
    else if (step == REMOTE_REPLICATION_PORTS)
    {
      return isVisible(SUFFIXES_OPTIONS, userData)
          && userData.getRemoteWithNoReplicationPort().size() > 0
          && !userData.getRemoteWithNoReplicationPort().isEmpty()
          && userData.getSuffixesToReplicateOptions().getType() ==
              SuffixesToReplicateOptions.Type.REPLICATE_WITH_EXISTING_SUFFIXES;
    }
@@ -694,7 +694,7 @@
      switch (getUserData().getSuffixesToReplicateOptions().getType())
      {
      case REPLICATE_WITH_EXISTING_SUFFIXES:
        if (getUserData().getRemoteWithNoReplicationPort().size() > 0)
        if (!getUserData().getRemoteWithNoReplicationPort().isEmpty())
        {
          return Step.REMOTE_REPLICATION_PORTS;
        }
opendj-server-legacy/src/main/java/org/opends/server/admin/doc/ConfigGuideGeneration.java
@@ -488,7 +488,7 @@
    propertiesLinkTable(basicProps, advancedProps);
    // basic properties
    if (basicProps.size() > 0) {
    if (!basicProps.isEmpty()) {
      heading4("Basic Properties");
      for ( PropertyDefinition prop : basicProps.values()) {
        generateProperty(mo, prop);
@@ -498,7 +498,7 @@
    }
    // advanced properties
    if (advancedProps.size() > 0) {
    if (!advancedProps.isEmpty()) {
      heading4("Advanced Properties");
      for ( PropertyDefinition prop : advancedProps.values()) {
        generateProperty(mo, prop);
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VerifyJob.java
@@ -294,7 +294,7 @@
      else
      {
        logger.info(NOTE_VERIFY_FINAL_STATUS, keyCount, errorCount, totalTime/1000, rate);
        if (entryLimitMap.size() > 0)
        if (!entryLimitMap.isEmpty())
        {
          logger.debug(INFO_VERIFY_ENTRY_LIMIT_STATS_HEADER);
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VerifyJob.java
@@ -299,7 +299,7 @@
      else
      {
        logger.info(NOTE_VERIFY_FINAL_STATUS, keyCount, errorCount, totalTime/1000, rate);
        if (entryLimitMap.size() > 0)
        if (!entryLimitMap.isEmpty())
        {
          logger.debug(INFO_VERIFY_ENTRY_LIMIT_STATS_HEADER);
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
@@ -444,7 +444,7 @@
          add(attrBuilder, "*", fractionalAllClassesAttributes);
      // Add attribute values for specific classes
      if (fractionalSpecificClassesAttributes.size() > 0)
      if (!fractionalSpecificClassesAttributes.isEmpty())
      {
        for (Map.Entry<String, Set<String>> specific
            : fractionalSpecificClassesAttributes.entrySet())
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/MultimasterReplication.java
@@ -202,7 +202,7 @@
    {
      final LDAPReplicationDomain domain = new LDAPReplicationDomain(
          configuration, updateToReplayQueue, dsrsShutdownSync);
      if (domains.size() == 0)
      if (domains.isEmpty())
      {
        // Create the threads that will process incoming update messages
        createReplayThreads();
@@ -255,7 +255,7 @@
    }
    // No replay threads running if no replication need
    if (domains.size() == 0) {
    if (domains.isEmpty()) {
      stopReplayThreads();
    }
  }
@@ -790,7 +790,7 @@
    // Stop threads then restart new number of threads
    stopReplayThreads();
    replayThreadNumber = numUpdateRepayThread;
    if (domains.size() > 0)
    if (!domains.isEmpty())
    {
      createReplayThreads();
    }
opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -2425,7 +2425,7 @@
    {
      mpThread.setPeriod(period);
    }
    else if (connectedDSs.size() > 0 || connectedRSs.size() > 0)
    else if (!connectedDSs.isEmpty() || !connectedRSs.isEmpty())
    {
      // Requested to start monitoring publishers with provided period value
      startMonitoringPublisher();
opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationBroker.java
@@ -841,7 +841,7 @@
          connectionError = true;
          connectPhaseLock.notify();
          if (rsInfos.size() > 0)
          if (!rsInfos.isEmpty())
          {
            logger.warn(WARN_COULD_NOT_FIND_CHANGELOG, serverId, baseDN,
                Utils.joinAsString(", ", rsInfos.keySet()));
opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationMonitor.java
@@ -162,7 +162,7 @@
  private void addMonitorData(List<Attribute> attributes, String attrType,
      Map<Integer, Integer> serverIdToNb)
  {
    if (serverIdToNb.size() > 0)
    if (!serverIdToNb.isEmpty())
    {
      AttributeType type = DirectoryServer.getDefaultAttributeType(attrType);
      final AttributeBuilder builder = new AttributeBuilder(type, attrType);
opendj-server-legacy/src/test/java/org/opends/server/core/SearchOperationTestCase.java
@@ -355,7 +355,7 @@
    assertEquals(resultEntry.getObjectClasses().size(), 0);
    assertEquals(resultEntry.getUserAttributes().size(), 0);
    assertTrue(resultEntry.getOperationalAttributes().size() > 0);
    assertTrue(!resultEntry.getOperationalAttributes().isEmpty());
  }
  @Test
@@ -365,7 +365,7 @@
    Entry resultEntry = getSingleEntry(searchOperation);
    assertEquals(resultEntry.getObjectClasses(), testEntry.getObjectClasses());
    assertTrue(resultEntry.getOperationalAttributes().size() > 0);
    assertTrue(!resultEntry.getOperationalAttributes().isEmpty());
    // Search results contain objectClass as an attribute.
    assertEquals(resultEntry.getUserAttributes().size(),