From befb8b35a52ecfc48390976af9ae69990eb802ee Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Wed, 12 Sep 2007 13:24:52 +0000
Subject: [PATCH] Improve the usability of dsconfig when the server rejects a change. Previously dsconfig would just bomb out. With this change dsconfig will either give the user the opportunity to re-edit and fix any mis-configured properties of the component (for create-xxx and set-xxx-prop interactive modes), or drop them back to the component menu (for delete-xxx interactive mode).

---
 opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java  |  179 ++++++++++++---------
 opendj-sdk/opends/src/messages/messages/dsconfig.properties                                 |   13 
 opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java  |   74 +++++---
 opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java |  142 ++++++++++-------
 opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java                 |   19 ++
 5 files changed, 254 insertions(+), 173 deletions(-)

diff --git a/opendj-sdk/opends/src/messages/messages/dsconfig.properties b/opendj-sdk/opends/src/messages/messages/dsconfig.properties
index 465f792..da4eca4 100644
--- a/opendj-sdk/opends/src/messages/messages/dsconfig.properties
+++ b/opendj-sdk/opends/src/messages/messages/dsconfig.properties
@@ -406,12 +406,13 @@
 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
+SEVERE_ERR_DSCFG_ERROR_CREATE_ORE_SINGLE_1384=The %s could not be created because of the following reason:
+SEVERE_ERR_DSCFG_ERROR_CREATE_ORE_PLURAL_1385=The %s could not be created because of the following reasons:
+SEVERE_ERR_DSCFG_ERROR_DELETE_ORE_SINGLE_1386=The %s could not be deleted because of the following reason:
+SEVERE_ERR_DSCFG_ERROR_DELETE_ORE_PLURAL_1387=The %s could not be deleted because of the following reasons:
+SEVERE_ERR_DSCFG_ERROR_MODIFY_ORE_SINGLE_1388=The %s could not be modified because of the following reason:
+SEVERE_ERR_DSCFG_ERROR_MODIFY_ORE_PLURAL_1389=The %s could not be modified because of the following reasons:
 INFO_DSCFG_PROMPT_SECURITY_LDAP_1390=LDAP
 INFO_DSCFG_PROMPT_SECURITY_PROTOCOL_DEFAULT_CHOICE_1391=%d
 SEVERE_ERR_DSCFG_PROMPT_SECURITY_INVALID_FILE_PATH_1392=The provided path is not valid
+INFO_DSCFG_PROMPT_EDIT_AGAIN_1393=Would you like to edit the properties of the %s again in order to resolve this problem?
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java b/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
index 299cd9e..2a3758e 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
@@ -551,6 +551,7 @@
       throw ArgumentExceptionFactory.unknownSubType(relation, typeName,
           typeUsage);
     }
+    Message ufn = d.getUserFriendlyName();
 
     // Get the naming argument values.
     List<String> names = getNamingArgValues(app, namingArgs);
@@ -566,34 +567,33 @@
     try {
       result = getManagedObject(app, context, path, names);
     } catch (AuthorizationException e) {
-      Message msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(d.getUserFriendlyName());
+      Message msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(ufn);
       throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
     } catch (DefinitionDecodingException e) {
-      Message ufn = path.getManagedObjectDefinition().getUserFriendlyName();
-      Message msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(ufn, ufn, ufn);
+      Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
+      Message msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(pufn, pufn, pufn);
       throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
     } catch (ManagedObjectDecodingException e) {
-      Message ufn = path.getManagedObjectDefinition().getUserFriendlyName();
-      Message msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(ufn);
+      Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
+      Message msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn);
       throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
     } catch (CommunicationException e) {
-      Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(d.getUserFriendlyName(), e
+      Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e
           .getMessage());
       throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
     } catch (ConcurrentModificationException e) {
-      Message msg = ERR_DSCFG_ERROR_CREATE_CME.get(d.getUserFriendlyName());
+      Message msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn);
       throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
     } catch (ManagedObjectNotFoundException e) {
-      Message ufn = path.getManagedObjectDefinition().getUserFriendlyName();
-      Message msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(ufn);
+      Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
+      Message msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(pufn);
       throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
     }
 
     if (result.isQuit()) {
       if (!app.isMenuDrivenMode()) {
         // User chose to cancel creation.
-        Message msg = INFO_DSCFG_CONFIRM_CREATE_FAIL.get(d
-            .getUserFriendlyName());
+        Message msg = INFO_DSCFG_CONFIRM_CREATE_FAIL.get(ufn);
         app.printVerboseMessage(msg);
       }
       return MenuResult.quit();
@@ -603,46 +603,46 @@
     }
 
     ManagedObject<?> parent = result.getValue();
