From 75fa1207356d3048f707fd0e15ca4a2f9fcaed5c Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 03 Aug 2016 16:05:42 +0000
Subject: [PATCH] Code cleanup, added toStrings()

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java            |   28 +++-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java             |  145 +++++++++-----------
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java                      |   49 +++---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java             |   79 ++++------
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BaseDNDescriptor.java             |   32 ++-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/LDAPEntryTableCellRenderer.java |   54 +++----
 6 files changed, 183 insertions(+), 204 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java
index cde9139..a64bbf3 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java
@@ -16,12 +16,15 @@
  */
 package org.opends.guitools.controlpanel.datamodel;
 
+import java.util.HashSet;
 import java.util.Objects;
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
+import org.forgerock.opendj.ldap.DN;
 import org.forgerock.opendj.ldap.responses.SearchResultEntry;
+import org.forgerock.util.Utils;
 import org.opends.admin.ads.ADSContext;
 
 /** The class that describes the backend configuration. */
@@ -121,7 +124,6 @@
     return vlvIndexes;
   }
 
-
   /**
    * Returns the index objects associated with the backend.
    * @return the index objects associated with the backend.
@@ -231,8 +233,8 @@
    * An convenience method to know if the provided ID corresponds to a
    * configuration backend or not.
    * @param id the backend ID to analyze
-   * @return <CODE>true</CODE> if the the id corresponds to a configuration
-   * backend and <CODE>false</CODE> otherwise.
+   * @return {@code true} if the the id corresponds to a configuration backend,
+   *         {@code false} otherwise.
    */
   private boolean isConfigBackend(String id)
   {
@@ -247,8 +249,7 @@
 
   /**
    * Tells whether this is a configuration backend or not.
-   * @return <CODE>true</CODE> if this is a configuration backend and
-   * <CODE>false</CODE> otherwise.
+   * @return {@code true} if this is a configuration backend, {@code false} otherwise.
    */
   public boolean isConfigBackend()
   {
@@ -287,8 +288,7 @@
 
   /**
    * Tells whether this backend is enabled or not.
-   * @return <CODE>true</CODE> if this is backend is enabled
-   * <CODE>false</CODE> otherwise.
+   * @return {@code true} if this is backend is enabled, {@code false} otherwise.
    */
   public boolean isEnabled()
   {
@@ -312,4 +312,18 @@
   {
     return pluggableType;
   }
+
+  @Override
+  public String toString()
+  {
+    Set<DN> baseDNs = new HashSet<>();
+    for (BaseDNDescriptor baseDn : this.baseDns)
+    {
+      baseDNs.add(baseDn.getDn());
+    }
+    return getClass().getSimpleName()
+        + "(backendID=" + backendID
+        + ", isEnabled=" + isEnabled
+        + ", baseDNs=" + Utils.joinAsString(",", baseDNs) + ")";
+  }
 }
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BaseDNDescriptor.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BaseDNDescriptor.java
index e6fe548..b21242f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BaseDNDescriptor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BaseDNDescriptor.java
@@ -14,12 +14,10 @@
  * Copyright 2008-2011 Sun Microsystems, Inc.
  * Portions Copyright 2011-2016 ForgeRock AS.
  */
-
 package org.opends.guitools.controlpanel.datamodel;
 
 import org.forgerock.opendj.ldap.DN;
 
-
 /**
  * This class is used to represent a Base DN / Replica and is aimed to be
  * used by the classes in the BackendTableModel class.
@@ -37,12 +35,12 @@
     DISABLED
   }
 
+  private final DN baseDn;
+  private BackendDescriptor backend;
+  private Type type;
   private int nEntries;
   private int missingChanges;
-  private BackendDescriptor backend;
   private long ageOfOldestMissingChange;
-  private Type type;
-  private final DN baseDn;
   private int replicaID = -1;
 
   private int hashCode;
@@ -105,9 +103,9 @@
   private boolean backendIdEqual(BaseDNDescriptor desc)
   {
     // Only compare the backend IDs.  In this context is enough
-    return getBackend() != null
-        && desc.getBackend() != null
-        && getBackend().getBackendID().equals(desc.getBackend().getBackendID());
+    final BackendDescriptor b1 = getBackend();
+    final BackendDescriptor b2 = desc.getBackend();
+    return b1 != null && b2 != null && b1.getBackendID().equals(b2.getBackendID());
   }
 
   @Override
@@ -218,7 +216,6 @@
     return backend;
   }
 
-
   /**
    * Sets the backend of this base DN.
    * @param backend the backend for this base DN.
@@ -277,9 +274,9 @@
    */
   private void recalculateHashCode()
   {
-    hashCode = (getType().toString() + getAgeOfOldestMissingChange() +
-          getDn() +
-        getBackend().getBackendID() + getMissingChanges()).hashCode();
+    String s = ""
+        + getType() + getAgeOfOldestMissingChange() + getDn() + getBackend().getBackendID() + getMissingChanges();
+    hashCode = s.hashCode();
   }
 
   private int compare(int i1, int i2)
@@ -313,4 +310,15 @@
       return -1;
     }
   }
