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

Valery Kharseko
16 hours ago ebb19c5816399b83c42b8f9194dbf3d9296975a3
opendj-server-legacy/src/main/java/org/opends/admin/ads/SuffixDescriptor.java
@@ -13,6 +13,7 @@
 *
 * Copyright 2008 Sun Microsystems, Inc.
 * Portions Copyright 2015-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.admin.ads;
@@ -107,6 +108,13 @@
  }
  @Override
  public boolean equals(Object o)
  {
    return this == o
        || (o instanceof SuffixDescriptor && getId().equals(((SuffixDescriptor) o).getId()));
  }
  @Override
  public int hashCode()
  {
    return getId().hashCode();
@@ -114,16 +122,28 @@
  /**
   * Returns an Id that is unique for this suffix.
   * <p>
   * The id is built from the suffix DN and the ids of the servers holding a replica of it.
   * The server ids are sorted because {@link #getReplicas()} hands out a {@link HashSet} of
   * {@link ReplicaDescriptor}s, which do not override {@code hashCode()}: without the sort,
   * two descriptors describing the same suffix on the same servers could produce different
   * ids depending on the iteration order.
   *
   * @return an Id that is unique for this suffix.
   */
  public String getId()
  {
    StringBuilder buf = new StringBuilder();
    buf.append(getDN());
    Set<String> serverIds = new TreeSet<>();
    for (ReplicaDescriptor replica : getReplicas())
    {
      buf.append("-").append(replica.getServer().getId());
      serverIds.add(replica.getServer().getId());
    }
    StringBuilder buf = new StringBuilder();
    buf.append(getDN());
    for (String serverId : serverIds)
    {
      buf.append("-").append(serverId);
    }
    return buf.toString();
  }