-    try {
-      ManagedObject<? extends C> child;
-      List<DefaultBehaviorException> exceptions =
-        new LinkedList<DefaultBehaviorException>();
-      if (relation instanceof InstantiableRelationDefinition) {
-        InstantiableRelationDefinition<C, S> irelation =
-          (InstantiableRelationDefinition<C, S>) relation;
-        String name = names.get(names.size() - 1);
-        if (name == null) {
-          if (app.isInteractive()) {
-            child = createChildInteractively(app, parent, irelation,
-                d, exceptions);
-          } else {
-            throw ArgumentExceptionFactory
-                .missingMandatoryNonInteractiveArgument(namingArgs.get(names
-                    .size() - 1));
-          }
+    ManagedObject<? extends C> child;
+    List<DefaultBehaviorException> exceptions =
+      new LinkedList<DefaultBehaviorException>();
+    if (relation instanceof InstantiableRelationDefinition) {
+      InstantiableRelationDefinition<C, S> irelation =
+        (InstantiableRelationDefinition<C, S>) relation;
+      String name = names.get(names.size() - 1);
+      if (name == null) {
+        if (app.isInteractive()) {
+          child = createChildInteractively(app, parent, irelation,
+              d, exceptions);
         } else {
-          try {
-            child = parent.createChild(irelation, d, name,
-                exceptions);
-          } catch (IllegalManagedObjectNameException e) {
-            throw ArgumentExceptionFactory
-                .adaptIllegalManagedObjectNameException(e, d);
-          }
+          throw ArgumentExceptionFactory
+              .missingMandatoryNonInteractiveArgument(namingArgs.get(names
+                  .size() - 1));
         }
       } else {
-        OptionalRelationDefinition<C, S> orelation =
-          (OptionalRelationDefinition<C, S>) relation;
-        child = parent.createChild(orelation, d, exceptions);
+        try {
+          child = parent.createChild(irelation, d, name,
+              exceptions);
+        } catch (IllegalManagedObjectNameException e) {
+          throw ArgumentExceptionFactory
+              .adaptIllegalManagedObjectNameException(e, d);
+        }
       }
+    } else {
+      OptionalRelationDefinition<C, S> orelation =
+        (OptionalRelationDefinition<C, S>) relation;
+      child = parent.createChild(orelation, d, exceptions);
+    }
 
-      // FIXME: display any default behavior exceptions in verbose
-      // mode.
+    // FIXME: display any default behavior exceptions in verbose
+    // mode.
 
-      // Set any properties specified on the command line.
-      for (PropertyDefinition<?> pd : provider.getProperties()) {
-        setProperty(child, provider, pd);
-      }
+    // Set any properties specified on the command line.
+    for (PropertyDefinition<?> pd : provider.getProperties()) {
+      setProperty(child, provider, pd);
+    }
 
+    while (true) {
       // Interactively set properties if applicable.
       if (app.isInteractive()) {
         SortedSet<PropertyDefinition<?>> properties =
@@ -664,8 +664,7 @@
         MenuResult<Void> result2 = editor.edit(child, properties, true);
         if (result2.isQuit()) {
           if (!app.isMenuDrivenMode()) {
-            Message msg = INFO_DSCFG_CONFIRM_CREATE_FAIL.get(d
-                .getUserFriendlyName());
+            Message msg = INFO_DSCFG_CONFIRM_CREATE_FAIL.get(ufn);
             app.printVerboseMessage(msg);
           }
           return MenuResult.quit();
@@ -674,42 +673,64 @@
         }
       }
 
-      // Add the managed object.
-      child.commit();
+      try {
+        // Create the managed object.
+        child.commit();
 
-      // Output success message.
-      Message msg = INFO_DSCFG_CONFIRM_CREATE_SUCCESS.get(d
-          .getUserFriendlyName());
-      app.printVerboseMessage(msg);
-    } catch (MissingMandatoryPropertiesException e) {
-      throw ArgumentExceptionFactory.adaptMissingMandatoryPropertiesException(
-          e, d);
-    } catch (AuthorizationException e) {
-      Message msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(d.getUserFriendlyName());
-      throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
-    } catch (ManagedObjectAlreadyExistsException e) {
-      Message msg = ERR_DSCFG_ERROR_CREATE_MOAEE.get(d.getUserFriendlyName());
-      throw new ClientException(LDAPResultCode.ENTRY_ALREADY_EXISTS, msg);
-    } catch (ConcurrentModificationException e) {
-      Message msg = ERR_DSCFG_ERROR_CREATE_CME.get(d.getUserFriendlyName());
-      throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
-    } catch (OperationRejectedException e) {
-      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());
+        // Output success message.
+        Message msg = INFO_DSCFG_CONFIRM_CREATE_SUCCESS.get(ufn);
+        app.printVerboseMessage(msg);
+        return MenuResult.success(0);
+      } catch (MissingMandatoryPropertiesException e) {
+        throw ArgumentExceptionFactory.adaptMissingMandatoryPropertiesException(
+            e, d);
+      } catch (AuthorizationException e) {
+        Message msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(ufn);
+        throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS,
+            msg);
+      } catch (ManagedObjectAlreadyExistsException e) {
+        Message msg = ERR_DSCFG_ERROR_CREATE_MOAEE.get(ufn);
+        throw new ClientException(LDAPResultCode.ENTRY_ALREADY_EXISTS, msg);
+      } catch (ConcurrentModificationException e) {
+        Message msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn);
+        throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
+      } catch (OperationRejectedException e) {
+        Message msg;
+        if (e.getMessages().size() == 1) {
+          msg = ERR_DSCFG_ERROR_CREATE_ORE_SINGLE.get(ufn);
+        } else {
+          msg = ERR_DSCFG_ERROR_CREATE_ORE_PLURAL.get(ufn);
+        }
+
+        if (app.isInteractive()) {
+          // If interactive, give the user the chance to fix the problems.
+          app.println();
+          app.println(msg);
+          app.println();
+          TableBuilder builder = new TableBuilder();
+          for (Message reason : e.getMessages()) {
+            builder.startRow();
+            builder.appendCell("*");
+            builder.appendCell(reason);
+          }
+          TextTablePrinter printer = new TextTablePrinter(app.getErrorStream());
+          printer.setDisplayHeadings(false);
+          printer.setColumnWidth(1, 0);
+          printer.setIndentWidth(4);
+          builder.print(printer);
+          app.println();
+          if (!app.confirmAction(INFO_DSCFG_PROMPT_EDIT_AGAIN.get(ufn), true)) {
+            return MenuResult.cancel();
+          }
+        } else {
+          throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION,
+              msg, e);
+        }
+      } catch (CommunicationException e) {
+        Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e.getMessage());
+        throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
       }