+
+  @Override
+  public String toString()
+  {
+    return getClass().getSimpleName()
+        + "(baseDN=" + baseDn
+        + ", nbEntries=" + nEntries
+        + ", missingChanges=" + missingChanges
+        + ", ageOfOldestMissingChange=" + ageOfOldestMissingChange
+        + ")";
+  }
 }
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
index 6890912..b6abb0c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -184,23 +184,20 @@
   /**
    * Tells whether an index must be reindexed or not.
    * @param index the index.
-   * @return <CODE>true</CODE> if the index must be reindexed and
-   * <CODE>false</CODE> otherwise.
+   * @return {@code true} if the index must be reindexed, {@code false} otherwise.
    */
   public boolean mustReindex(AbstractIndexDescriptor index)
   {
-    boolean mustReindex = false;
     for (AbstractIndexDescriptor i : modifiedIndexes)
     {
       if (i.getName().equals(index.getName()) &&
           i.getBackend().getBackendID().equals(
               index.getBackend().getBackendID()))
       {
-        mustReindex = true;
-        break;
+        return true;
       }
     }
-    return mustReindex;
+    return false;
   }
 
   /**
@@ -217,8 +214,8 @@
   /**
    * Unregisters a modified index.
    * @param index the index.
-   * @return <CODE>true</CODE> if the index is found in the list of modified
-   * indexes and <CODE>false</CODE> otherwise.
+   * @return {@code true} if the index is found in the list of modified
+   * indexes, {@code false} otherwise.
    */
   public boolean unregisterModifiedIndex(AbstractIndexDescriptor index)
   {
@@ -257,8 +254,7 @@
     {
       // Compare only the Backend ID, since the backend object attached to
       // the registered index might have changed (for instance the number of
-      // entries).  Relying on the backend ID to identify the backend is
-      // safe.
+      // entries).  Relying on the backend ID to identify the backend is safe.
       if (index.getBackend().getBackendID().equalsIgnoreCase(backendName))
       {
         toDelete.add(index);
@@ -411,7 +407,7 @@
     desc.setIsLocal(isLocal);
     if (isLocal)
     {
-      desc.setOpenDSVersion(DynamicConstants.FULL_VERSION_STRING);
+      desc.setOpenDJVersion(DynamicConstants.FULL_VERSION_STRING);
       String installPath = Utilities.getInstallPathFromClasspath();
       desc.setInstallPath(installPath);
       desc.setInstancePath(Utils.getInstancePathFromInstallPath(installPath));
@@ -526,7 +522,7 @@
           desc.setJvmMemoryUsageMonitor(rCtx.getJvmMemoryUsage());
           desc.setSystemInformationMonitor(rCtx.getSystemInformation());
           desc.setWorkQueueMonitor(rCtx.getWorkQueue());
-          desc.setOpenDSVersion(rCtx.getVersionMonitor().getAttribute("fullVersion").firstValueAsString());
+          desc.setOpenDJVersion(rCtx.getVersionMonitor().getAttribute("fullVersion").firstValueAsString());
           String installPath = rCtx.getSystemInformation().getAttribute("installPath").firstValueAsString();
           if (installPath != null)
           {
@@ -631,8 +627,7 @@
   /**
    * Removes a configuration change listener.
    * @param listener the listener.
-   * @return <CODE>true</CODE> if the listener is found and <CODE>false</CODE>
-   * otherwise.
+   * @return {@code true} if the listener is found, {@code false} otherwise.
    */
   public boolean removeConfigChangeListener(ConfigChangeListener listener)
   {
@@ -651,8 +646,7 @@
   /**
    * Removes a backup creation listener.
    * @param listener the listener.
-   * @return <CODE>true</CODE> if the listener is found and <CODE>false</CODE>
-   * otherwise.
+   * @return {@code true} if the listener is found, {@code false} otherwise.
    */
   public boolean removeBackupCreatedListener(BackupCreatedListener listener)
   {
@@ -671,8 +665,7 @@
   /**
    * Removes a backend populated listener.
    * @param listener the listener.
-   * @return <CODE>true</CODE> if the listener is found and <CODE>false</CODE>
-   * otherwise.
+   * @return {@code true} if the listener is found, {@code false} otherwise.
    */
   public boolean removeBackendPopulatedListener(
       BackendPopulatedListener listener)
@@ -692,8 +685,7 @@
   /**
    * Removes an index modification listener.
    * @param listener the listener.
-   * @return <CODE>true</CODE> if the listener is found and <CODE>false</CODE>
-   * otherwise.
+   * @return {@code true} if the listener is found, {@code false} otherwise.
    */
   public boolean removeIndexModifiedListener(IndexModifiedListener listener)
   {
@@ -826,7 +818,7 @@
 
   /**
    * Gets the LDAPS URL based in what is read in the configuration. It
-   * returns <CODE>null</CODE> if no LDAPS URL was found.
+   * returns {@code null} if no LDAPS URL was found.
    * @return the LDAPS URL to be used to connect to the server.
    */
   public String getLDAPSURL()
@@ -836,7 +828,7 @@
 
   /**
    * Gets the Administration Connector URL based in what is read in the
-   * configuration. It returns <CODE>null</CODE> if no Administration
+   * configuration. It returns {@code null} if no Administration
    * Connector URL was found.
    * @return the Administration Connector URL to be used to connect
    * to the server.
@@ -845,9 +837,8 @@
   {
     if (isLocal)
     {
-      // If the user set isLocal to true, we want to return the
-      // localAdminConnectorURL (in particular if regenerateDescriptor has not
-      // been called).
+      // If the user set isLocal to true, we want to return the localAdminConnectorURL
+      // (in particular if regenerateDescriptor has not been called).
       return localAdminConnectorURL;
     }
     return adminConnectorURL;
@@ -855,7 +846,7 @@
 
   /**
    * Gets the Administration Connector URL based in what is read in the local
-   * configuration. It returns <CODE>null</CODE> if no Administration
+   * configuration. It returns {@code null} if no Administration
    * Connector URL was found.
    * @return the Administration Connector URL to be used to connect
    * to the local server.
@@ -866,8 +857,8 @@
   }
 
   /**
-   * Gets the LDAP URL based in what is read in the configuration. It
-   * returns <CODE>null</CODE> if no LDAP URL was found.
+   * Gets the LDAP URL based in what is read in the configuration.
+   * It returns {@code null} if no LDAP URL was found.
    * @return the LDAP URL to be used to connect to the server.
    */
   public String getLDAPURL()
@@ -877,7 +868,7 @@
 
   /**
    * Gets the Start TLS URL based in what is read in the configuration. It
-   * returns <CODE>null</CODE> if no Start TLS URL is found.
+   * returns {@code null} if no Start TLS URL is found.
    * @return the Start TLS URL to be used to connect to the server.
    */
   public String getStartTLSURL()
@@ -887,7 +878,7 @@
 
   /**
    * Returns the LDAP URL to be used to connect to a given ServerDescriptor
-   * using a certain protocol. It returns <CODE>null</CODE> if URL for the
+   * using a certain protocol. It returns {@code null} if URL for the
    * protocol is not found.
    * @param server the server descriptor.
    * @param protocol the protocol to be used.
@@ -936,11 +927,10 @@
     switch (protocol)
     {
     case LDAP:
+    case LDAP_STARTTLS:
       return "ldap";
     case LDAPS:
       return "ldaps";
-    case LDAP_STARTTLS:
-      return "ldap";
     case JMX:
       return "jmx";
     case JMXS:
@@ -952,8 +942,7 @@
 
   /**
    * Returns the Administration Connector URL.
-   * It returns <CODE>null</CODE> if URL for the
-   * protocol is not found.
+   * It returns {@code null} if URL for the protocol is not found.
    * @param server the server descriptor.
    * @return the Administration Connector URL.
    */
@@ -980,8 +969,8 @@
 
   /**
    * Tells whether we must connect to the server using Start TLS.
-   * @return <CODE>true</CODE> if we must connect to the server using Start TLS
-   * and <CODE>false</CODE> otherwise.
+   * @return {@code true} if we must connect to the server using Start TLS
+   * and {@code false} otherwise.
    */
   public boolean connectUsingStartTLS()
   {
@@ -990,8 +979,7 @@
 
   /**
    * Tells whether we must connect to the server using LDAPS.
-   * @return <CODE>true</CODE> if we must connect to the server using LDAPS
-   * and <CODE>false</CODE> otherwise.
+   * @return {@code true} if we must connect to the server using LDAPS, {@code false} otherwise.
    */
   public boolean connectUsingLDAPS()
   {
@@ -1074,10 +1062,9 @@
   }
 
   /**
-   * Returns <CODE>true</CODE> if we are trying to manage the local host and
-   * <CODE>false</CODE> otherwise.
-   * @return <CODE>true</CODE> if we are trying to manage the local host and
-   * <CODE>false</CODE> otherwise.
+   * Returns whether we are trying to manage the local host.
+   * @return {@code true} if we are trying to manage the local host,
+   * {@code false} otherwise.
    */
   public boolean isLocal()
   {
@@ -1103,8 +1090,8 @@
   }
 
   /**
-   * Returns the pooling period in miliseconds.
-   * @return the pooling period in miliseconds.
+   * Returns the pooling period in milliseconds.
+   * @return the pooling period in milliseconds.
    */
   public long getPoolingPeriod()
   {
@@ -1145,8 +1132,8 @@
    * path if it is local).
    * @param server the server.
    * @param task the task to be analyzed.
-   * @return <CODE>true</CODE> if the provided task is running on the provided
-   * server and <CODE>false</CODE> otherwise.
+   * @return {@code true} if the provided task is running on the provided server,
+   * {@code false} otherwise.
    */
   private boolean isRunningOnServer(ServerDescriptor server, Task task)
   {
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
index a91d1a1..2647945 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -16,7 +16,8 @@
  */
 package org.opends.guitools.controlpanel.datamodel;
 
-import static org.opends.server.util.SchemaUtils.getElementDefinitionWithFileName;
+import static org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes.*;
+import static org.opends.server.util.SchemaUtils.*;
 
 import java.io.File;
 import java.io.IOException;
@@ -26,6 +27,7 @@
 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 
 import org.forgerock.opendj.ldap.DN;
@@ -39,8 +41,6 @@
 
 import com.forgerock.opendj.util.OperatingSystem;
 
-import static org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes.*;
-
 /**
  * This is just a class used to provide a data model describing what the
  * StatusPanelDialog will show to the user.
@@ -57,7 +57,7 @@
   private Set<DN> administrativeUsers = new HashSet<>();
   private String installPath;
   private String instancePath;
-  private String openDSVersion;
+  private String openDJVersion;
   private String javaVersion;
   private ArrayList<Exception> exceptions = new ArrayList<>();
   private boolean isWindowsServiceEnabled;
@@ -119,8 +119,7 @@
 
   /**
    * Returns whether the schema is enabled or not.
-   * @return <CODE>true</CODE> if the schema is enabled and <CODE>false</CODE>
-   * otherwise.
+   * @return {@code true} if the schema is enabled, {@code false} otherwise.
    */
   public boolean isSchemaEnabled()
   {
@@ -129,8 +128,7 @@
 
   /**
    * Sets whether the schema is enabled or not.
-   * @param isSchemaEnabled <CODE>true</CODE> if the schema is enabled and
-   * <CODE>false</CODE> otherwise.
+   * @param isSchemaEnabled {@code true} if the schema is enabled, {@code false} otherwise.
    */
   public void setSchemaEnabled(boolean isSchemaEnabled)
   {
@@ -256,16 +254,16 @@
    */
   public String getOpenDSVersion()
   {
-    return openDSVersion;
+    return openDJVersion;
   }
 
   /**
    * Sets the version of the server.
    * @param openDSVersion the version of the server.
    */
-  public void setOpenDSVersion(String openDSVersion)
+  public void setOpenDJVersion(String openDSVersion)
   {
-    this.openDSVersion = openDSVersion;
+    this.openDJVersion = openDSVersion;
   }
 
   /**
@@ -321,14 +319,14 @@
         && desc.isLocal() == isLocal()
         && desc.isAuthenticated() == isAuthenticated()
         && desc.getOpenConnections() == getOpenConnections()
-        && areEqual(getInstallPath(), desc.getInstallPath())
-        && areEqual(getInstancePath(), desc.getInstancePath())
-        && areEqual(getJavaVersion(), desc.getJavaVersion())
-        && areEqual(getOpenDSVersion(), desc.getOpenDSVersion())
-        && areEqual(desc.getAdministrativeUsers(), getAdministrativeUsers())
-        && areEqual(desc.getConnectionHandlers(), getConnectionHandlers())
-        && areEqual(desc.getBackends(), getBackends())
-        && areEqual(desc.getExceptions(), getExceptions())
+        && Objects.equals(getInstallPath(), desc.getInstallPath())
+        && Objects.equals(getInstancePath(), desc.getInstancePath())
+        && Objects.equals(getJavaVersion(), desc.getJavaVersion())
+        && Objects.equals(getOpenDSVersion(), desc.getOpenDSVersion())
+        && Objects.equals(desc.getAdministrativeUsers(), getAdministrativeUsers())
+        && Objects.equals(desc.getConnectionHandlers(), getConnectionHandlers())
+        && Objects.equals(desc.getBackends(), getBackends())
+        && Objects.equals(desc.getExceptions(), getExceptions())
         && desc.isSchemaEnabled() == isSchemaEnabled()
         && areSchemasEqual(getSchema(), desc.getSchema())
         && (!OperatingSystem.isWindows() || desc.isWindowsServiceEnabled() == isWindowsServiceEnabled())
@@ -338,16 +336,15 @@
   @Override
   public int hashCode()
   {
-    String s = installPath + openDSVersion + javaVersion + isAuthenticated;
+    String s = installPath + openDJVersion + javaVersion + isAuthenticated;
     return status.hashCode() + openConnections + s.hashCode();
   }
 
   /**
    * Return whether we were authenticated when retrieving the information of
    * this ServerStatusDescriptor.
-   * @return <CODE>true</CODE> if we were authenticated when retrieving the
-   * information of this ServerStatusDescriptor and <CODE>false</CODE>
-   * otherwise.
+   * @return {@code true} if we were authenticated when retrieving the
+   * information of this ServerStatusDescriptor and {@code false} otherwise.
    */
   public boolean isAuthenticated()
   {
@@ -438,10 +435,8 @@
   }
 
   /**
-   * Returns <CODE>true</CODE> if we are trying to manage the local host and
-   * <CODE>false</CODE> otherwise.
-   * @return <CODE>true</CODE> if we are trying to manage the local host and
-   * <CODE>false</CODE> otherwise.
+   * Returns whether we are trying to manage the local host.
+   * @return {@code true} if we are trying to manage the local host, {@code false} otherwise.
    */
   public boolean isLocal()
   {
@@ -481,8 +476,7 @@
 
   /**
    * Tells whether the windows service is enabled or not.
-   * @return <CODE>true</CODE> if the windows service is enabled and
-   * <CODE>false</CODE> otherwise.
+   * @return {@code true} if the windows service is enabled, {@code false} otherwise.
    */
   public boolean isWindowsServiceEnabled()
   {
@@ -491,8 +485,8 @@
 
   /**
    * Sets whether the windows service is enabled or not.
-   * @param isWindowsServiceEnabled <CODE>true</CODE> if the windows service is
-   * enabled and <CODE>false</CODE> otherwise.
+   * @param isWindowsServiceEnabled {@code true} if the windows service is
+   * enabled, {@code false} otherwise.
    */
   public void setWindowsServiceEnabled(boolean isWindowsServiceEnabled)
   {
@@ -520,12 +514,10 @@
 
   /**
    * Method used to compare schemas.
-   * Returns <CODE>true</CODE> if the two schemas are equal and
-   * <CODE>false</CODE> otherwise.
+   * Returns whether the two schemas are equal.
    * @param schema1 the first schema.
    * @param schema2 the second schema.
-   * @return <CODE>true</CODE> if the two schemas are equal and
-   * <CODE>false</CODE> otherwise.
+   * @return {@code true} if the two schemas are equal, {@code false} otherwise.
    */
   public static boolean areSchemasEqual(Schema schema1, Schema schema2)
   {
@@ -544,8 +536,8 @@
 
     return areAttributeTypesEqual(schema1, schema2)
         && areObjectClassesEqual(schema1, schema2)
-        && areEqual(schema1.getMatchingRules(), schema2.getMatchingRules())
-        && areEqual(schema1.getSyntaxes(), schema2.getSyntaxes());
+        && Objects.equals(schema1.getMatchingRules(), schema2.getMatchingRules())
+        && Objects.equals(schema1.getSyntaxes(), schema2.getSyntaxes());
   }
 
   private static boolean areAttributeTypesEqual(Schema schema1, Schema schema2)
@@ -591,12 +583,10 @@
 
   /**
    * Method used to compare attributes defined in the schema.
-   * Returns <CODE>true</CODE> if the two schema attributes are equal and
-   * <CODE>false</CODE> otherwise.
+   * Returns whether the two schema attributes are equal.
    * @param schema1 the first schema attribute.
    * @param schema2 the second schema attribute.
-   * @return <CODE>true</CODE> if the two schema attributes are equal and
-   * <CODE>false</CODE> otherwise.
+   * @return {@code true} if the two schema attributes are equal, {@code false} otherwise.
    */
   private static boolean areAttributesEqual(AttributeType attr1, AttributeType attr2)
   {
@@ -607,39 +597,37 @@
         && attr1.isObsolete() == attr2.isObsolete()
         && attr1.isOperational() == attr2.isOperational()
         && attr1.isSingleValue() == attr2.isSingleValue()
-        && areEqual(attr1.getApproximateMatchingRule(), attr2.getApproximateMatchingRule())
-        && areEqual(getElementDefinitionWithFileName(attr1), getElementDefinitionWithFileName(attr2))
-        && areEqual(attr1.getDescription(), attr2.getDescription())
-        && areEqual(attr1.getEqualityMatchingRule(), attr2.getEqualityMatchingRule())
-        && areEqual(attr1.getOrderingMatchingRule(), attr2.getOrderingMatchingRule())
-        && areEqual(attr1.getSubstringMatchingRule(), attr2.getSubstringMatchingRule())
-        && areEqual(attr1.getSuperiorType(), attr2.getSuperiorType())
-        && areEqual(attr1.getSyntax(), attr2.getSyntax())
-        && areEqual(attr1.getSyntax().getOID(), attr2.getSyntax().getOID())
-        && areEqual(attr1.getExtraProperties().keySet(), attr2.getExtraProperties().keySet())
-        && areEqual(toSet(attr1.getNames()), toSet(attr2.getNames()));
+        && Objects.equals(attr1.getApproximateMatchingRule(), attr2.getApproximateMatchingRule())
+        && Objects.equals(getElementDefinitionWithFileName(attr1), getElementDefinitionWithFileName(attr2))
+        && Objects.equals(attr1.getDescription(), attr2.getDescription())
+        && Objects.equals(attr1.getEqualityMatchingRule(), attr2.getEqualityMatchingRule())
+        && Objects.equals(attr1.getOrderingMatchingRule(), attr2.getOrderingMatchingRule())
+        && Objects.equals(attr1.getSubstringMatchingRule(), attr2.getSubstringMatchingRule())
+        && Objects.equals(attr1.getSuperiorType(), attr2.getSuperiorType())
+        && Objects.equals(attr1.getSyntax(), attr2.getSyntax())
+        && Objects.equals(attr1.getSyntax().getOID(), attr2.getSyntax().getOID())
+        && Objects.equals(attr1.getExtraProperties().keySet(), attr2.getExtraProperties().keySet())
+        && Objects.equals(toSet(attr1.getNames()), toSet(attr2.getNames()));
   }
 
   /**
    * Method used to compare objectclasses defined in the schema.
-   * Returns <CODE>true</CODE> if the two schema objectclasses are equal and
-   * <CODE>false</CODE> otherwise.
+   * Returns whether the two schema objectclasses are equal.
    * @param schema1 the first schema objectclass.
    * @param schema2 the second schema objectclass.
-   * @return <CODE>true</CODE> if the two schema objectclasses are equal and
-   * <CODE>false</CODE> otherwise.
+   * @return {@code true} if the two schema objectclasses are equal, {@code false} otherwise.
    */
   private static boolean areObjectClassesEqual(ObjectClass oc1, ObjectClass oc2)
   {
     return oc1.getOID().equals(oc2.getOID())
-        && areEqual(getElementDefinitionWithFileName(oc1), getElementDefinitionWithFileName(oc2))
-        && areEqual(oc1.getDescription(), oc2.getDescription())
-        && areEqual(oc1.getObjectClassType(), oc2.getObjectClassType())
-        && areEqual(oc1.getDeclaredOptionalAttributes(), oc2.getDeclaredOptionalAttributes())
-        && areEqual(oc1.getDeclaredRequiredAttributes(), oc2.getDeclaredRequiredAttributes())
-        && areEqual(oc1.getSuperiorClasses(), oc2.getSuperiorClasses())
-        && areEqual(oc1.getExtraProperties().keySet(), oc2.getExtraProperties().keySet())
-        && areEqual(toSet(oc1.getNames()), toSet(oc2.getNames()));
+        && Objects.equals(getElementDefinitionWithFileName(oc1), getElementDefinitionWithFileName(oc2))
+        && Objects.equals(oc1.getDescription(), oc2.getDescription())
+        && Objects.equals(oc1.getObjectClassType(), oc2.getObjectClassType())
+        && Objects.equals(oc1.getDeclaredOptionalAttributes(), oc2.getDeclaredOptionalAttributes())
+        && Objects.equals(oc1.getDeclaredRequiredAttributes(), oc2.getDeclaredRequiredAttributes())
+        && Objects.equals(oc1.getSuperiorClasses(), oc2.getSuperiorClasses())
+        && Objects.equals(oc1.getExtraProperties().keySet(), oc2.getExtraProperties().keySet())
+        && Objects.equals(toSet(oc1.getNames()), toSet(oc2.getNames()));
   }
 
   private static Set<Object> toSet(Iterable<?> iterable)
@@ -653,24 +641,6 @@
   }
 
   /**
-   * Commodity method used to compare two objects that might be
-   * <CODE>null</CODE>.
-   * @param o1 the first object.
-   * @param o2 the second object.
-   * @return if both objects are <CODE>null</CODE> returns true.  If not returns
-   * <CODE>true</CODE> if both objects are equal according to the Object.equal
-   * method and <CODE>false</CODE> otherwise.
-   */
-  private static boolean areEqual(Object o1, Object o2)
-  {
-    if (o1 != null)
-    {
-      return o1.equals(o2);
-    }
-    return o2 == null;
-  }
-
-  /**
    * Returns the admin connector.
    * @return the admin connector.
    */
@@ -808,4 +778,15 @@
   {
     return workQueue;
   }
+
+  @Override
+  public String toString()
+  {
+    return getClass().getSimpleName()
+        + "(hostName=" + hostName
+        + ", openDJVersion=" + openDJVersion
+        + ", status=" + status
+        + ", isLocal=" + isLocal
+        + ", backends=" + backends + ")";
+  }
 }
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
index d4af5b9..3dda6d7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
@@ -597,19 +597,20 @@
       final DN theDN = DN.valueOf(dn);
       for (final BackendDescriptor backend : existingBackends)
       {
-        for (final BaseDNDescriptor baseDN : backend.getBaseDns())
+        for (final BaseDNDescriptor baseDNDescriptor : backend.getBaseDns())
         {
-          if (baseDN.getDn().equals(theDN))
+          DN baseDN = baseDNDescriptor.getDn();
+          if (baseDN.equals(theDN))
           {
             return invalidBaseDNValue(dn, ERR_BASE_DN_ALREADY_EXISTS.get(dn), errors);
           }
-          else if (baseDN.getDn().isSuperiorOrEqualTo(theDN) && backendName.equalsIgnoreCase(backend.getBackendID()))
+          else if (baseDN.isSuperiorOrEqualTo(theDN) && backendName.equalsIgnoreCase(backend.getBackendID()))
           {
-            return invalidBaseDNValue(dn, ERR_BASE_DN_ANCESTOR_EXISTS.get(baseDN.getDn()), errors);
+            return invalidBaseDNValue(dn, ERR_BASE_DN_ANCESTOR_EXISTS.get(baseDN), errors);
           }
-          else if (theDN.isSuperiorOrEqualTo(baseDN.getDn()) && backendName.equalsIgnoreCase(backend.getBackendID()))
+          else if (theDN.isSuperiorOrEqualTo(baseDN) && backendName.equalsIgnoreCase(backend.getBackendID()))
           {
-            return invalidBaseDNValue(dn, ERR_BASE_DN_DN_IS_ANCESTOR_OF.get(baseDN.getDn()), errors);
+            return invalidBaseDNValue(dn, ERR_BASE_DN_DN_IS_ANCESTOR_OF.get(baseDN), errors);
           }
         }
       }
@@ -676,7 +677,6 @@
     {
       return backendName.toString();
     }
-
     return null;
   }
 
@@ -695,7 +695,7 @@
   {
     private final Set<String> backendSet;
     private final String newBaseDN;
-    private int progressAfterConfigurationUpdate = -1;
+    private final int progressAfterConfigurationUpdate;
 
     /**
      * The constructor of the task.
@@ -711,31 +711,36 @@
       backendSet = new HashSet<>();
       backendSet.add(getBackendName());
       newBaseDN = baseDN.getText();
+      progressAfterConfigurationUpdate = computeProgress();
+    }
 
+    private int computeProgress()
+    {
       if (onlyCreateBaseEntry.isSelected())
       {
-        progressAfterConfigurationUpdate = 40;
+        return 40;
       }
       else if (leaveDatabaseEmpty.isSelected())
       {
-        progressAfterConfigurationUpdate = 90;
+        return 90;
       }
       else if (importAutomaticallyGenerated.isSelected())
       {
         int nEntries = Integer.parseInt(numberOfEntries.getText().trim());
         if (nEntries < 500)
         {
-          progressAfterConfigurationUpdate = 30;
+          return 30;
         }
         else if (nEntries < 3000)
         {
-          progressAfterConfigurationUpdate = 15;
+          return 15;
         }
         else
         {
-          progressAfterConfigurationUpdate = 5;
+          return 5;
         }
       }
+      return -1;
     }
 
     @Override
@@ -787,7 +792,6 @@
       {
         return getCommandLinePath(isLocal() ? "import-ldif" : "ldapmodify");
       }
-
       return null;
     }
 
@@ -869,22 +873,16 @@
 
     private void updateConfigurationOffline() throws Exception
     {
-      boolean configHandlerUpdated = false;
+      stopPoolingAndInitializeConfiguration();
       try
       {
-        stopPoolingAndInitializeConfiguration();
-        configHandlerUpdated = true;
-
         performTask();
         printTaskDone();
         refreshProgressBar();
       }
       finally
       {
-        if (configHandlerUpdated)
-        {
-          startPoolingAndInitializeConfiguration();
-        }
+        startPoolingAndInitializeConfiguration();
       }
     }
 
@@ -922,10 +920,11 @@
       if (!isServerRunning())
       {
         createBackendOffline(backendName);
-        return;
       }
-
-      createBackendOnline(backendName);
+      else
+      {
+        createBackendOnline(backendName);
+      }
     }
 
     private void createBackendOffline(String backendName) throws OpenDsException
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/LDAPEntryTableCellRenderer.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/LDAPEntryTableCellRenderer.java
index 1d4b6aa..decfd8c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/LDAPEntryTableCellRenderer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/renderer/LDAPEntryTableCellRenderer.java
@@ -73,8 +73,7 @@
     }
     if (isPassword(table, row, column))
     {
-      return getStringValue(table, OBFUSCATED_VALUE, isSelected,
-          hasFocus, row, column);
+      return getStringValue(table, OBFUSCATED_VALUE, isSelected, hasFocus, row, column);
     }
     else if (value instanceof ObjectClassValue)
     {
@@ -82,34 +81,25 @@
       ocPanel.setLockIconVisible(!cellEditable);
       ocPanel.setEditButtonVisible(cellEditable);
       ocPanel.setValue((ObjectClassValue)value);
-      if (hasFocus)
-      {
-        ocPanel.setBorder(getDefaultFocusBorder(table, value, isSelected, row, column));
-      }
-      else
-      {
-        ocPanel.setBorder(defaultBorder);
-      }
+      ocPanel.setBorder(hasFocus
+          ? getDefaultFocusBorder(table, value, isSelected, row, column)
+          : defaultBorder);
       updateComponent(ocPanel, table, row, column, isSelected);
       return ocPanel;
     }
     else if (value instanceof byte[] || value instanceof BinaryValue)
     {
+      boolean isImage = isImage(table, row, column);
       if (value instanceof byte[])
       {
-        if (((byte[])value).length > 0)
-        {
-          binaryPanel.setValue((byte[])value, isImage(table, row, column));
-        }
-        else
-        {
-          binaryPanel.setValue((byte[])null, isImage(table, row, column));
-        }
+        byte[] bytes = (byte[]) value;
+        binaryPanel.setValue(bytes.length > 0 ? bytes : null, isImage);
       }
       else
       {
-        binaryPanel.setValue((BinaryValue)value, isImage(table, row, column));
+        binaryPanel.setValue((BinaryValue) value, isImage);
       }
+
       if (!table.isCellEditable(row, column))
       {
         binaryPanel.setLockIconVisible(true);
@@ -120,15 +110,10 @@
         binaryPanel.setLockIconVisible(false);
         binaryPanel.setEditButtonText(INFO_CTRL_PANEL_EDIT_BUTTON_LABEL.get());
       }
-      if (hasFocus)
-      {
-        binaryPanel.setBorder(getDefaultFocusBorder(table, value, isSelected,
-            row, column));
-      }
-      else
-      {
-        binaryPanel.setBorder(defaultBorder);
-      }
+
+      binaryPanel.setBorder(hasFocus
+          ? getDefaultFocusBorder(table, value, isSelected, row, column)
+          : defaultBorder);
       updateComponent(binaryPanel, table, row, column, isSelected);
       return binaryPanel;
     }
@@ -173,19 +158,24 @@
   {
     super.getTableCellRendererComponent(table, value, isSelected,
         hasFocus, row, column);
+    lockLabel.setIcon(getIcon(table, row, column, isSelected));
+    return this;
+  }
+
+  private ImageIcon getIcon(JTable table, int row, int column, boolean isSelected)
+  {
     if (table.isCellEditable(row, column) && !isSelected)
     {
-      lockLabel.setIcon(null);
+      return null;
     }
     else if (column == 1 && !table.isCellEditable(row, column))
     {
-      lockLabel.setIcon(lockIcon);
+      return lockIcon;
     }
     else
     {
-      lockLabel.setIcon(null);
+      return null;
     }
-    return this;
   }
 
   private boolean isPassword(JTable table, int row, int col)

--
Gitblit v1.10.0