From ce99899b787aaacd25aeb04dd4b8efee3a037b0c Mon Sep 17 00:00:00 2001
From: jcambon <jcambon@localhost>
Date: Thu, 05 Mar 2009 11:09:19 +0000
Subject: [PATCH] Fix for issue #3852 : dsconfig : in interactive mode, should not exit if parent component does not exist
---
opends/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java | 8 +++++++-
opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java | 20 ++++++++++++++++++--
opends/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java | 10 ++++++++--
opends/src/messages/messages/dsconfig.properties | 2 ++
opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java | 8 +++++++-
5 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/opends/src/messages/messages/dsconfig.properties b/opends/src/messages/messages/dsconfig.properties
index 3003035..568f84d 100644
--- a/opends/src/messages/messages/dsconfig.properties
+++ b/opends/src/messages/messages/dsconfig.properties
@@ -262,6 +262,8 @@
INFO_DSCFG_FINDER_PROMPT_SINGLE_1232=>>>> There is only one %s: "%s". Are you sure \
that this is the correct one?
INFO_DSCFG_FINDER_PROMPT_MANY_1233=>>>> Select the %s from the following list:
+SEVERE_ERR_DSCFG_ERROR_FINDER_NO_CHILDREN_NULL_1234=Unable to continue since there \
+ is no such an object currently configured on the server
INFO_DSCFG_GENERAL_CHOICE_PROMPT_NOHELP_1237=Enter choice [1 - %d]:
INFO_DSCFG_GENERAL_CHOICE_PROMPT_HELP_1238=Enter choice [1 - %d, ? - help]:
SEVERE_ERR_DSCFG_ERROR_GENERAL_CHOICE_1239=Invalid response. Please enter a \
diff --git a/opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java b/opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
index 6ab4000..7fcc7d5 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
@@ -261,7 +261,13 @@
if (!forceArgument.isPresent()) {
Message pufn = path.getManagedObjectDefinition().getUserFriendlyName();
Message msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(pufn);
- throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
+ if (app.isInteractive()) {
+ app.println();
+ app.printVerboseMessage(msg);
+ return MenuResult.cancel();
+ } else {
+ throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
+ }
} else {
return MenuResult.success(0);
}
diff --git a/opends/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java b/opends/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
index 247da4f..032ea9c 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
@@ -272,7 +272,13 @@
} catch (ManagedObjectNotFoundException e) {
ufn = path.getManagedObjectDefinition().getUserFriendlyName();
Message msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(ufn);
- throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
+ if (app.isInteractive()) {
+ app.println();
+ app.printVerboseMessage(msg);
+ return MenuResult.cancel();
+ } else {
+ throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
+ }
}
if (result.isQuit()) {
diff --git a/opends/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java b/opends/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
index 6ffacc3..c0b98c1 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2008-2009 Sun Microsystems, Inc.
*/
package org.opends.server.tools.dsconfig;
@@ -151,7 +151,13 @@
Message pufn = path.getManagedObjectDefinition()
.getUserFriendlyName();
Message msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(pufn);
- throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
+ if (app.isInteractive()) {
+ app.println();
+ app.printVerboseMessage(msg);
+ return MenuResult.cancel();
+ } else {
+ throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg);
+ }
}
// Now let the user create the child component.
diff --git a/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java b/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
index 29a77c7..737c4b2 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
@@ -722,8 +722,24 @@
Message msg = ERR_DSCFG_ERROR_MODIFY_CME.get(ufn);
throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg);
} catch (ManagedObjectNotFoundException e) {
- throw ArgumentExceptionFactory.unknownValueForChildComponent(
- "\"" + names.get(names.size()-1) + "\"");
+ String objName = names.get(names.size() - 1);
+ ArgumentException except = null;
+ Message msg;
+ // if object name is 'null', get a user-friendly string to represent this
+ if (objName == null) {
+ msg = ERR_DSCFG_ERROR_FINDER_NO_CHILDREN_NULL.get();
+ except = new ArgumentException(msg);
+ } else {
+ except = ArgumentExceptionFactory.unknownValueForChildComponent(
+ "\"" + objName + "\"");
+ }
+ if (app.isInteractive()) {
+ app.println();
+ app.printVerboseMessage(except.getMessageObject());
+ return MenuResult.cancel();
+ } else {
+ throw except;
+ }
}
if (result.isQuit()) {
--
Gitblit v1.10.0