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

Jean-Noel Rouvignac
19.21.2014 9fe74c0b75f4be20ca49e005850e7a8775e3bc0a
Code cleanup.
Used UCDetector + AutoRefactor.
3 files modified
234 ■■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/core/RootDseWorkflowTopology.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/WorkflowResultCode.java 173 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/networkgroups/NetworkGroupNamingContexts.java 59 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/RootDseWorkflowTopology.java
@@ -51,7 +51,7 @@
   * The naming contexts known by the root DSE. These naming contexts
   * are defined in the scope of a network group.
   */
  private NetworkGroupNamingContexts namingContexts;
  private final NetworkGroupNamingContexts namingContexts;
  /**
   * Creates a workflow node to handle the root DSE entry.
opendj3-server-dev/src/server/org/opends/server/core/WorkflowResultCode.java
@@ -34,15 +34,14 @@
 * This class implements the workflow result code. The workflow result code
 * contains an LDAP result code along with an LDAP error message.
 */
public class WorkflowResultCode
class WorkflowResultCode
{
  // The global result code.
  /** The global result code. */
  private ResultCode resultCode = ResultCode.UNDEFINED;
  // The global error message.
  /** The global error message. */
  private LocalizableMessageBuilder errorMessage = new LocalizableMessageBuilder(LocalizableMessage.EMPTY);
  /**
   * Creates a new instance of a workflow result. By default the result code
   * is set to UNDEFINED and there is no error message.
@@ -52,7 +51,6 @@
    // Nothing to implement.
  }
  /**
   * Creates a new instance of a workflow result code and initializes it
   * with a result code and an error message.
@@ -60,10 +58,7 @@
   * @param resultCode    the initial value for the result code
   * @param errorMessage  the initial value for the error message
   */
  public WorkflowResultCode(
      ResultCode     resultCode,
      LocalizableMessageBuilder errorMessage
      )
  WorkflowResultCode(ResultCode resultCode, LocalizableMessageBuilder errorMessage)
  {
    this.resultCode   = resultCode;
    this.errorMessage = errorMessage;
@@ -76,8 +71,8 @@
   * has to take into account all the subordinate result codes to elaborate
   * a global result code.
   *
   * Sometimes, a referral result code has to be turned into a reference
   * entry. When such case is occurring the elaborateGlobalResultCode method
   * Sometimes, a referral result code has to be turned into a reference entry.
   * When such case is occurring the elaborateGlobalResultCode method
   * will return true.
   *
   * The global result code is elaborated as follows:
@@ -108,131 +103,95 @@
   * </PRE>
   *
   * @param newResultCode    the new result code to take into account
   * @param newErrorMessage  the new error message associated to the new
   *                         error code
   * @return <code>true</code> if a referral result code must be turned
   *         into a reference entry
   * @param newErrorMessage  the new error message associated to the new error code
   * @return <code>true</code> if a referral result code must be turned into a reference entry
   */
  public boolean elaborateGlobalResultCode(
      ResultCode     newResultCode,
      LocalizableMessageBuilder newErrorMessage
      )
  boolean elaborateGlobalResultCode(ResultCode newResultCode, LocalizableMessageBuilder newErrorMessage)
  {
    // Returned value
    boolean sendReferenceEntry = false;
    // if global result code has not been set yet then just take the new
    // result code as is
    if (resultCode == ResultCode.UNDEFINED)
    {
      resultCode   = newResultCode;
      errorMessage = new LocalizableMessageBuilder (newErrorMessage);
      return false;
    }
    else
    {
      // Elaborate the new result code (see table in the description header).
      switch (newResultCode.asEnum())
    // Elaborate the new result code (see table in the description header).
    switch (newResultCode.asEnum())
    {
    case SUCCESS:
      switch (resultCode.asEnum())
      {
      case SUCCESS:
        //
        // Received SUCCESS
        // ----------------
        //
        switch (resultCode.asEnum())
        {
          case NO_SUCH_OBJECT:
            resultCode = ResultCode.SUCCESS;
            errorMessage = new LocalizableMessageBuilder(LocalizableMessage.EMPTY);
            break;
          case REFERRAL:
            resultCode = ResultCode.SUCCESS;
            errorMessage = new LocalizableMessageBuilder(LocalizableMessage.EMPTY);
            sendReferenceEntry = true;
            break;
          default:
            // global resultCode remains the same
            break;
        }
        break;
      case NO_SUCH_OBJECT:
        //
        // Received NO SUCH OBJECT
        // -----------------------
        //
        // global resultCode remains the same
        break;
      case REFERRAL:
        //
        // Received REFERRAL
        // -----------------
        //
        switch (resultCode.asEnum())
        {
          case REFERRAL:
            resultCode = ResultCode.SUCCESS;
            errorMessage = new LocalizableMessageBuilder(LocalizableMessage.EMPTY);
            sendReferenceEntry = true;
            break;
          case NO_SUCH_OBJECT:
            resultCode = ResultCode.REFERRAL;
            errorMessage = new LocalizableMessageBuilder (LocalizableMessage.EMPTY);
            break;
          default:
            // global resultCode remains the same
            sendReferenceEntry = true;
            break;
        }
        break;
      default:
        //
        // Received other result codes
        // ---------------------------
        //
        switch (resultCode.asEnum())
        {
          case REFERRAL:
            resultCode = newResultCode;
            errorMessage = new LocalizableMessageBuilder (newErrorMessage);
            sendReferenceEntry = true;
            break;
          case SUCCESS:
            resultCode = newResultCode;
            errorMessage = new LocalizableMessageBuilder (newErrorMessage);
            break;
          case NO_SUCH_OBJECT:
            resultCode = newResultCode;
            errorMessage = new LocalizableMessageBuilder (newErrorMessage);
            break;
          default:
            // Do nothing (we don't want to override the first error)
            break;
        }
        break;
        case NO_SUCH_OBJECT:
          resultCode = ResultCode.SUCCESS;
          errorMessage = new LocalizableMessageBuilder(LocalizableMessage.EMPTY);
          return false;
        case REFERRAL:
          resultCode = ResultCode.SUCCESS;
          errorMessage = new LocalizableMessageBuilder(LocalizableMessage.EMPTY);
          return true;
        default:
          // global resultCode remains the same
          return false;
      }
    case NO_SUCH_OBJECT:
      // global resultCode remains the same
      return false;
    case REFERRAL:
      switch (resultCode.asEnum())
      {
        case REFERRAL:
          resultCode = ResultCode.SUCCESS;
          errorMessage = new LocalizableMessageBuilder(LocalizableMessage.EMPTY);
          return true;
        case NO_SUCH_OBJECT:
          resultCode = ResultCode.REFERRAL;
          errorMessage = new LocalizableMessageBuilder (LocalizableMessage.EMPTY);
          return false;
        default:
          // global resultCode remains the same
          return true;
      }
    default:
      switch (resultCode.asEnum())
      {
        case REFERRAL:
          resultCode = newResultCode;
          errorMessage = new LocalizableMessageBuilder (newErrorMessage);
          return true;
        case SUCCESS:
        case NO_SUCH_OBJECT:
          resultCode = newResultCode;
          errorMessage = new LocalizableMessageBuilder (newErrorMessage);
          return false;
        default:
          // Do nothing (we don't want to override the first error)
          return false;
      }
    }
    return sendReferenceEntry;
  }
  /**
   * Returns the global result code.
   *
   * @return the global result code.
   */
  public ResultCode resultCode()
  ResultCode resultCode()
  {
    return resultCode;
  }
  /**
   * Returns the global error message.
   *
   * @return the global error message.
   */
  public LocalizableMessageBuilder errorMessage()
  LocalizableMessageBuilder errorMessage()
  {
    return errorMessage;
  }
opendj3-server-dev/src/server/org/opends/server/core/networkgroups/NetworkGroupNamingContexts.java
@@ -22,57 +22,40 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.core.networkgroups;
import org.opends.server.core.*;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.opends.server.core.WorkflowTopologyNode;
/**
 * This classes defines a list of naming contexts for a network group.
 */
public class NetworkGroupNamingContexts
{
  // List of naming contexts.
  private List<WorkflowTopologyNode> namingContexts;
  // If list of naming contexts is returned, ensure it is immutable
  private List<WorkflowTopologyNode> _namingContexts;
  /** List of naming contexts. */
  private final List<WorkflowTopologyNode> namingContexts = new CopyOnWriteArrayList<WorkflowTopologyNode>();
  /** If list of naming contexts is returned, ensure it is immutable. */
  private final List<WorkflowTopologyNode> _namingContexts = Collections.unmodifiableList(namingContexts);
  // List of public naming contexts.
  private List<WorkflowTopologyNode> publicNamingContexts;
  // If list of public naming contexts is returned, ensure it is immutable
  private List<WorkflowTopologyNode> _publicNamingContexts;
  /** List of public naming contexts. */
  private final List<WorkflowTopologyNode> publicNamingContexts = new CopyOnWriteArrayList<WorkflowTopologyNode>();
  /** If list of public naming contexts is returned, ensure it is immutable. */
  private final List<WorkflowTopologyNode> _publicNamingContexts = Collections.unmodifiableList(publicNamingContexts);
  // List of private naming contexts.
  private List<WorkflowTopologyNode> privateNamingContexts;
  // If list of private naming contexts is returned, ensure it is immutable
  private List<WorkflowTopologyNode> _privateNamingContexts;
  /**
   * Create a list of naming contexts for a network group.
   */
  public NetworkGroupNamingContexts()
  {
    namingContexts  = new CopyOnWriteArrayList<WorkflowTopologyNode>();
    _namingContexts = Collections.unmodifiableList(namingContexts);
    privateNamingContexts  = new CopyOnWriteArrayList<WorkflowTopologyNode>();
    _privateNamingContexts =
                            Collections.unmodifiableList(privateNamingContexts);
    publicNamingContexts  = new CopyOnWriteArrayList<WorkflowTopologyNode>();
    _publicNamingContexts = Collections.unmodifiableList(publicNamingContexts);
  }
  /** List of private naming contexts. */
  private final List<WorkflowTopologyNode> privateNamingContexts = new CopyOnWriteArrayList<WorkflowTopologyNode>();
  /** If list of private naming contexts is returned, ensure it is immutable. */
  private final List<WorkflowTopologyNode> _privateNamingContexts = Collections.unmodifiableList(privateNamingContexts);
  /**
   * Reset the list of naming contexts.
   */
  public void resetLists()
  void resetLists()
  {
    namingContexts.clear();
    privateNamingContexts.clear();
@@ -85,9 +68,7 @@
   *
   * @param workflow  the workflow to add in the list of naming contexts
   */
  public void addNamingContext (
      WorkflowTopologyNode workflow
      )
  void addNamingContext(WorkflowTopologyNode workflow)
  {
    // add the workflow to the list of naming context
    namingContexts.add (workflow);
@@ -147,7 +128,7 @@
  /**
   * Dumps info from the current networkk group for debug purpose.
   * Dumps info from the current network group for debug purpose.
   *
   * @param  leftMargin  white spaces used to indent traces
   * @return a string buffer that contains trace information
@@ -157,19 +138,19 @@
    StringBuilder sb = new StringBuilder();
    String newMargin = leftMargin + "   ";
    sb.append (leftMargin + "List of naming contexts:\n");
    sb.append(leftMargin).append("List of naming contexts:\n");
    for (WorkflowTopologyNode w: namingContexts)
    {
      sb.append (w.toString (newMargin));
    }
    sb.append (leftMargin + "List of PRIVATE naming contexts:\n");
    sb.append(leftMargin).append("List of PRIVATE naming contexts:\n");
    for (WorkflowTopologyNode w: privateNamingContexts)
    {
      sb.append (w.toString (newMargin));
    }
    sb.append (leftMargin + "List of PUBLIC naming contexts:\n");
    sb.append(leftMargin).append("List of PUBLIC naming contexts:\n");
    for (WorkflowTopologyNode w: publicNamingContexts)
    {
      sb.append (w.toString (newMargin));