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

matthew_swift
04.26.2007 25767e41837b50d8a577be06e4272c4ae947e837
Improve display of OperationRejectedExceptions in dsconfig.
5 files modified
96 ■■■■ changed files
opends/src/messages/messages/dsconfig.properties 12 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/client/OperationRejectedException.java 55 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java 10 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java 10 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java 9 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/dsconfig.properties
@@ -110,14 +110,10 @@
 communications problem: %s
SEVERE_ERR_DSCFG_ERROR_CREATE_CME_1036=The %s could not be created because \
 another client is currently making conflicting configuration changes
SEVERE_ERR_DSCFG_ERROR_CREATE_ORE_1037=The server prevented the %s from being \
 created because of the following reason: %s
SEVERE_ERR_DSCFG_ERROR_DELETE_MONFE_1038=The %s could not be deleted because \
 it does not exist
SEVERE_ERR_DSCFG_ERROR_DELETE_AUTHZ_1039=The %s could not be deleted because \
 you do not have the correct authorization
SEVERE_ERR_DSCFG_ERROR_DELETE_ORE_1040=The server prevented the %s from being \
 deleted because of the following reason: %s
SEVERE_ERR_DSCFG_ERROR_DELETE_CE_1041=The %s could not be deleted due to a \
 communications problem: %s
SEVERE_ERR_DSCFG_ERROR_DELETE_CME_1042=The %s could not be deleted because \
@@ -142,8 +138,6 @@
 communications problem: %s
SEVERE_ERR_DSCFG_ERROR_MODIFY_CME_1052=The %s could not be modified because \
 another client is currently making conflicting configuration changes
SEVERE_ERR_DSCFG_ERROR_MODIFY_ORE_1053=The server prevented the %s from being \
 modified because of the following reason: %s
SEVERE_ERR_DSCFG_ERROR_LIST_DDE_1054=The %s could not be retrieved because \
 its type could not be determined. This is probably due to the %s having an \
 invalid LDAP entry. Check that the %s object classes are correct
@@ -412,3 +406,9 @@
INFO_DSCFG_PROMPT_SECURITY_KEYSTORE_PATH_1381=Keystore path:
INFO_DSCFG_PROMPT_SECURITY_KEYSTORE_PASSWORD_1382=Password for keystore '%s':
INFO_DSCFG_PROMPT_SECURITY_CERTIFICATE_NAME_1383=Certificate nickname:
SEVERE_ERR_DSCFG_ERROR_CREATE_ORE_SINGLE_1384=The %s could not be created because of the following reason: %s
SEVERE_ERR_DSCFG_ERROR_CREATE_ORE_PLURAL_1385=The %s could not be created because of the following reasons: %s
SEVERE_ERR_DSCFG_ERROR_DELETE_ORE_SINGLE_1386=The %s could not be deleted because of the following reason: %s
SEVERE_ERR_DSCFG_ERROR_DELETE_ORE_PLURAL_1387=The %s could not be deleted because of the following reasons: %s
SEVERE_ERR_DSCFG_ERROR_MODIFY_ORE_SINGLE_1388=The %s could not be modified because of the following reason: %s
SEVERE_ERR_DSCFG_ERROR_MODIFY_ORE_PLURAL_1389=The %s could not be modified because of the following reasons: %s
opends/src/server/org/opends/server/admin/client/OperationRejectedException.java
@@ -63,8 +63,8 @@
  // Merge the messages into a single message.
  private static Message getSingleMessage(Collection<Message> messages) {
  // Gets the default message.
  private static Message getDefaultMessage(Collection<Message> messages) {
    Validator.ensureNotNull(messages);
    Validator.ensureTrue(!messages.isEmpty());
@@ -72,18 +72,30 @@
      return ERR_OPERATION_REJECTED_EXCEPTION_SINGLE.get(messages.iterator()
          .next());
    } else {
      return ERR_OPERATION_REJECTED_EXCEPTION_PLURAL
          .get(getSingleMessage(messages));
    }
  }
  // Merge the messages into a single message.
  private static Message getSingleMessage(Collection<Message> messages) {
    if (messages.size() == 1) {
      return messages.iterator().next();
    } else {
      MessageBuilder builder = new MessageBuilder();
      boolean isFirst = true;
      for (Message m : messages) {
        if (!isFirst) {
          builder.append("; ");
          builder.append(";  ");
        }
        builder.append(m);
        isFirst = false;
      }
      return ERR_OPERATION_REJECTED_EXCEPTION_PLURAL.get(builder.toMessage());
      return builder.toMessage();
    }
  }