-      throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
-    } catch (CommunicationException e) {
-      Message msg = ERR_DSCFG_ERROR_CREATE_CE.get(d.getUserFriendlyName(), e
-          .getMessage());
-      throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
     }
-
-    return MenuResult.success(0);
   }
 
 
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java b/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java
index ed72af1..3092f5f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java
@@ -54,6 +54,7 @@
 import org.opends.server.admin.RelationDefinition;
 import org.opends.server.admin.Tag;
 import org.opends.server.admin.client.ManagedObjectDecodingException;
+import org.opends.server.admin.client.OperationRejectedException;
 import org.opends.server.loggers.debug.DebugTracer;
 import org.opends.server.tools.ClientException;
 import org.opends.server.types.DebugLogLevel;
@@ -849,6 +850,24 @@
         TextTablePrinter printer = new TextTablePrinter(getErrorStream());
         printer.setDisplayHeadings(false);
         printer.setColumnWidth(1, 0);
+        printer.setIndentWidth(4);
+        builder.print(printer);
+        println();
+      } else if (cause instanceof OperationRejectedException) {
+        OperationRejectedException ore = (OperationRejectedException) cause;
+
+        println();
+        TableBuilder builder = new TableBuilder();
+        for (Message reason : ore.getMessages()) {
+          builder.startRow();
+          builder.appendCell("*");
+          builder.appendCell(reason);
+        }
+
+        TextTablePrinter printer = new TextTablePrinter(getErrorStream());
+        printer.setDisplayHeadings(false);
+        printer.setColumnWidth(1, 0);
+        printer.setIndentWidth(4);
         builder.print(printer);
         println();
       }
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java b/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
index 7abde48..8c30ab6 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
@@ -56,6 +56,8 @@
 import org.opends.server.util.cli.CLIException;
 import org.opends.server.util.cli.ConsoleApplication;
 import org.opends.server.util.cli.MenuResult;
