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

Violette Roche-Montane
24.07.2014 fe9d45d7f26b89b9fb2b87011e1656d4feecf551
OPENDJ-1343 Migrate dsconfig
- Removed CommunicationException from dsconfig package.
- Replaced ReturnCode.TODO by appropriate return code.

StatusCli
- Reorganized imports.
9 files modified
98 ■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java 9 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java 7 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java 18 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java 31 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java 17 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
@@ -80,7 +80,6 @@
import org.forgerock.opendj.config.conditions.ContainsCondition;
import org.forgerock.opendj.ldap.AuthorizationException;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.opends.server.admin.client.CommunicationException;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
@@ -873,11 +872,11 @@
        } catch (ConcurrentModificationException e) {
          LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(irelation
              .getUserFriendlyName());
          throw new ClientException(ReturnCode.TODO, msg);
          throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg);
        } catch (ErrorResultException e) {
          LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(irelation
              .getUserFriendlyName(), e.getMessage());
          throw new ClientException(ReturnCode.TODO, msg);
          throw new ClientException(ReturnCode.APPLICATION_ERROR, msg);
        } catch (DefinitionDecodingException e) {
          // Do nothing.
        } catch (ManagedObjectDecodingException e) {
@@ -1177,10 +1176,6 @@
      LocalizableMessage pufn = path.getManagedObjectDefinition().getUserFriendlyName();
      LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn);
      throw new ClientException(ReturnCode.OTHER, msg, e);
    } catch (CommunicationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e
          .getMessage());
      throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg);
    } catch (ConcurrentModificationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn);
      throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg);
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
@@ -47,7 +47,6 @@
import org.forgerock.opendj.config.client.OperationRejectedException;
import org.forgerock.opendj.ldap.AuthorizationException;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.opends.server.admin.client.CommunicationException;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
@@ -246,9 +245,6 @@
      LocalizableMessage pufn = path.getManagedObjectDefinition().getUserFriendlyName();
      LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn);
      throw new ClientException(ReturnCode.OTHER, msg, e);
    } catch (CommunicationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage());
      throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg);
    } catch (ConcurrentModificationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CME.get(ufn);
      throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg);
@@ -386,9 +382,6 @@
    } catch (ConcurrentModificationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CME.get(ufn);
      throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg);
    } catch (CommunicationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage());
      throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg);
    } catch (ErrorResultException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage());
      throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg);
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java
@@ -59,7 +59,6 @@
import org.forgerock.opendj.config.client.ManagedObjectDecodingException;
import org.forgerock.opendj.config.client.ManagementContext;
import org.forgerock.opendj.ldap.AuthorizationException;
import org.opends.server.admin.client.CommunicationException;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ReturnCode;
@@ -265,9 +264,6 @@
    } catch (ManagedObjectDecodingException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(ufn);
      throw new ClientException(ReturnCode.OTHER, msg, e);
    } catch (CommunicationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_CE.get(ufn, e.getMessage());
      throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg);
    } catch (ConcurrentModificationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_CME.get(ufn);
      throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg);
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
@@ -52,7 +52,6 @@
import org.forgerock.opendj.config.client.ManagementContext;
import org.forgerock.opendj.ldap.AuthorizationException;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.opends.server.admin.client.CommunicationException;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ClientException;
@@ -258,9 +257,6 @@
      ufn = path.getManagedObjectDefinition().getUserFriendlyName();
      LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(ufn);
      throw new ClientException(ReturnCode.OTHER, msg, e);
    } catch (CommunicationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage());
      throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg);
    } catch (ConcurrentModificationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn);
      throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg);
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
@@ -474,13 +474,13 @@
      try {
        values.addAll(Arrays.asList(context.listManagedObjects(path, rd)));
      } catch (AuthorizationException e) {
        this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage()));
        this.e = new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, LocalizableMessage.raw(e.getMessage()));
        return MenuResult.quit();
      } catch (ManagedObjectNotFoundException e) {
        this.e = new ClientException(ReturnCode.TODO, e.getMessageObject());
        this.e = new ClientException(ReturnCode.NO_SUCH_OBJECT, e.getMessageObject());
        return MenuResult.cancel();
      } catch (ErrorResultException e) {
        this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage()));
        this.e = new ClientException(ReturnCode.APPLICATION_ERROR, LocalizableMessage.raw(e.getMessage()));
        return MenuResult.quit();
      }
