From fe9d45d7f26b89b9fb2b87011e1656d4feecf551 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Mon, 24 Mar 2014 14:07:56 +0000
Subject: [PATCH] OPENDJ-1343 Migrate dsconfig - Removed CommunicationException from dsconfig package. - Replaced ReturnCode.TODO by appropriate return code.
---
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java | 9 +---
opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java | 17 ++++----
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java | 4 --
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java | 4 +-
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java | 4 --
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java | 18 ++++----
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java | 31 +++------------
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java | 7 ---
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java | 4 --
9 files changed, 27 insertions(+), 71 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
index f39d1b7..73b51d6 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
+++ b/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);
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
index 7d351bb..764d5e3 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
+++ b/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);
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java
index a7090b6..5fbfc20 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java
+++ b/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);
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
index 394240e..a9896cc 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
+++ b/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);
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
index f2675bd..3f50667 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
+++ b/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();
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
index ba4e1e3..f999cff 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
+++ b/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);
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
index f1da683..314c870 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
+++ b/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();
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java b/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
index 64a435e..73ab45f 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
+++ b/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));
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java b/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java
index 090c453..714c594 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java
+++ b/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);
}
}
--
Gitblit v1.10.0