+import org.opends.server.util.table.TableBuilder;
+import org.opends.server.util.table.TextTablePrinter;
 
 
 
@@ -204,33 +206,31 @@
     // Delete the child managed object.
     ManagementContext context = factory.getManagementContext(app);
     MenuResult<ManagedObject<?>> result;
+    Message ufn = relation.getUserFriendlyName();
     try {
       result = getManagedObject(app, context, path, names);
     } catch (AuthorizationException e) {
-      Message msg = ERR_DSCFG_ERROR_DELETE_AUTHZ.get(relation
-          .getUserFriendlyName());
+      Message msg = ERR_DSCFG_ERROR_DELETE_AUTHZ.get(ufn);
       throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
     } catch (DefinitionDecodingException e) {
-      Message ufn = path.getManagedObjectDefinition().getUserFriendlyName();
-      Message msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(ufn, ufn, ufn);
+      Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
+      Message msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(pufn, pufn, pufn);
       throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
     } catch (ManagedObjectDecodingException e) {
-      Message ufn = path.getManagedObjectDefinition().getUserFriendlyName();
-      Message msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(ufn);
+      Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
+      Message msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn);
       throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg, e);
     } catch (CommunicationException e) {
-      Message msg = ERR_DSCFG_ERROR_DELETE_CE.get(relation
-          .getUserFriendlyName(), e.getMessage());
+      Message msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage());
       throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
     } catch (ConcurrentModificationException e) {
-      Message msg = ERR_DSCFG_ERROR_DELETE_CME.get(relation
-          .getUserFriendlyName());
+      Message msg = ERR_DSCFG_ERROR_DELETE_CME.get(ufn);
       throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
     } catch (ManagedObjectNotFoundException e) {
       // Ignore the error if the deletion is being forced.
       if (!forceArgument.isPresent()) {
-        Message ufn = path.getManagedObjectDefinition().getUserFriendlyName();
-        Message msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(ufn);
+        Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
+        Message msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(pufn);
         throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
       } else {
         return MenuResult.success(0);
@@ -240,8 +240,7 @@
     if (result.isQuit()) {
       if (!app.isMenuDrivenMode()) {
         // User chose to cancel deletion.
-        Message msg = INFO_DSCFG_CONFIRM_DELETE_FAIL.get(relation
-            .getUserFriendlyName());
+        Message msg = INFO_DSCFG_CONFIRM_DELETE_FAIL.get(ufn);
         app.printVerboseMessage(msg);
       }
       return MenuResult.quit();
@@ -264,8 +263,7 @@
           if (sresult.isQuit()) {
             if (!app.isMenuDrivenMode()) {
               // User chose to cancel deletion.
-              Message msg = INFO_DSCFG_CONFIRM_DELETE_FAIL.get(relation
-                  .getUserFriendlyName());
+              Message msg = INFO_DSCFG_CONFIRM_DELETE_FAIL.get(ufn);
               app.printVerboseMessage(msg);
             }
             return MenuResult.quit();
@@ -293,39 +291,53 @@
         }
       }
     } catch (AuthorizationException e) {
-      Message msg = ERR_DSCFG_ERROR_DELETE_AUTHZ.get(relation
-          .getUserFriendlyName());
+      Message msg = ERR_DSCFG_ERROR_DELETE_AUTHZ.get(ufn);
       throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
     } catch (OperationRejectedException e) {
       Message msg;
       if (e.getMessages().size() == 1) {
-        msg = ERR_DSCFG_ERROR_DELETE_ORE_SINGLE.get(relation
-            .getUserFriendlyName(), e.getMessagesAsSingleMessage());
+        msg = ERR_DSCFG_ERROR_DELETE_ORE_SINGLE.get(ufn);
       } else {
-        msg = ERR_DSCFG_ERROR_DELETE_ORE_PLURAL.get(relation
-            .getUserFriendlyName(), e.getMessagesAsSingleMessage());
+        msg = ERR_DSCFG_ERROR_DELETE_ORE_PLURAL.get(ufn);
       }
-      throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
+
+      if (app.isInteractive()) {
+        // If interactive, let the user go back to the main menu.
+        app.println();
+        app.println(msg);
+        app.println();
+        TableBuilder builder = new TableBuilder();
+        for (Message reason : e.getMessages()) {
+          builder.startRow();
+          builder.appendCell("*");
+          builder.appendCell(reason);
+        }
+        TextTablePrinter printer = new TextTablePrinter(app.getErrorStream());
+        printer.setDisplayHeadings(false);
+        printer.setColumnWidth(1, 0);
+        printer.setIndentWidth(4);
+        builder.print(printer);
+        return MenuResult.cancel();
+      } else {
+        throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION,
+            msg, e);
+      }
     } catch (ManagedObjectNotFoundException e) {
       // Ignore the error if the deletion is being forced.
       if (!forceArgument.isPresent()) {
-        Message msg = ERR_DSCFG_ERROR_DELETE_MONFE.get(relation
-            .getUserFriendlyName());
+        Message msg = ERR_DSCFG_ERROR_DELETE_MONFE.get(ufn);
         throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
       }
     } catch (ConcurrentModificationException e) {
-      Message msg = ERR_DSCFG_ERROR_DELETE_CME.get(relation
-          .getUserFriendlyName());
+      Message msg = ERR_DSCFG_ERROR_DELETE_CME.get(ufn);
       throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
     } catch (CommunicationException e) {
-      Message msg = ERR_DSCFG_ERROR_DELETE_CE.get(relation
-          .getUserFriendlyName(), e.getMessage());
+      Message msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage());
       throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg);
     }
 
     // Output success message.
-    Message msg = INFO_DSCFG_CONFIRM_DELETE_SUCCESS.get(relation
-        .getUserFriendlyName());
+    Message msg = INFO_DSCFG_CONFIRM_DELETE_SUCCESS.get(ufn);
     app.printVerboseMessage(msg);
 
     return MenuResult.success(0);
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java b/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
index 0ec55f8..c73ec36 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
@@ -69,6 +69,8 @@
 import org.opends.server.util.cli.CLIException;
 import org.opends.server.util.cli.ConsoleApplication;
 import org.opends.server.util.cli.MenuResult;
+import org.opends.server.util.table.TableBuilder;
+import org.opends.server.util.table.TextTablePrinter;
 
 
 
@@ -498,7 +500,7 @@
       }
     }
 
-    // Commit the changes.
+    // Apply the command line changes.
     for (PropertyDefinition<?> pd : changes.keySet()) {
       try {
         child.setPropertyValues(pd, changes.get(pd));
@@ -507,71 +509,97 @@
       }
     }
 
-    // Interactively set properties if applicable.
-    if (app.isInteractive()) {
-      SortedSet<PropertyDefinition<?>> properties =
-        new TreeSet<PropertyDefinition<?>>();
+    while (true) {
+      // Interactively set properties if applicable.
+      if (app.isInteractive()) {
+        SortedSet<PropertyDefinition<?>> properties =
+          new TreeSet<PropertyDefinition<?>>();
 
-      for (PropertyDefinition<?> pd : d.getAllPropertyDefinitions()) {
-        if (pd.hasOption(PropertyOption.HIDDEN)) {
-          continue;
+        for (PropertyDefinition<?> pd : d.getAllPropertyDefinitions()) {
+          if (pd.hasOption(PropertyOption.HIDDEN)) {
+            continue;
+          }
+
+          if (!app.isAdvancedMode() && pd.hasOption(PropertyOption.ADVANCED)) {
+            continue;
+          }
+
+          properties.add(pd);
         }
 
-        if (!app.isAdvancedMode() && pd.hasOption(PropertyOption.ADVANCED)) {
-          continue;
+        PropertyValueEditor editor = new PropertyValueEditor(app);
+        MenuResult<Void> result2 = editor.edit(child, properties, false);
+        if (result2.isQuit()) {
+          if (!app.isMenuDrivenMode()) {
+            // User chose to cancel any changes.
+            Message msg = INFO_DSCFG_CONFIRM_MODIFY_FAIL.get(ufn);
+            app.printVerboseMessage(msg);
+          }
+          return MenuResult.quit();
+        } else if (result2.isCancel()) {
+          return MenuResult.cancel();
         }
-
-        properties.add(pd);
       }
 
-      PropertyValueEditor editor = new PropertyValueEditor(app);
-      MenuResult<Void> result2 = editor.edit(child, properties, false);
-      if (result2.isQuit()) {
-        if (!app.isMenuDrivenMode()) {
-          // User chose to cancel any changes.
-          Message msg = INFO_DSCFG_CONFIRM_MODIFY_FAIL.get(ufn);
-          app.printVerboseMessage(msg);
+      try {
+        // Commit the changes.
+        child.commit();
+
+        // Output success message.
+        Message msg = INFO_DSCFG_CONFIRM_MODIFY_SUCCESS.get(ufn);
+        app.printVerboseMessage(msg);
+
+        return MenuResult.success(0);
+      } catch (MissingMandatoryPropertiesException e) {
+        throw ArgumentExceptionFactory
+            .adaptMissingMandatoryPropertiesException(e, d);
+      } catch (AuthorizationException e) {
+        Message msg = ERR_DSCFG_ERROR_MODIFY_AUTHZ.get(ufn);
+        throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS,
+            msg);
+      } catch (ConcurrentModificationException e) {
+        Message msg = ERR_DSCFG_ERROR_MODIFY_CME.get(ufn);
+        throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
+      } catch (OperationRejectedException e) {
+        Message msg;
+        if (e.getMessages().size() == 1) {
+          msg = ERR_DSCFG_ERROR_MODIFY_ORE_SINGLE.get(ufn);
+        } else {
+          msg = ERR_DSCFG_ERROR_MODIFY_ORE_PLURAL.get(ufn);
         }
-        return MenuResult.quit();
-      } else if (result2.isCancel()) {
-        return MenuResult.cancel();
+
+        if (app.isInteractive()) {
+          // If interactive, give the user the chance to fix the problems.
+          app.println();
+          app.println(msg);
+          app.println();
+          TableBuilder builder = new TableBuilder();
+          for (Message reason : e.getMessages()) {
+            builder.startRow();
+            builder.appendCell("*");
+            builder.appendCell(reason);
+          }
+          TextTablePrinter printer = new TextTablePrinter(app.getErrorStream());
+          printer.setDisplayHeadings(false);
+          printer.setColumnWidth(1, 0);
+          printer.setIndentWidth(4);
+          builder.print(printer);
+          app.println();
+          if (!app.confirmAction(INFO_DSCFG_PROMPT_EDIT_AGAIN.get(ufn), true)) {
+            return MenuResult.cancel();
+          }
+        } else {
+          throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION,
+              msg, e);
+        }
+      } catch (CommunicationException e) {
+        Message msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage());
+        throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
+      } catch (ManagedObjectAlreadyExistsException e) {
+        // Should never happen.
+        throw new IllegalStateException(e);
       }
     }
-
-    try {
-      child.commit();
-
-      // Output success message.
-      Message msg = INFO_DSCFG_CONFIRM_MODIFY_SUCCESS.get(ufn);
-      app.printVerboseMessage(msg);
-    } catch (MissingMandatoryPropertiesException e) {
-      throw ArgumentExceptionFactory.adaptMissingMandatoryPropertiesException(
-          e, d);
-    } catch (AuthorizationException e) {
-      Message msg = ERR_DSCFG_ERROR_MODIFY_AUTHZ.get(ufn);
-      throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg);
-    } catch (ConcurrentModificationException e) {
-      Message msg = ERR_DSCFG_ERROR_MODIFY_CME.get(ufn);
-      throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
-    } catch (OperationRejectedException e) {
-      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());
-      throw new ClientException(LDAPResultCode.OPERATIONS_ERROR, msg);
-    } catch (ManagedObjectAlreadyExistsException e) {
-      // Should never happen.
-      throw new IllegalStateException(e);
-    }
-
-    return MenuResult.success(0);
   }
 
 

--
Gitblit v1.10.0