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

Violette Roche-Montane
07.51.2013 e65f1a41c4676cb09918dd1bc0ba068a5d2ee7f9
Minor fix about style and typos.
1 files modified
51 ■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/tasks/RebuildTask.java 51 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/tasks/RebuildTask.java
@@ -26,6 +26,7 @@
 *      Portions copyright 2012-2013 ForgeRock AS.
 */
package org.opends.server.tasks;
import org.opends.messages.Message;
import org.opends.messages.TaskMessages;
@@ -41,7 +42,6 @@
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.Operation;
import org.opends.server.types.Privilege;
import org.opends.server.types.ResultCode;
@@ -58,13 +58,12 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import java.util.List;
import java.util.ArrayList;
/**
 * This class provides an implementation of a Directory Server task that can
 * be used to rebuild indexes in the JEB backend..
 * This class provides an implementation of a Directory Server task that can be
 * used to rebuild indexes in the JEB backend..
 */
public class RebuildTask extends Task
{
@@ -82,14 +81,16 @@
  /**
   * {@inheritDoc}
   */
  public Message getDisplayName() {
  public Message getDisplayName()
  {
    return TaskMessages.INFO_TASK_REBUILD_NAME.get();
  }
  /**
   * {@inheritDoc}
   */
  @Override public void initializeTask() throws DirectoryException
  @Override
  public void initializeTask() throws DirectoryException
  {
    // If the client connection is available, then make sure the associated
    // client has the INDEX_REBUILD privilege.
@@ -106,7 +107,6 @@
      }
    }
    Entry taskEntry = getTaskEntry();
    AttributeType typeBaseDN;
@@ -114,12 +114,9 @@
    AttributeType typeTmpDirectory;
    AttributeType clearDegradedState;
    typeBaseDN =
         getAttributeType(ATTR_REBUILD_BASE_DN, true);
    typeIndex =
         getAttributeType(ATTR_REBUILD_INDEX, true);
    typeTmpDirectory =
         getAttributeType(ATTR_REBUILD_TMP_DIRECTORY, true);
    typeBaseDN = getAttributeType(ATTR_REBUILD_BASE_DN, true);
    typeIndex = getAttributeType(ATTR_REBUILD_INDEX, true);
    typeTmpDirectory = getAttributeType(ATTR_REBUILD_TMP_DIRECTORY, true);
    clearDegradedState =
        getAttributeType(ATTR_REBUILD_INDEX_CLEARDEGRADEDSTATE, true);
@@ -143,8 +140,8 @@
    }
    attrList = taskEntry.getAttribute(clearDegradedState);
    isClearDegradedState = Boolean.parseBoolean(
        TaskUtils.getSingleValueString(attrList));
    isClearDegradedState =
        Boolean.parseBoolean(TaskUtils.getSingleValueString(attrList));
    attrList = taskEntry.getAttribute(typeTmpDirectory);
    tmpDirectory = TaskUtils.getSingleValueString(attrList);
@@ -215,7 +212,7 @@
    // Acquire a shared lock for the backend if we are rebuilding attribute
    // indexes only. If we are rebuilding one or more system indexes, we have
    // to aquire exclusive lock.
    // to acquire exclusive lock.
    String lockFile = LockFileManager.getBackendLockFileName(backend);
    StringBuilder failureReason = new StringBuilder();
@@ -239,16 +236,18 @@
    {
      if(! LockFileManager.acquireExclusiveLock(lockFile, failureReason))
      {
        Message message = ERR_REBUILDINDEX_CANNOT_EXCLUSIVE_LOCK_BACKEND.get(
            backend.getBackendID(), String.valueOf(failureReason));
        Message message =
            ERR_REBUILDINDEX_CANNOT_EXCLUSIVE_LOCK_BACKEND.get(backend
                .getBackendID(), String.valueOf(failureReason));
        logError(message);
        return TaskState.STOPPED_BY_ERROR;
      }
    }
    catch (Exception e)
    {
      Message message = ERR_REBUILDINDEX_CANNOT_EXCLUSIVE_LOCK_BACKEND.get(
          backend.getBackendID(), getExceptionMessage(e));
      Message message =
          ERR_REBUILDINDEX_CANNOT_EXCLUSIVE_LOCK_BACKEND.get(backend
              .getBackendID(), getExceptionMessage(e));
      logError(message);
      return TaskState.STOPPED_BY_ERROR;
    }
@@ -261,6 +260,7 @@
    rebuildConfig.setRebuildMode(rebuildMode);
    TaskState returnCode = TaskState.COMPLETED_SUCCESSFULLY;
    // Launch the rebuild process.
    try
    {
@@ -279,6 +279,7 @@
      logError(message);
      returnCode = TaskState.STOPPED_BY_ERROR;
    }
    // Release the lock on the backend.
    finally
    {
@@ -288,16 +289,18 @@
        failureReason = new StringBuilder();
        if (! LockFileManager.releaseLock(lockFile, failureReason))
        {
          Message message = WARN_REBUILDINDEX_CANNOT_UNLOCK_BACKEND.get(
              backend.getBackendID(), String.valueOf(failureReason));
          Message message =
              WARN_REBUILDINDEX_CANNOT_UNLOCK_BACKEND.get(backend
                  .getBackendID(), String.valueOf(failureReason));
          logError(message);
          returnCode = TaskState.COMPLETED_WITH_ERRORS;
        }
      }
      catch (Throwable t)
      {
        Message message = WARN_REBUILDINDEX_CANNOT_UNLOCK_BACKEND.get(
            backend.getBackendID(), getExceptionMessage(t));
        Message message =
            WARN_REBUILDINDEX_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(),
                getExceptionMessage(t));
        logError(message);
        returnCode = TaskState.COMPLETED_WITH_ERRORS;
      }