@@ -735,13 +735,13 @@
        try {
          values.addAll(Arrays.asList(context.listManagedObjects(path, rd)));
        } catch (AuthorizationException e) {
          this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage()));
          this.e = new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, LocalizableMessage.raw(e.getMessage()));
          return MenuResult.quit();
        } catch (ManagedObjectNotFoundException e) {
          this.e = new ClientException(ReturnCode.TODO, e.getMessageObject());
          this.e = new ClientException(ReturnCode.NO_SUCH_OBJECT, e.getMessageObject());
          return MenuResult.cancel();
        } catch (ErrorResultException e) {
          this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage()));
          this.e = new ClientException(ReturnCode.APPLICATION_ERROR, LocalizableMessage.raw(e.getMessage()));
          return MenuResult.quit();
        }
@@ -1628,13 +1628,13 @@
      try {
        values.addAll(Arrays.asList(context.listManagedObjects(path, rd)));
      } catch (AuthorizationException e) {
        this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage()));
        this.e = new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, LocalizableMessage.raw(e.getMessage()));
        return MenuResult.quit();
      } catch (ManagedObjectNotFoundException e) {
        this.e = new ClientException(ReturnCode.TODO, e.getMessageObject());
        this.e = new ClientException(ReturnCode.NO_SUCH_OBJECT, e.getMessageObject());
        return MenuResult.cancel();
      } catch (ErrorResultException e) {
        this.e = new ClientException(ReturnCode.TODO, LocalizableMessage.raw(e.getMessage()));
        this.e = new ClientException(ReturnCode.APPLICATION_ERROR, LocalizableMessage.raw(e.getMessage()));
        return MenuResult.quit();
      }
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
@@ -67,7 +67,6 @@
import org.forgerock.opendj.config.conditions.ContainsCondition;
import org.forgerock.opendj.ldap.AuthorizationException;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.opends.server.admin.client.CommunicationException;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
@@ -725,9 +724,6 @@
      // verbose) and apply the changes to the partial managed object.
      LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(ufn);
      throw new ClientException(ReturnCode.OTHER, msg, e);
    } catch (CommunicationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage());
      throw new ClientException(ReturnCode.OTHER, msg);
    } catch (ConcurrentModificationException e) {
      LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CME.get(ufn);
      throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg);
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
@@ -72,7 +72,6 @@
import org.forgerock.opendj.config.client.ManagementContext;
import org.forgerock.opendj.ldap.AuthorizationException;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.opends.server.admin.client.CommunicationException;
import org.opends.server.util.ServerConstants;
import com.forgerock.opendj.cli.Argument;
@@ -114,8 +113,6 @@
    private AuthorizationException authze;
    private CommunicationException ce;
    private ErrorResultException ere;
    /**
@@ -209,9 +206,6 @@
        } catch (ErrorResultException e) {
          ere = e;
          result = MenuResult.quit();
        } catch (CommunicationException e) {
          ce = e;
          result = MenuResult.quit();
        }
      }
    }
@@ -309,7 +303,7 @@
              String typeUsage = getSubTypesUsage(d);
              LocalizableMessage msg = ERR_DSCFG_ERROR_SUB_TYPE_UNRECOGNIZED.get(
                  name, r.getUserFriendlyName(), typeUsage);
              clie = new ClientException(ReturnCode.TODO, msg);
              clie = new ClientException(ReturnCode.APPLICATION_ERROR, msg);
              result = MenuResult.quit();
              return;
            } else {
@@ -346,9 +340,6 @@
        } catch (ErrorResultException e) {
          ere = e;
          result = MenuResult.quit();
        } catch (CommunicationException e) {
          ce = e;
          result = MenuResult.quit();
        }
      }
    }
@@ -432,13 +423,10 @@
     *           If the server refuses to retrieve the managed object
     *           because the client does not have the correct
     *           privileges.
     * @throws CommunicationException
     *           If the client cannot contact the server due to an
     *           underlying communication problem.
     */
    public MenuResult<ManagedObject<?>> find(ConsoleApplication app,
        ManagementContext context, ManagedObjectPath<?, ?> path,
        List<String> args) throws ClientException, CommunicationException,
        List<String> args) throws ClientException,
        AuthorizationException, ConcurrentModificationException,
        DefinitionDecodingException, ManagedObjectDecodingException,
        ManagedObjectNotFoundException {
@@ -450,7 +438,6 @@
      this.clie = null;
      this.authze = null;
      this.ce = null;
      this.cme = null;
      this.dde = null;
      this.mode = null;
@@ -464,8 +451,6 @@
        throw clie;
      } else if (authze != null) {
        throw authze;
      } else if (ce != null) {
        throw ce;
      } else if (cme != null) {
        throw cme;
      } else if (dde != null) {
@@ -964,9 +949,6 @@
   *           If the server refuses to retrieve the managed object
   *           because the client does not have the correct
   *           privileges.
   * @throws CommunicationException
   *           If the client cannot contact the server due to an
   *           underlying communication problem.
   * @throws ClientException
   *           If one of the naming arguments referenced a managed
   *           object of the wrong type.
@@ -977,8 +959,8 @@
      ConsoleApplication app, ManagementContext context,
      ManagedObjectPath<?, ?> path, List<String> args) throws ClientException,
      AuthorizationException, DefinitionDecodingException,
      ManagedObjectDecodingException, CommunicationException,
      ConcurrentModificationException, ManagedObjectNotFoundException
      ManagedObjectDecodingException, ConcurrentModificationException,
      ManagedObjectNotFoundException
  {
    ManagedObjectFinder finder = new ManagedObjectFinder();
    return finder.find(app, context, path, args);
@@ -1129,8 +1111,6 @@
   *         {@link MenuResult#quit()}, or {@link MenuResult#cancel()},
   *         if the sub-command was run interactive and the user chose
   *         to quit or cancel.
   * @throws CommunicationException
   *           If the server cannot be contacted.
   * @throws ConcurrentModificationException
   *           If the parent managed object has been deleted.
   * @throws AuthorizationException
@@ -1146,7 +1126,8 @@
      RelationDefinition<C, S> r,
      AbstractManagedObjectDefinition<? extends C, ? extends S> d)
      throws AuthorizationException, ConcurrentModificationException,
      CommunicationException, ClientException {
      ClientException
  {
    if (d == null) {
      d = r.getChildDefinition();
    }
opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
@@ -28,13 +28,12 @@
package org.opends.server.tools.status;
import static com.forgerock.opendj.cli.ArgumentConstants.LIST_TABLE_SEPARATOR;
import static com.forgerock.opendj.cli.CliMessages.ERR_CANNOT_INITIALIZE_ARGS;
import static com.forgerock.opendj.cli.CliMessages.ERR_ERROR_PARSING_ARGS;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.ToolMessages.ERR_ERROR_PARSING_ARGS;
import static com.forgerock.opendj.cli.CliMessages.*;
import static org.opends.quicksetup.util.Utils.getCommandLineMaxLineWidth;
import static org.opends.messages.QuickSetupMessages.INFO_ERROR_READING_SERVER_CONFIGURATION;
import static org.opends.messages.QuickSetupMessages.INFO_NOT_AVAILABLE_LABEL;
import static org.opends.messages.QuickSetupMessages.
INFO_ERROR_READING_SERVER_CONFIGURATION;
import static com.forgerock.opendj.cli.Utils.MAX_LINE_WIDTH;
import java.io.File;
import java.io.InputStream;
@@ -80,9 +79,9 @@
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ReturnCode;
import com.forgerock.opendj.cli.TableBuilder;
import com.forgerock.opendj.cli.TextTablePrinter;
import com.forgerock.opendj.cli.ReturnCode;
/**
 * The class used to provide some CLI interface to display status.
@@ -1151,11 +1150,11 @@
  private LocalizableMessage centerTitle(LocalizableMessage text)
  {
    LocalizableMessage centered;
    if (text.length() <= getCommandLineMaxLineWidth() - 8)
    if (text.length() <= MAX_LINE_WIDTH - 8)
    {
      LocalizableMessageBuilder buf = new LocalizableMessageBuilder();
      int extra = Math.min(10,
          (getCommandLineMaxLineWidth() - 8 - text.length()) / 2);
          (MAX_LINE_WIDTH - 8 - text.length()) / 2);
      for (int i=0; i<extra; i++)
      {
        buf.append(" ");
@@ -1242,6 +1241,6 @@
  private LocalizableMessage wrapText(LocalizableMessage text)
  {
    return LocalizableMessage.raw(
        StaticUtils.wrapText(text, getCommandLineMaxLineWidth()));
        StaticUtils.wrapText(text, MAX_LINE_WIDTH));
  }
}
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java
@@ -220,7 +220,7 @@
    }
    else
    {
      throw new ClientException(ReturnCode.TODO, LocalizableMessage.EMPTY);
      throw new ClientException(ReturnCode.ERROR_UNEXPECTED, LocalizableMessage.EMPTY);
    }
  }
@@ -445,7 +445,7 @@
    }
    else
    {
      throw new ClientException(ReturnCode.TODO, LocalizableMessage.EMPTY);
      throw new ClientException(ReturnCode.ERROR_UNEXPECTED, LocalizableMessage.EMPTY);
    }
  }