From bd458262d71f8a331082e8b4d00a2f47b0eaa3fd Mon Sep 17 00:00:00 2001
From: jcambon <jcambon@localhost>
Date: Wed, 28 Jan 2009 17:01:42 +0000
Subject: [PATCH] Fix for Issue #3760 dsconfig exits abruptly when creating a component with a missing parent (cont'd). Fix for Issue #3761 dsconfig exits abruptly when creating a component with the same name.

---
 opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java b/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
index a17bd95..b9a23c2 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
@@ -796,7 +796,13 @@
         throw new ClientException(LDAPResultCode.OTHER, msg);
       } catch (ManagedObjectAlreadyExistsException e) {
         Message msg = ERR_DSCFG_ERROR_CREATE_MOAEE.get(ufn);
-        throw new ClientException(LDAPResultCode.ENTRY_ALREADY_EXISTS, msg);
+        if (app.isInteractive()) {
+          app.println();
+          app.printVerboseMessage(msg);
+          return MenuResult.cancel();
+        } else {
+          throw new ClientException(LDAPResultCode.ENTRY_ALREADY_EXISTS, msg);
+        }
       }
     }
   }
@@ -1237,9 +1243,13 @@
     } catch (ManagedObjectNotFoundException e) {
       Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
       Message msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(pufn);
-      app.println();
-      app.printVerboseMessage(msg);
-      return MenuResult.cancel();
+      if (app.isInteractive()) {
+        app.println();
+        app.printVerboseMessage(msg);
+        return MenuResult.cancel();
+      } else {
+        throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
+      }
     }
 
     if (result.isQuit()) {

--
Gitblit v1.10.0