@@ -93,6 +105,16 @@
  /**
   * Creates a new operation rejected exception with a default
   * message.
   */
  public OperationRejectedException() {
    this(ERR_OPERATION_REJECTED_DEFAULT.get());
  }
  /**
   * Creates a new operation rejected exception with the provided
   * messages.
   *
@@ -102,7 +124,7 @@
   *          non-empty).
   */
  public OperationRejectedException(Collection<Message> messages) {
    super(getSingleMessage(messages));
    super(getDefaultMessage(messages));
    this.messages = new ArrayList<Message>(messages);
  }
@@ -124,16 +146,6 @@
  /**
   * Creates a new operation rejected exception with a default
   * message.
   */
  public OperationRejectedException() {
    this(ERR_OPERATION_REJECTED_DEFAULT.get());
  }
  /**
   * Gets an unmodifiable collection view of the messages describing
   * the constraint violations that occurred.
   *
@@ -144,4 +156,17 @@
    return Collections.unmodifiableCollection(messages);
  }
  /**
   * Creates a single message listing all the messages combined into a
   * single list separated by semi-colons.
   *
   * @return Returns a single message listing all the messages
   *         combined into a single list separated by semi-colons.
   */
  public Message getMessagesAsSingleMessage() {
    return getSingleMessage(messages);
  }
}
opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
@@ -694,8 +694,14 @@
      Message msg = ERR_DSCFG_ERROR_CREATE_CME.get(d.getUserFriendlyName());
      throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
    } catch (OperationRejectedException e) {
      Message msg = ERR_DSCFG_ERROR_CREATE_ORE.get(d.getUserFriendlyName(), e
          .getMessage());
      Message msg;
      if (e.getMessages().size() == 1) {
        msg = ERR_DSCFG_ERROR_CREATE_ORE_SINGLE.get(d.getUserFriendlyName(), e
            .getMessagesAsSingleMessage());
      } else {
        msg = ERR_DSCFG_ERROR_CREATE_ORE_PLURAL.get(d.getUserFriendlyName(), e
            .getMessagesAsSingleMessage());
      }
      throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
    } catch (CommunicationException e) {
      Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(d.getUserFriendlyName(), e
opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
@@ -297,8 +297,14 @@
          .getUserFriendlyName());
      throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
    } catch (OperationRejectedException e) {
      Message msg = ERR_DSCFG_ERROR_DELETE_ORE.get(relation
          .getUserFriendlyName(), e.getMessage());
      Message msg;
      if (e.getMessages().size() == 1) {
        msg = ERR_DSCFG_ERROR_DELETE_ORE_SINGLE.get(relation
            .getUserFriendlyName(), e.getMessagesAsSingleMessage());
      } else {
        msg = ERR_DSCFG_ERROR_DELETE_ORE_PLURAL.get(relation
            .getUserFriendlyName(), e.getMessagesAsSingleMessage());
      }
      throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
    } catch (ManagedObjectNotFoundException e) {
      // Ignore the error if the deletion is being forced.
opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
@@ -554,7 +554,14 @@
      Message msg = ERR_DSCFG_ERROR_MODIFY_CME.get(ufn);
      throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
    } catch (OperationRejectedException e) {
      Message msg = ERR_DSCFG_ERROR_MODIFY_ORE.get(ufn, e.getMessage());
      Message msg;
      if (e.getMessages().size() == 1) {
        msg = ERR_DSCFG_ERROR_MODIFY_ORE_SINGLE.get(ufn, e
            .getMessagesAsSingleMessage());
      } else {
        msg = ERR_DSCFG_ERROR_MODIFY_ORE_PLURAL.get(ufn, e
            .getMessagesAsSingleMessage());
      }
      throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
    } catch (CommunicationException e) {
      Message msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage());