From 9c88e7e8be7dde117ada9ae483d535b99c6c11dc Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Tue, 25 Feb 2014 10:35:48 +0000
Subject: [PATCH] Checkpoint OPENDJ-1343 Migrate dsconfig - Code cleanup. Thanks to AutoRefactor ;)
---
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CLIProfile.java | 15
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java | 99 ++--
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java | 1
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java | 104 ++---
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java | 34 -
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java | 50 +-
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java | 272 +++++-------
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java | 25
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java | 2
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java | 28 -
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java | 95 ++--
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java | 46 -
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java | 117 ++---
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java | 2
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java | 247 +++++-------
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyEditorModification.java | 13
16 files changed, 484 insertions(+), 666 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CLIProfile.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CLIProfile.java
index 83d797a..abfc203 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CLIProfile.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CLIProfile.java
@@ -22,6 +22,7 @@
*
*
* Copyright 2009 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.tools.dsconfig;
@@ -45,7 +46,7 @@
*/
final class CLIProfile {
- // The singleton instance.
+ /** The singleton instance. */
private static final CLIProfile INSTANCE = new CLIProfile();
@@ -59,12 +60,12 @@
return INSTANCE;
}
- // The CLI profile property table.
+ /** The CLI profile property table. */
private final ManagedObjectDefinitionResource resource;
- // Private constructor.
+ /** Private constructor. */
private CLIProfile() {
this.resource = ManagedObjectDefinitionResource.createForProfile("cli");
}
@@ -81,13 +82,12 @@
* displayed in a list-xxx operation.
*/
public Set<String> getDefaultListPropertyNames(RelationDefinition<?, ?> r) {
- String s = resource.getString(r.getParentDefinition(), "relation."
+ final String s = resource.getString(r.getParentDefinition(), "relation."
+ r.getName() + ".list-properties");
if (s.trim().length() == 0) {
return Collections.emptySet();
- } else {
- return new LinkedHashSet<String>(Arrays.asList(s.split(",")));
}
+ return new LinkedHashSet<String>(Arrays.asList(s.split(",")));
}
@@ -145,7 +145,6 @@
* customization.
*/
public boolean isForCustomization(AbstractManagedObjectDefinition<?, ?> d) {
- String s = resource.getString(d, "is-for-customization");
- return Boolean.parseBoolean(s);
+ return Boolean.parseBoolean(resource.getString(d, "is-for-customization"));
}
}
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 6d2f545..ca95e13 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
@@ -116,7 +116,7 @@
*/
private static class MyPropertyProvider implements PropertyProvider {
- // Decoded set of properties.
+ /** Decoded set of properties. */
private final Map<PropertyDefinition<?>, Collection<?>> properties =
new HashMap<PropertyDefinition<?>, Collection<?>>();
@@ -190,23 +190,20 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@SuppressWarnings("unchecked")
public <T> Collection<T> getPropertyValues(PropertyDefinition<T> d)
throws IllegalArgumentException {
Collection<T> values = (Collection<T>) properties.get(d);
if (values == null) {
return Collections.emptySet();
- } else {
- return values;
}
+ return values;
}
- // Add a single property value.
+ /** Add a single property value. */
@SuppressWarnings("unchecked")
private <T> void addPropertyValue(ManagedObjectDefinition<?, ?> d,
PropertyDefinition<T> pd, String s) throws ArgumentException {
@@ -242,21 +239,19 @@
<C extends ConfigurationClient, S extends Configuration>
implements HelpCallback {
- // The abstract definition for which to provide help on its sub-types.
+ /** The abstract definition for which to provide help on its sub-types. */
private final AbstractManagedObjectDefinition<C, S> d;
- // Create a new type help call-back.
+ /** Create a new type help call-back. */
private TypeHelpCallback(AbstractManagedObjectDefinition<C, S> d) {
this.d = d;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void display(ConsoleApplication app) {
app.println(INFO_DSCFG_CREATE_TYPE_HELP_HEADING.get(d
.getUserFriendlyPluralName()));
@@ -557,8 +552,9 @@
- // Check that any referenced components are enabled if
- // required.
+ /**
+ * Check that any referenced components are enabled if required.
+ */
private static MenuResult<Void> checkReferences(ConsoleApplication app,
ManagementContext context, ManagedObject<?> mo, SubCommandHandler handler)
throws ClientException, ClientException
@@ -685,9 +681,8 @@
if (app.confirmAction(INFO_DSCFG_PROMPT_EDIT_AGAIN.get(ufn),
true)) {
return MenuResult.again();
- } else {
- return MenuResult.cancel();
}
+ return MenuResult.cancel();
}
}
}
@@ -706,7 +701,7 @@
- // Commit a new managed object's configuration.
+ /** Commit a new managed object's configuration. */
private static MenuResult<Void> commitManagedObject(ConsoleApplication app,
ManagementContext context, ManagedObject<?> mo, SubCommandHandler handler)
throws ClientException {
@@ -837,7 +832,7 @@
- // Interactively create the child by prompting for the name.
+ /** Interactively create the child by prompting for the name. */
private static <C extends ConfigurationClient, S extends Configuration>
ManagedObject<? extends C> createChildInteractively(
ConsoleApplication app, final ManagedObject<?> parent,
@@ -941,7 +936,7 @@
- // Interactively ask the user which type of component they want to create.
+ /** Interactively ask the user which type of component they want to create. */
private static <C extends ConfigurationClient, S extends Configuration>
MenuResult<ManagedObjectDefinition<? extends C, ? extends S>>
getTypeInteractively(ConsoleApplication app,
@@ -1022,42 +1017,47 @@
- // The sub-commands naming arguments.
+ /** The sub-commands naming arguments. */
private final List<StringArgument> namingArgs;
- // The optional naming property definition.
+ /** The optional naming property definition. */
private final PropertyDefinition<?> namingPropertyDefinition;
- // The path of the parent managed object.
+ /** The path of the parent managed object. */
private final ManagedObjectPath<?, ?> path;
- // The argument which should be used to specify zero or more
- // property values.
+ /**
+ * The argument which should be used to specify zero or more property values.
+ */
private final StringArgument propertySetArgument;
- // The relation which should be used for creating children.
+ /** The relation which should be used for creating children. */
private final RelationDefinition<C, S> relation;
- // The sub-command associated with this handler.
+ /** The sub-command associated with this handler. */
private final SubCommand subCommand;
- // The argument which should be used to specify the type of managed
- // object to be created.
+ /**
+ * The argument which should be used to specify the type of managed object to
+ * be created.
+ */
private final StringArgument typeArgument;
- // The set of instantiable managed object definitions and their
- // associated type option value.
+ /**
+ * The set of instantiable managed object definitions and their associated
+ * type option value.
+ */
private final SortedMap<String,
ManagedObjectDefinition<? extends C, ? extends S>> types;
- // The syntax of the type argument.
+ /** The syntax of the type argument. */
private final String typeUsage;
- // Common constructor.
+ /** Common constructor. */
private CreateSubCommandHandler(
SubCommandArgumentParser parser, ManagedObjectPath<?, ?> p,
RelationDefinition<C, S> r, PropertyDefinition<?> pd,
@@ -1134,9 +1134,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public SubCommand getSubCommand() {
return subCommand;
@@ -1144,9 +1142,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public MenuResult<Integer> run(ConsoleApplication app,
ManagementContextFactory factory) throws ArgumentException,
@@ -1384,8 +1380,8 @@
for (String value2 : arg.getValues())
{
String prop2Name;
- if (arg.getName().equals(OPTION_DSCFG_LONG_SET) ||
- arg.getName().equals(OPTION_DSCFG_LONG_REMOVE))
+ if (OPTION_DSCFG_LONG_SET.equals(arg.getName()) ||
+ OPTION_DSCFG_LONG_REMOVE.equals(arg.getName()))
{
int index2 = value2.indexOf(':');
if (index2 != -1)
@@ -1397,7 +1393,7 @@
prop2Name = null;
}
}
- else if (arg.getName().equals(OPTION_DSCFG_LONG_RESET))
+ else if (OPTION_DSCFG_LONG_RESET.equals(arg.getName()))
{
prop2Name = value2;
}
@@ -1405,13 +1401,10 @@
{
prop2Name = null;
}
- if (prop2Name != null)
+ if (prop2Name != null && prop2Name.equalsIgnoreCase(propName))
{
- if (prop2Name.equalsIgnoreCase(propName))
- {
- addValue = false;
- break;
- }
+ addValue = false;
+ break;
}
}
if (!addValue)
@@ -1440,11 +1433,11 @@
getCommandBuilder().getArguments());
for (Argument arg : argsCopy)
{
- if (arg != null) {
- if (arg.getName().equals(OPTION_DSCFG_LONG_RESET) ||
- arg.getName().equals(OPTION_DSCFG_LONG_REMOVE)) {
- getCommandBuilder().removeArgument(arg);
- }
+ if (arg != null
+ && (OPTION_DSCFG_LONG_RESET.equals(arg.getName())
+ || OPTION_DSCFG_LONG_REMOVE.equals(arg.getName())))
+ {
+ getCommandBuilder().removeArgument(arg);
}
}
@@ -1473,7 +1466,7 @@
- // Set a property's initial values.
+ /** Set a property's initial values. */
private <T> void setProperty(ManagedObject<?> mo,
MyPropertyProvider provider, PropertyDefinition<T> pd) {
Collection<T> values = provider.getPropertyValues(pd);
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java
index 0d16ad7..f0f6ee6 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java
@@ -76,8 +76,6 @@
import org.opends.server.types.InitializationException;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.EmbeddedUtils;
-import org.opends.server.util.ServerConstants;
-import org.opends.server.util.StaticUtils;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
@@ -103,11 +101,16 @@
public final class DSConfig extends ConsoleApplication {
/**
+ * The name of this tool.
+ */
+ final static String DSCONFIGTOOLNAME = "dsconfig";
+
+ /**
* A menu call-back which runs a sub-command interactively.
*/
private class SubCommandHandlerMenuCallback implements MenuCallback<Integer> {
- // The sub-command handler.
+ /** The sub-command handler. */
private final SubCommandHandler handler;
@@ -124,9 +127,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public MenuResult<Integer> invoke(ConsoleApplication app)
throws ClientException {
@@ -163,7 +164,7 @@
*/
private class SubMenuCallback implements MenuCallback<Integer> {
- // The menu.
+ /** The menu. */
private final Menu<Integer> menu;
@@ -254,9 +255,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public final MenuResult<Integer> invoke(ConsoleApplication app)
throws ClientException {
@@ -293,7 +292,7 @@
*/
public static final String GENERIC_TYPE = "generic";
- // This CLI is always using the administration connector with SSL
+ /** This CLI is always using the administration connector with SSL. */
private static final boolean alwaysSSL = true;
private long sessionStartTime;
@@ -357,67 +356,81 @@
return app.run(args);
}
- // The argument which should be used to request advanced mode.
+ /** The argument which should be used to request advanced mode. */
private BooleanArgument advancedModeArgument;
- // Flag indicating whether or not the application environment has
- // already been initialized.
+ /**
+ * Flag indicating whether or not the application environment has already been
+ * initialized.
+ */
private boolean environmentInitialized = false;
- // The factory which the application should use to retrieve its
- // management context.
+ /**
+ * The factory which the application should use to retrieve its management
+ * context.
+ */
private final ManagementContextFactory factory;
- // Flag indicating whether or not the global arguments have
- // already been initialized.
+ /**
+ * Flag indicating whether or not the global arguments have already been
+ * initialized.
+ */
private boolean globalArgumentsInitialized = false;
- // The sub-command handler factory.
+ /** The sub-command handler factory. */
private SubCommandHandlerFactory handlerFactory = null;
- // Mapping of sub-commands to their implementations;
+ /** Mapping of sub-commands to their implementations. */
private final Map<SubCommand, SubCommandHandler> handlers =
new HashMap<SubCommand, SubCommandHandler>();
- // Indicates whether or not a sub-command was provided.
+ /** Indicates whether or not a sub-command was provided. */
private boolean hasSubCommand = true;
- // The argument which should be used to read dsconfig commands from a file.
+ /** The argument which should be used to read dsconfig commands from a file. */
private StringArgument batchFileArgument;
- // The argument which should be used to request non interactive
- // behavior.
+ /**
+ * The argument which should be used to request non interactive behavior.
+ */
private BooleanArgument noPromptArgument;
- // The argument that the user must set to display the equivalent
- // non-interactive mode argument
+ /**
+ * The argument that the user must set to display the equivalent
+ * non-interactive mode argument.
+ */
private BooleanArgument displayEquivalentArgument;
- // The argument that allows the user to dump the equivalent non-interactive
- // command to a file.
+ /**
+ * The argument that allows the user to dump the equivalent non-interactive
+ * command to a file.
+ */
private StringArgument equivalentCommandFileArgument;
- // The command-line argument parser.
+ /** The command-line argument parser. */
private final SubCommandArgumentParser parser;
- // The argument which should be used to request quiet output.
+ /** The argument which should be used to request quiet output. */
private BooleanArgument quietArgument;
- // The argument which should be used to request script-friendly
- // output.
+ /**
+ * The argument which should be used to request script-friendly output.
+ */
private BooleanArgument scriptFriendlyArgument;
- // The argument which should be used to request usage information.
+ /** The argument which should be used to request usage information. */
private BooleanArgument showUsageArgument;
- // The argument which should be used to request verbose output.
+ /** The argument which should be used to request verbose output. */
private BooleanArgument verboseArgument;
- // The argument which should be used to indicate the properties file.
+ /** The argument which should be used to indicate the properties file. */
private StringArgument propertiesFileArgument;
- // The argument which should be used to indicate that we will not look for
- // properties file.
+ /**
+ * The argument which should be used to indicate that we will not look for
+ * properties file.
+ */
private BooleanArgument noPropertiesFileArgument;
/**
@@ -437,7 +450,7 @@
ManagementContextFactory factory) {
super(new PrintStream(out), new PrintStream(err));
- this.parser = new SubCommandArgumentParser(this.getClass().getName(),
+ this.parser = new SubCommandArgumentParser(getClass().getName(),
INFO_CONFIGDS_TOOL_DESCRIPTION.get(), false);
this.factory = factory;
@@ -453,7 +466,7 @@
* If the core APIs could not be initialized.
*/
private void initializeClientEnvironment() throws InitializationException {
- if (environmentInitialized == false) {
+ if (!environmentInitialized) {
EmbeddedUtils.initializeForClientUse();
// Bootstrap definition classes.
@@ -471,9 +484,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isAdvancedMode() {
return advancedModeArgument.isPresent();
@@ -481,9 +492,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isInteractive() {
return !noPromptArgument.isPresent();
@@ -491,9 +500,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isMenuDrivenMode() {
return !hasSubCommand;
@@ -501,9 +508,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isQuiet() {
return quietArgument.isPresent();
@@ -511,9 +516,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isScriptFriendly() {
return scriptFriendlyArgument.isPresent();
@@ -521,9 +524,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isVerbose() {
return verboseArgument.isPresent();
@@ -531,7 +532,7 @@
- // Displays the provided message followed by a help usage reference.
+ /** Displays the provided message followed by a help usage reference. */
private void displayMessageAndUsageReference(LocalizableMessage message) {
println(message);
println();
@@ -548,7 +549,7 @@
*/
private void initializeGlobalArguments(String[] args)
throws ArgumentException {
- if (globalArgumentsInitialized == false) {
+ if (!globalArgumentsInitialized) {
verboseArgument = CommonArguments.getVerbose();
quietArgument = CommonArguments.getQuiet();
@@ -841,7 +842,7 @@
- // Run the top-level interactive console.
+ /** Run the top-level interactive console. */
private int runInteractiveMode() {
ConsoleApplication app = this;
@@ -958,7 +959,7 @@
- // Run the provided sub-command handler.
+ /** Run the provided sub-command handler. */
private int runSubCommand(SubCommandHandler handler) {
try {
MenuResult<Integer> result = handler.run(this, factory);
@@ -1003,82 +1004,41 @@
return 1;
} catch (Exception e) {
- println(LocalizableMessage.raw(StaticUtils.stackTraceToString(e)));
+ println(LocalizableMessage.raw(stackTraceToString(e)));
return 1;
}
}
/**
* Updates the command builder with the global options: script friendly,
- * verbose, etc. for a given subcommand. It also adds systematically the
+ * verbose, etc. for a given sub command. It also adds systematically the
* no-prompt option.
- * @param handler the subcommand handler.
+ *
+ * @param <T>
+ * SubCommand type.
+ * @param subCommand
+ * The sub command handler or common.
+ * @return <T> The builded command.
*/
- private CommandBuilder getCommandBuilder(SubCommandHandler handler)
+ <T> CommandBuilder getCommandBuilder(final T subCommand)
{
- String commandName =
- System.getProperty(ServerConstants.PROPERTY_SCRIPT_NAME);
+ String commandName = System.getProperty(PROPERTY_SCRIPT_NAME);
if (commandName == null)
{
- commandName = "dsconfig";
+ commandName = DSCONFIGTOOLNAME;
}
-
- CommandBuilder commandBuilder =
- new CommandBuilder(commandName, handler.getSubCommand().getName());
-
- commandBuilder.append(handler.getCommandBuilder());
-
- if ((factory != null) && (factory.getContextCommandBuilder() != null))
+ CommandBuilder commandBuilder = null;
+ if (subCommand instanceof SubCommandHandler)
{
- commandBuilder.append(factory.getContextCommandBuilder());
+ commandBuilder =
+ new CommandBuilder(commandName, ((SubCommandHandler) subCommand)
+ .getSubCommand().getName());
}
-
- if (verboseArgument.isPresent())
+ else
{
- commandBuilder.addArgument(verboseArgument);
+ commandBuilder = new CommandBuilder(commandName, (String) subCommand);
}
-
- if (scriptFriendlyArgument.isPresent())
- {
- commandBuilder.addArgument(scriptFriendlyArgument);
- }
-
- commandBuilder.addArgument(noPromptArgument);
-
- if (propertiesFileArgument.isPresent())
- {
- commandBuilder.addArgument(propertiesFileArgument);
- }
-
- if (noPropertiesFileArgument.isPresent())
- {
- commandBuilder.addArgument(noPropertiesFileArgument);
- }
-
- return commandBuilder;
- }
-
- /**
- * Creates a command builder with the global options: script friendly,
- * verbose, etc. for a given subcommand name. It also adds systematically the
- * no-prompt option.
- * @param subcommandName the subcommand name.
- * @return the command builder that has been created with the specified
- * subcommandName.
- */
- CommandBuilder getCommandBuilder(String subcommandName)
- {
- String commandName =
- System.getProperty(ServerConstants.PROPERTY_SCRIPT_NAME);
- if (commandName == null)
- {
- commandName = "dsconfig";
- }
-
- CommandBuilder commandBuilder =
- new CommandBuilder(commandName, subcommandName);
-
- if ((factory != null) && (factory.getContextCommandBuilder() != null))
+ if (factory != null && factory.getContextCommandBuilder() != null)
{
commandBuilder.append(factory.getContextCommandBuilder());
}
@@ -1126,10 +1086,10 @@
if (equivalentCommandFileArgument.isPresent())
{
String file = equivalentCommandFileArgument.getValue();
+ BufferedWriter writer = null;
try
{
- BufferedWriter writer =
- new BufferedWriter(new FileWriter(file, true));
+ writer = new BufferedWriter(new FileWriter(file, true));
if (!sessionStartTimePrinted)
{
@@ -1153,12 +1113,15 @@
writer.newLine();
writer.flush();
- writer.close();
}
catch (IOException ioe)
{
println(ERR_DSCFG_ERROR_WRITING_EQUIVALENT_COMMAND_LINE.get(file, ioe));
}
+ finally
+ {
+ close(writer);
+ }
}
}
@@ -1171,17 +1134,19 @@
private String getSessionStartTimeMessage()
{
String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME);
- if ((scriptName == null) || (scriptName.length() == 0))
+ if (scriptName == null || scriptName.length() == 0)
{
- scriptName = "dsconfig";
+ scriptName = DSCONFIGTOOLNAME;
}
- String date = formatDateTimeStringForEquivalentCommand(
+ final String date = formatDateTimeStringForEquivalentCommand(
new Date(sessionStartTime));
return INFO_DSCFG_SESSION_START_TIME_MESSAGE.get(scriptName, date).
toString();
}
private void handleBatchFile(String[] args) {
+
+ BufferedReader bReader = null;
try {
// Build a list of initial arguments,
// removing the batch file option + its value
@@ -1201,15 +1166,13 @@
initialArgs.remove(batchFileArgIndex);
}
String batchFilePath = batchFileArgument.getValue().trim();
- BufferedReader reader =
+ bReader =
new BufferedReader(new FileReader(batchFilePath));
String line;
String command = "";
- //
// Split the CLI string into arguments array
- //
- while ((line = reader.readLine()) != null) {
- if (line.equals("") || line.startsWith("#")) {
+ while ((line = bReader.readLine()) != null) {
+ if ("".equals(line) || line.startsWith("#")) {
// Empty line or comment
continue;
}
@@ -1248,35 +1211,31 @@
int exitCode =
main(allArgsArray, false, getOutputStream(), getErrorStream());
if (exitCode != 0) {
- reader.close();
+ bReader.close();
System.exit(filterExitCode(exitCode));
}
errPrintln();
}
- reader.close();
+ bReader.close();
} catch (IOException ex) {
println(ERR_DSCFG_ERROR_READING_BATCH_FILE.get(ex));
+ } finally {
+ close(bReader);
}
}
- // Replace spaces in quotes by "\ "
+ /** Replace spaces in quotes by "\ ". */
private String replaceSpacesInQuotes(String line) {
String newLine = "";
boolean inQuotes = false;
for (int ii = 0; ii < line.length(); ii++) {
char ch = line.charAt(ii);
- if ((ch == '\"') || (ch == '\'')) {
- if (!inQuotes) {
- // enter in a quoted string
- inQuotes = true;
- } else {
- // end of a quoted string
- inQuotes = false;
- }
+ if (ch == '\"' || ch == '\'') {
+ inQuotes = !inQuotes;
continue;
}
- if (inQuotes && (ch == ' ')) {
+ if (inQuotes && ch == ' ') {
newLine += "\\ ";
} else {
newLine += ch;
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 3f34864..39a74d5 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
@@ -149,25 +149,26 @@
- // The argument which should be used to force deletion.
+ /** The argument which should be used to force deletion. */
private final BooleanArgument forceArgument;
- // The sub-commands naming arguments.
+ /** The sub-commands naming arguments. */
private final List<StringArgument> namingArgs;
- // The path of the managed object.
+ /** The path of the managed object. */
private final ManagedObjectPath<?, ?> path;
- // The relation which references the managed
- // object to be deleted.
+ /**
+ * The relation which references the managed object to be deleted.
+ */
private final RelationDefinition<?, ?> relation;
- // The sub-command associated with this handler.
+ /** The sub-command associated with this handler. */
private final SubCommand subCommand;
- // Private constructor.
+ /** Private constructor. */
private DeleteSubCommandHandler(
SubCommandArgumentParser parser, ManagedObjectPath<?, ?> p,
RelationDefinition<?, ?> r, ManagedObjectPath<?, ?> c)
@@ -210,9 +211,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public SubCommand getSubCommand() {
return subCommand;
@@ -220,9 +219,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public MenuResult<Integer> run(ConsoleApplication app,
ManagementContextFactory factory) throws ArgumentException,
@@ -414,7 +411,7 @@
- // Confirm deletion.
+ /** Confirm deletion. */
private boolean confirmDeletion(ConsoleApplication app) throws ClientException {
if (app.isInteractive()) {
LocalizableMessage prompt = INFO_DSCFG_CONFIRM_DELETE.get(relation
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 4e1f15d..f7cf306 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
@@ -69,7 +69,6 @@
import com.forgerock.opendj.cli.SubCommand;
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import com.forgerock.opendj.cli.ClientException;
-
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.MenuResult;
import com.forgerock.opendj.cli.TableBuilder;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
index c8aff02..f91a3c2 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
@@ -100,9 +100,7 @@
private static class DefaultVisitor<T> implements
DefaultBehaviorProviderVisitor<T, LocalizableMessage, PropertyDefinition<T>> {
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public LocalizableMessage visitAbsoluteInherited(
AbsoluteInheritedDefaultBehaviorProvider<T> d,
PropertyDefinition<T> p) {
@@ -113,9 +111,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public LocalizableMessage visitAlias(AliasDefaultBehaviorProvider<T> d,
PropertyDefinition<T> p) {
return d.getSynopsis();
@@ -123,9 +119,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public LocalizableMessage visitDefined(DefinedDefaultBehaviorProvider<T> d,
PropertyDefinition<T> p) {
LocalizableMessageBuilder builder = new LocalizableMessageBuilder();
@@ -146,9 +140,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public LocalizableMessage visitRelativeInherited(
RelativeInheritedDefaultBehaviorProvider<T> d,
PropertyDefinition<T> p) {
@@ -164,9 +156,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public LocalizableMessage visitUndefined(UndefinedDefaultBehaviorProvider<T> d,
PropertyDefinition<T> p) {
return INFO_DSCFG_HELP_FIELD_UNDEFINED.get();
@@ -216,16 +206,14 @@
private static class Visitor extends
PropertyDefinitionVisitor<Void, PrintStream> {
- // Private constructor.
+ /** Private constructor. */
private Visitor() {
// No implementation required.
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <E extends Enum<E>> Void visitEnum(EnumPropertyDefinition<E> d,
PrintStream p) {
@@ -263,9 +251,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public Void visitString(StringPropertyDefinition d, PrintStream p) {
PropertyDefinitionUsageBuilder usageBuilder =
@@ -298,9 +284,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <T> Void visitUnknown(PropertyDefinition<T> d, PrintStream p)
throws PropertyException {
@@ -313,7 +297,7 @@
- // Common usage.
+ /** Common usage. */
private void displayUsage(PrintStream p, LocalizableMessage usage) {
TableBuilder builder = new TableBuilder();
builder.startRow();
@@ -331,7 +315,7 @@
}
}
- // The private implementation.
+ /** The private implementation. */
private final Visitor pimpl;
@@ -359,11 +343,11 @@
}
}
- // Strings used in property help.
- private final static String HEADING_SEPARATOR = " : ";
+ /** Strings used in property help. */
+ private static final String HEADING_SEPARATOR = " : ";
- // Width of biggest heading (need to be careful of I18N).
- private final static int HEADING_WIDTH;
+ /** Width of biggest heading (need to be careful of I18N). */
+ private static final int HEADING_WIDTH;
/**
* The value for the long option category.
@@ -612,7 +596,7 @@
- // Displays the property option summary key.
+ /** Displays the property option summary key. */
private static void displayPropertyOptionKey(ConsoleApplication app) {
LocalizableMessageBuilder builder;
@@ -647,7 +631,7 @@
- // Compute the options field.
+ /** Compute the options field. */
private static String getPropertyOptionSummary(PropertyDefinition<?> pd) {
StringBuilder b = new StringBuilder();
@@ -679,34 +663,43 @@
return b.toString();
}
- // The argument which should be used to specify the category of
- // managed object to be retrieved.
+ /**
+ * The argument which should be used to specify the category of managed object
+ * to be retrieved.
+ */
private final StringArgument categoryArgument;
- // A table listing all the available types of managed object indexed
- // on their parent type.
+ /**
+ * A table listing all the available types of managed object indexed on their
+ * parent type.
+ */
private final Map<String, Map<String,
AbstractManagedObjectDefinition<?, ?>>> categoryMap;
- // The argument which should be used to display inherited
- // properties.
+ /**
+ * The argument which should be used to display inherited properties.
+ */
private BooleanArgument inheritedModeArgument;
- // The sub-command associated with this handler.
+ /** The sub-command associated with this handler. */
private final SubCommand subCommand;
- // A table listing all the available types of managed object indexed
- // on their tag(s).
+ /**
+ * A table listing all the available types of managed object indexed on their
+ * tag(s).
+ */
private final Map<Tag, Map<String,
AbstractManagedObjectDefinition<?, ?>>> tagMap;
- // The argument which should be used to specify the sub-type of
- // managed object to be retrieved.
+ /**
+ * The argument which should be used to specify the sub-type of managed object
+ * to be retrieved.
+ */
private final StringArgument typeArgument;
- // Private constructor.
+ /** Private constructor. */
private HelpSubCommandHandler(SubCommandArgumentParser parser)
throws ArgumentException {
// Create the sub-command.
@@ -745,9 +738,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public SubCommand getSubCommand() {
return subCommand;
@@ -809,9 +800,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public MenuResult<Integer> run(ConsoleApplication app,
ManagementContextFactory factory) throws ArgumentException,
@@ -930,7 +919,7 @@
return MenuResult.success(0);
}
- // Output property summary table.
+ /** Output property summary table. */
private void displayNonVerbose(ConsoleApplication app, String categoryName,
String typeName, Tag tag, Set<String> propertyNames) {
if (!app.isScriptFriendly()) {
@@ -1048,7 +1037,7 @@
- // Display detailed help on managed objects and their properties.
+ /** Display detailed help on managed objects and their properties. */
private void displayVerbose(ConsoleApplication app, String categoryName,
String typeName, Tag tag, Set<String> propertyNames) {
// Construct line used to separate consecutive sections.
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java
index 71529ca..ed28b27 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.tools.dsconfig;
-
-
import org.opends.server.admin.client.ManagementContext;
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.ArgumentException;
@@ -44,7 +42,7 @@
public final class InternalManagementContextFactory implements
ManagementContextFactory {
- // The pre-defined management context.
+ /** The pre-defined management context. */
private final ManagementContext context;
@@ -60,9 +58,7 @@
this.context = context;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void close()
{
// No implementation required.
@@ -70,9 +66,7 @@
// his/her context.
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public ManagementContext getManagementContext(ConsoleApplication app)
throws ArgumentException, ClientException {
return context;
@@ -80,9 +74,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void registerGlobalArguments(SubCommandArgumentParser parser)
throws ArgumentException {
// No implementation required.
@@ -90,24 +82,18 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void validateGlobalArguments() throws ArgumentException {
// No implementation required.
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public CommandBuilder getContextCommandBuilder() {
// No implementation required.
return new CommandBuilder(null, null);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void setRawArguments(String[] args) {
// No implementation required.
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
index e6061bb..ae71217 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
@@ -73,19 +73,19 @@
public final class LDAPManagementContextFactory implements
ManagementContextFactory {
- // The SecureConnectionCliArgsList object.
+ /** The SecureConnectionCliArgsList object. */
private SecureConnectionCliArgs secureArgsList = null;
- // The management context.
+ /** The management context. */
private ManagementContext context = null;
- // The connection parameters command builder.
+ /** The connection parameters command builder. */
private CommandBuilder contextCommandBuilder;
- // This CLI is always using the administration connector with SSL
+ /** This CLI is always using the administration connector with SSL. */
private boolean alwaysSSL = false;
- // Raw arguments
+ /** Raw arguments. */
private String[] rawArgs = null;
/**
@@ -98,9 +98,7 @@
this.alwaysSSL = alwaysSSL;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public ManagementContext getManagementContext(ConsoleApplication app)
throws ArgumentException, ClientException
@@ -117,9 +115,7 @@
return context;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void close()
{
@@ -129,9 +125,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public CommandBuilder getContextCommandBuilder()
{
@@ -190,51 +184,47 @@
}
catch (NamingException e)
{
- if ( app.isInteractive() && ci.isTrustStoreInMemory())
+ if (app.isInteractive()
+ && ci.isTrustStoreInMemory()
+ && e.getRootCause() != null
+ && e.getRootCause().getCause() instanceof OpendsCertificateException)
{
- if ((e.getRootCause() != null)
- && (e.getRootCause().getCause()
- instanceof OpendsCertificateException))
- {
- OpendsCertificateException oce =
+ OpendsCertificateException oce =
(OpendsCertificateException) e.getRootCause().getCause();
- String authType = null;
- if (trustManager instanceof ApplicationTrustManager)
- {
- ApplicationTrustManager appTrustManager =
- (ApplicationTrustManager)trustManager;
- authType = appTrustManager.getLastRefusedAuthType();
- }
- if (ci.checkServerCertificate(oce.getChain(), authType,
- hostName))
- {
- // If the certificate is trusted, update the trust manager.
- trustManager = ci.getTrustManager();
-
- // Try to connect again.
- continue ;
- }
+ String authType = null;
+ if (trustManager instanceof ApplicationTrustManager)
+ {
+ ApplicationTrustManager appTrustManager =
+ (ApplicationTrustManager) trustManager;
+ authType = appTrustManager.getLastRefusedAuthType();
+ }
+ if (ci.checkServerCertificate(oce.getChain(), authType, hostName))
+ {
+ // If the certificate is trusted, update the trust manager.
+ trustManager = ci.getTrustManager();
+ // Try to connect again.
+ continue;
}
}
if (e.getRootCause() != null) {
- if (e.getRootCause().getCause() != null) {
- if (((e.getRootCause().getCause()
- instanceof OpendsCertificateException)) ||
- (e.getRootCause() instanceof SSLHandshakeException)) {
- LocalizableMessage message =
- ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get(hostName, portNumber);
- throw new ClientException(
- ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message);
- }
+ if (e.getRootCause().getCause() != null
+ && (e.getRootCause().getCause() instanceof OpendsCertificateException
+ || e.getRootCause() instanceof SSLHandshakeException))
+ {
+ final LocalizableMessage message =
+ ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get(
+ hostName, portNumber);
+ throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR,
+ message);
}
if (e.getRootCause() instanceof SSLException) {
- LocalizableMessage message =
+ final LocalizableMessage message =
ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get(hostName, portNumber);
throw new ClientException(
ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message);
}
}
- LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber);
+ final LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber);
throw new ClientException(
ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message);
}
@@ -259,9 +249,8 @@
{
if ( app.isInteractive() && ci.isTrustStoreInMemory())
{
- if ((e.getRootCause() != null)
- && (e.getRootCause().getCause()
- instanceof OpendsCertificateException))
+ if (e.getRootCause() != null
+ && e.getRootCause().getCause() instanceof OpendsCertificateException)
{
String authType = null;
if (trustManager instanceof ApplicationTrustManager)
@@ -332,18 +321,14 @@
return context;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void setRawArguments(String[] args) {
this.rawArgs = args;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void registerGlobalArguments(SubCommandArgumentParser parser)
throws ArgumentException {
@@ -367,8 +352,7 @@
continue;
}
if (rawArg.contains(OPTION_LONG_HELP) ||
- (rawArg.charAt(1) == OPTION_SHORT_HELP) || (rawArg.
- charAt(1) == '?')) {
+ rawArg.charAt(1) == OPTION_SHORT_HELP || rawArg.charAt(1) == '?') {
// used for usage help default values only
secureArgsList.initArgumentsWithConfiguration();
}
@@ -383,9 +367,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void validateGlobalArguments() throws ArgumentException {
// Make sure that the user didn't specify any conflicting
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 1ffc323..e50289b 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
@@ -142,21 +142,21 @@
.getUserFriendlyName());
}
- // The sub-commands naming arguments.
+ /** The sub-commands naming arguments. */
private final List<StringArgument> namingArgs;
- // The path of the parent managed object.
+ /** The path of the parent managed object. */
private final ManagedObjectPath<?, ?> path;
- // The relation which should be listed.
+ /** The relation which should be listed. */
private final RelationDefinition<?, ?> relation;
- // The sub-command associated with this handler.
+ /** The sub-command associated with this handler. */
private final SubCommand subCommand;
- // Private constructor.
+ /** Private constructor. */
private ListSubCommandHandler(
SubCommandArgumentParser parser, ManagedObjectPath<?, ?> p,
RelationDefinition<?, ?> r, String rname, LocalizableMessage rufn)
@@ -196,9 +196,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public SubCommand getSubCommand() {
return subCommand;
@@ -206,9 +204,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public MenuResult<Integer> run(ConsoleApplication app,
ManagementContextFactory factory) throws ArgumentException,
@@ -423,8 +419,7 @@
// appropriate), and requested properties.
SortedMap<String, ?> subTypes =
getSubTypes(relation.getChildDefinition());
- boolean includeTypesColumn = (subTypes.size() != 1
- || !subTypes.containsKey(DSConfig.GENERIC_TYPE));
+ boolean includeTypesColumn = subTypes.size() != 1 || !subTypes.containsKey(DSConfig.GENERIC_TYPE);
TableBuilder builder = new TableBuilder();
builder.appendHeading(relation.getUserFriendlyName());
@@ -502,20 +497,19 @@
}
PrintStream out = app.getOutputStream();
+ TablePrinter printer = null;
if (app.isScriptFriendly()) {
- TablePrinter printer = createScriptFriendlyTablePrinter(out);
- builder.print(printer);
+ printer = createScriptFriendlyTablePrinter(out);
} else {
if (app.isInteractive()) {
// Make interactive mode prettier.
app.println();
app.println();
}
-
- TextTablePrinter printer = new TextTablePrinter(out);
- printer.setColumnSeparator(LIST_TABLE_SEPARATOR);
- builder.print(printer);
+ printer = new TextTablePrinter(out);
+ ((TextTablePrinter)printer).setColumnSeparator(LIST_TABLE_SEPARATOR);
}
+ builder.print(printer);
}
return MenuResult.success(0);
@@ -523,7 +517,7 @@
- // Display the set of values associated with a property.
+ /** Display the set of values associated with a property. */
private <T> void displayProperty(ConsoleApplication app,
TableBuilder builder, ManagedObject<?> mo, PropertyDefinition<T> pd,
PropertyValuePrinter valuePrinter) {
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java
index 09436ff..414dffe 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java
@@ -92,7 +92,7 @@
*
* @param args raw arguments.
*/
- public void setRawArguments(String[] args);
+ void setRawArguments(String[] args);
/**
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyEditorModification.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyEditorModification.java
index 459ec48..ac96b53 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyEditorModification.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyEditorModification.java
@@ -22,6 +22,7 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.tools.dsconfig;
@@ -181,15 +182,13 @@
return originalValues;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public String toString()
{
- return "Property name: "+getPropertyDefinition()+
- "\nMod type: "+getType()+
- "\nMod values: "+getModificationValues()+
- "\nOriginal values: "+getOriginalValues();
+ return "Property name: " + getPropertyDefinition()
+ + "\nMod type: " + getType()
+ + "\nMod values: " + getModificationValues()
+ + "\nOriginal values: " + getOriginalValues();
}
}
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 c7f6424..e02c37f 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
@@ -98,22 +98,22 @@
<C extends ConfigurationClient, S extends Configuration>
implements MenuCallback<String> {
- // The aggregation property definition.
+ /** The aggregation property definition. */
private final AggregationPropertyDefinition<C, S> pd;
- // Creates a new component create call-back for the provided
- // aggregation property definition.
+ /**
+ * Creates a new component create call-back for the provided aggregation
+ * property definition.
+ */
private CreateComponentCallback(AggregationPropertyDefinition<C, S> pd) {
this.pd = pd;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public MenuResult<String> invoke(ConsoleApplication app)
throws ClientException {
try {
@@ -182,15 +182,15 @@
*/
private static final class ComponentHelpCallback implements HelpCallback {
- // The managed object being edited.
+ /** The managed object being edited. */
private final ManagedObject<?> mo;
- // The properties that can be edited.
+ /** The properties that can be edited. */
private final Collection<PropertyDefinition<?>> properties;
- // Creates a new component helper for the specified property.
+ /** Creates a new component helper for the specified property. */
private ComponentHelpCallback(ManagedObject<?> mo,
Collection<PropertyDefinition<?>> c) {
this.mo = mo;
@@ -199,9 +199,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void display(ConsoleApplication app) {
app.println();
HelpSubCommandHandler.displaySingleComponent(app, mo
@@ -262,9 +260,7 @@
new DefaultBehaviorProviderVisitor<T, DefaultBehaviorQuery<T>,
PropertyDefinition<T>>() {
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public DefaultBehaviorQuery<T> visitAbsoluteInherited(
AbsoluteInheritedDefaultBehaviorProvider<T> d,
PropertyDefinition<T> p) {
@@ -280,9 +276,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public DefaultBehaviorQuery<T> visitAlias(
AliasDefaultBehaviorProvider<T> d, PropertyDefinition<T> p) {
return new DefaultBehaviorQuery<T>(Type.ALIAS, d.getSynopsis());
@@ -290,9 +284,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public DefaultBehaviorQuery<T> visitDefined(
DefinedDefaultBehaviorProvider<T> d, PropertyDefinition<T> p) {
return new DefaultBehaviorQuery<T>(Type.DEFINED, null);
@@ -300,9 +292,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public DefaultBehaviorQuery<T> visitRelativeInherited(
RelativeInheritedDefaultBehaviorProvider<T> d,
PropertyDefinition<T> p) {
@@ -318,9 +308,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public DefaultBehaviorQuery<T> visitUndefined(
UndefinedDefaultBehaviorProvider<T> d, PropertyDefinition<T> p) {
return new DefaultBehaviorQuery<T>(Type.UNDEFINED, null);
@@ -330,16 +318,17 @@
return pd.getDefaultBehaviorProvider().accept(visitor, pd);
}
- // The description of the behavior if it is an alias default
- // behavior.
+ /**
+ * The description of the behavior if it is an alias default behavior.
+ */
private final LocalizableMessage aliasDescription;
- // The type of behavior.
+ /** The type of behavior. */
private final Type type;
- // Private constructor.
+ /** Private constructor. */
private DefaultBehaviorQuery(Type type, LocalizableMessage aliasDescription) {
this.type = type;
this.aliasDescription = aliasDescription;
@@ -421,18 +410,18 @@
PropertyDefinitionVisitor<MenuResult<Void>, Void> implements
MenuCallback<Void> {
- // Any exception that was caught during processing.
+ /** Any exception that was caught during processing. */
private ClientException e = null;
- // The managed object being edited.
+ /** The managed object being edited. */
private final ManagedObject<?> mo;
- // The property to be edited.
+ /** The property to be edited. */
private final PropertyDefinition<?> pd;
- // Creates a new property editor for the specified property.
+ /** Creates a new property editor for the specified property. */
private MandatoryPropertyInitializer(ManagedObject<?> mo,
PropertyDefinition<?> pd) {
this.mo = mo;
@@ -441,9 +430,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public MenuResult<Void> invoke(ConsoleApplication app)
throws ClientException {
displayPropertyHeader(app, pd);
@@ -459,9 +446,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <C extends ConfigurationClient, S extends Configuration>
MenuResult<Void> visitAggregation(
@@ -586,9 +571,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <E extends Enum<E>> MenuResult<Void> visitEnum(
EnumPropertyDefinition<E> d, Void x) {
@@ -643,9 +626,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <T> MenuResult<Void> visitUnknown(PropertyDefinition<T> d,
Void p) throws PropertyException {
@@ -678,18 +659,18 @@
PropertyDefinitionVisitor<MenuResult<Boolean>, Void>
implements MenuCallback<Boolean> {
- // Any exception that was caught during processing.
+ /** Any exception that was caught during processing. */
private ClientException e = null;
- // The managed object being edited.
+ /** The managed object being edited. */
private final ManagedObject<?> mo;
- // The property to be edited.
+ /** The property to be edited. */
private final PropertyDefinition<?> pd;
- // Creates a new property editor for the specified property.
+ /** Creates a new property editor for the specified property. */
private MultiValuedPropertyEditor(ManagedObject<?> mo,
PropertyDefinition<?> pd) {
Reject.ifFalse(pd.hasOption(PropertyOption.MULTI_VALUED));
@@ -700,9 +681,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public MenuResult<Boolean> invoke(ConsoleApplication app)
throws ClientException {
displayPropertyHeader(app, pd);
@@ -717,9 +696,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <C extends ConfigurationClient, S extends Configuration>
MenuResult<Boolean> visitAggregation(
@@ -887,9 +864,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <T extends Enum<T>> MenuResult<Boolean> visitEnum(
final EnumPropertyDefinition<T> d, Void p) {
@@ -1033,9 +1008,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <T> MenuResult<Boolean> visitUnknown(final PropertyDefinition<T> d,
Void p) {
@@ -1287,7 +1260,7 @@
- // Common menu processing.
+ /** Common menu processing. */
private <T> MenuResult<Boolean> runMenu(final PropertyDefinition<T> d,
ConsoleApplication app, final SortedSet<T> defaultValues,
final SortedSet<T> oldValues, final SortedSet<T> currentValues,
@@ -1337,24 +1310,23 @@
currentValues);
}
- if (!currentValues.isEmpty()) {
- if (resetOption == null || !defaultValues.isEmpty()) {
- MenuCallback<Boolean> callback = new MenuCallback<Boolean>() {
-
- public MenuResult<Boolean> invoke(ConsoleApplication app)
- throws ClientException {
- isLastChoiceReset = false;
- currentValues.clear();
- app.println();
- app.pressReturnToContinue();
- return MenuResult.success(false);
- }
-
- };
-
- builder.addNumberedOption(INFO_EDITOR_OPTION_REMOVE_ALL_VALUES.get(),
- callback);
- }
+ if (!currentValues.isEmpty()
+ && (resetOption == null || !defaultValues.isEmpty()))
+ {
+ MenuCallback<Boolean> callback = new MenuCallback<Boolean>()
+ {
+ public MenuResult<Boolean> invoke(ConsoleApplication app)
+ throws ClientException
+ {
+ isLastChoiceReset = false;
+ currentValues.clear();
+ app.println();
+ app.pressReturnToContinue();
+ return MenuResult.success(false);
+ }
+ };
+ builder.addNumberedOption(INFO_EDITOR_OPTION_REMOVE_ALL_VALUES.get(),
+ callback);
}
if (resetOption != null) {
@@ -1410,7 +1382,7 @@
}
if (result.isSuccess()) {
- if (result.getValue() == true) {
+ if (result.getValue()) {
// Set the new property value(s).
mo.setPropertyValues(d, currentValues);
@@ -1443,15 +1415,15 @@
*/
private static final class PropertyHelpCallback implements HelpCallback {
- // The managed object definition.
+ /** The managed object definition. */
private final ManagedObjectDefinition<?, ?> d;
- // The property to be edited.
+ /** The property to be edited. */
private final PropertyDefinition<?> pd;
- // Creates a new property helper for the specified property.
+ /** Creates a new property helper for the specified property. */
private PropertyHelpCallback(ManagedObjectDefinition<?, ?> d,
PropertyDefinition<?> pd) {
this.d = d;
@@ -1460,9 +1432,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void display(ConsoleApplication app) {
app.println();
HelpSubCommandHandler.displayVerboseSingleProperty(app, d, pd.getName());
@@ -1480,18 +1450,18 @@
PropertyDefinitionVisitor<MenuResult<Boolean>, Void> implements
MenuCallback<Boolean> {
- // Any exception that was caught during processing.
+ /** Any exception that was caught during processing. */
private ClientException e = null;
- // The managed object being edited.
+ /** The managed object being edited. */
private final ManagedObject<?> mo;
- // The property to be edited.
+ /** The property to be edited. */
private final PropertyDefinition<?> pd;
- // Creates a new property editor for the specified property.
+ /** Creates a new property editor for the specified property. */
private ReadOnlyPropertyViewer(ManagedObject<?> mo,
PropertyDefinition<?> pd) {
this.mo = mo;
@@ -1500,9 +1470,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public MenuResult<Boolean> invoke(ConsoleApplication app)
throws ClientException {
MenuResult<Boolean> result = pd.accept(this, null);
@@ -1515,9 +1483,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <T> MenuResult<Boolean> visitUnknown(PropertyDefinition<T> pd,
Void p) {
@@ -1581,18 +1547,18 @@
PropertyDefinitionVisitor<MenuResult<Boolean>, Void>
implements MenuCallback<Boolean> {
- // Any exception that was caught during processing.
+ /** Any exception that was caught during processing. */
private ClientException e = null;
- // The managed object being edited.
+ /** The managed object being edited. */
private final ManagedObject<?> mo;
- // The property to be edited.
+ /** The property to be edited. */
private final PropertyDefinition<?> pd;
- // Creates a new property editor for the specified property.
+ /** Creates a new property editor for the specified property. */
private SingleValuedPropertyEditor(ManagedObject<?> mo,
PropertyDefinition<?> pd) {
Reject.ifFalse(!pd.hasOption(PropertyOption.MULTI_VALUED));
@@ -1603,9 +1569,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public MenuResult<Boolean> invoke(ConsoleApplication app)
throws ClientException {
displayPropertyHeader(app, pd);
@@ -1620,9 +1584,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <C extends ConfigurationClient, S extends Configuration>
MenuResult<Boolean> visitAggregation(
@@ -1696,9 +1658,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public MenuResult<Boolean> visitBoolean(BooleanPropertyDefinition d,
Void p) {
@@ -1722,10 +1682,10 @@
// The second (and possibly third) option is to always change
// the property's value.
- if (currentValue == null || currentValue == false) {
+ if (currentValue == null || !currentValue) {
LocalizableMessage svalue = getPropertyValues(d, Collections.singleton(true));
- if (defaultValue != null && defaultValue == true) {
+ if (defaultValue != null && defaultValue) {
option = INFO_EDITOR_OPTION_CHANGE_TO_DEFAULT_VALUE.get(svalue);
} else {
option = INFO_EDITOR_OPTION_CHANGE_TO_VALUE.get(svalue);
@@ -1734,10 +1694,10 @@
builder.addNumberedOption(option, MenuResult.success(true));
}
- if (currentValue == null || currentValue == true) {
+ if (currentValue == null || currentValue) {
LocalizableMessage svalue = getPropertyValues(d, Collections.singleton(false));
- if (defaultValue != null && defaultValue == false) {
+ if (defaultValue != null && !defaultValue) {
option = INFO_EDITOR_OPTION_CHANGE_TO_DEFAULT_VALUE.get(svalue);
} else {
option = INFO_EDITOR_OPTION_CHANGE_TO_VALUE.get(svalue);
@@ -1759,9 +1719,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <E extends Enum<E>> MenuResult<Boolean> visitEnum(
EnumPropertyDefinition<E> d, Void p) {
@@ -1814,9 +1772,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <T> MenuResult<Boolean> visitUnknown(final PropertyDefinition<T> d,
Void p) {
@@ -1945,7 +1901,7 @@
- // Common menu processing.
+ /** Common menu processing. */
private <T> MenuResult<Boolean> runMenu(final PropertyDefinition<T> d,
MenuBuilder<T> builder) throws PropertyException,
PropertyException, PropertyException,
@@ -1969,15 +1925,9 @@
Collection<T> newValues = result.getValues();
SortedSet<T> oldValues = new TreeSet<T>(mo.getPropertyValues(d));
mo.setPropertyValues(d, newValues);
- if (newValues.size() > 0)
- {
- isLastChoiceReset = false;
- }
- else
- {
- // There are no newValues when we do a reset.
- isLastChoiceReset = true;
- }
+
+ // If there are no newValues when we do a reset.
+ isLastChoiceReset = !(newValues.size() > 0);
registerModification(d, new TreeSet<T>(newValues), oldValues);
app.println();
app.pressReturnToContinue();
@@ -1994,7 +1944,7 @@
- // Display a title and a description of the property.
+ /** Display a title and a description of the property. */
private static void displayPropertyHeader(ConsoleApplication app,
PropertyDefinition<?> pd) {
app.println();
@@ -2010,7 +1960,7 @@
- // Display a property's syntax.
+ /** Display a property's syntax. */
private static <T> void displayPropertySyntax(ConsoleApplication app,
PropertyDefinition<T> d) throws IllegalArgumentException {
PropertyDefinitionUsageBuilder b = new PropertyDefinitionUsageBuilder(true);
@@ -2029,7 +1979,7 @@
- // Display a table of property values.
+ /** Display a table of property values. */
private static <T> void displayPropertyValues(ConsoleApplication app,
PropertyDefinition<T> pd, Collection<T> values)
throws IllegalArgumentException {
@@ -2076,7 +2026,7 @@
- // Display the set of values associated with a property.
+ /** Display the set of values associated with a property. */
private static <T> LocalizableMessage getPropertyValues(PropertyDefinition<T> pd,
Collection<T> values) {
if (values.isEmpty()) {
@@ -2109,7 +2059,7 @@
- // Display the set of values associated with a property.
+ /** Display the set of values associated with a property. */
private static <T> LocalizableMessage getPropertyValues(
PropertyDefinition<T> pd,
ManagedObject<?> mo) {
@@ -2119,7 +2069,7 @@
- // Read new values for a property.
+ /** Read new values for a property. */
private static <T> SortedSet<T> readPropertyValues(ConsoleApplication app,
ManagedObjectDefinition<?, ?> d, PropertyDefinition<T> pd)
throws ClientException {
@@ -2130,7 +2080,7 @@
- // Add values to a property.
+ /** Add values to a property. */
private static <T> void readPropertyValues(ConsoleApplication app,
ManagedObjectDefinition<?, ?> d, PropertyDefinition<T> pd,
SortedSet<T> values) throws ClientException {
@@ -2149,10 +2099,9 @@
app.println();
String s = app.readLineOfInput(prompt);
- if (s.trim().length() == 0) {
- if (!pd.hasOption(PropertyOption.MANDATORY)) {
- return;
- }
+ if (s.trim().length() == 0 && !pd.hasOption(PropertyOption.MANDATORY))
+ {
+ return;
}
T value = pd.decodeValue(s);
@@ -2203,23 +2152,27 @@
}
}
- // The threshold above which choice menus should be displayed in
- // multiple columns.
+ /** The threshold above which choice menus should be displayed in
+ * multiple columns.
+*/
private static final int MULTI_COLUMN_THRESHOLD = 8;
- // The application console.
+ /** The application console. */
private final ConsoleApplication app;
- // The management context.
+ /** The management context. */
private final ManagementContext context;
- // The modifications performed: we assume that at most there is one
- // modification per property definition.
+ /**
+ * The modifications performed: we assume that at most there is one
+ * modification per property definition.
+ */
private final List<PropertyEditorModification<?>> mods =
new ArrayList<PropertyEditorModification<?>>();
- // Whether the last type of choice made by the user in a menu is a
- // reset
+ /**
+ * Whether the last type of choice made by the user in a menu is a reset.
+ */
private boolean isLastChoiceReset;
@@ -2271,14 +2224,15 @@
// Get values for this missing mandatory property.
for (PropertyDefinition<?> pd : c) {
- if (pd.hasOption(PropertyOption.MANDATORY)) {
- if (mo.getPropertyValues(pd).isEmpty()) {
- MandatoryPropertyInitializer mpi = new MandatoryPropertyInitializer(
- mo, pd);
- MenuResult<Void> result = mpi.invoke(app);
- if (!result.isSuccess()) {
- return result;
- }
+ if (pd.hasOption(PropertyOption.MANDATORY)
+ && mo.getPropertyValues(pd).isEmpty())
+ {
+ MandatoryPropertyInitializer mpi =
+ new MandatoryPropertyInitializer(mo, pd);
+ MenuResult<Void> result = mpi.invoke(app);
+ if (!result.isSuccess())
+ {
+ return result;
}
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java
index 1b51ec7..f2cab67 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java
@@ -56,24 +56,27 @@
private static class MyPropertyValueVisitor extends
PropertyValueVisitor<LocalizableMessage, Void> {
- // The requested size unit (null if the property's unit should be
- // used).
+ /**
+ * The requested size unit (null if the property's unit should be used).
+ */
private final SizeUnit sizeUnit;
- // The requested time unit (null if the property's unit should be
- // used).
+ /**
+ * The requested time unit (null if the property's unit should be used).
+ */
private final DurationUnit timeUnit;
- // Whether or not values should be displayed in a script-friendly
- // manner.
+ /**
+ * Whether or not values should be displayed in a script-friendly manner.
+ */
private final boolean isScriptFriendly;
- // The formatter to use for numeric values.
+ /** The formatter to use for numeric values. */
private final NumberFormat numberFormat;
- // Private constructor.
+ /** Private constructor. */
private MyPropertyValueVisitor(SizeUnit sizeUnit, DurationUnit timeUnit,
boolean isScriptFriendly) {
this.sizeUnit = sizeUnit;
@@ -81,24 +84,19 @@
this.isScriptFriendly = isScriptFriendly;
this.numberFormat = NumberFormat.getNumberInstance();
- if (this.isScriptFriendly) {
- numberFormat.setGroupingUsed(false);
- numberFormat.setMaximumFractionDigits(2);
- } else {
- numberFormat.setGroupingUsed(true);
+ {
+ numberFormat.setGroupingUsed(!this.isScriptFriendly);
numberFormat.setMaximumFractionDigits(2);
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public LocalizableMessage visitBoolean(BooleanPropertyDefinition pd, Boolean v,
Void p) {
- if (v == false) {
+ if (!v) {
return INFO_VALUE_FALSE.get();
} else {
return INFO_VALUE_TRUE.get();
@@ -107,9 +105,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public LocalizableMessage visitDuration(DurationPropertyDefinition pd, Long v,
Void p) {
@@ -141,9 +137,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public LocalizableMessage visitSize(SizePropertyDefinition pd, Long v, Void p) {
if (pd.isAllowUnlimited() && v < 0) {
@@ -170,9 +164,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public <T> LocalizableMessage visitUnknown(PropertyDefinition<T> pd, T v, Void p) {
// For all other property definition types the default encoding
@@ -191,7 +183,7 @@
}
- // The property value printer implementation.
+ /** The property value printer implementation. */
private final MyPropertyValueVisitor pimpl;
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 a9b4951..ac049bc 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
@@ -439,7 +439,7 @@
ref.commit();
// Try to create the command builder
- if ((app instanceof DSConfig) && app.isInteractive())
+ if (app instanceof DSConfig && app.isInteractive())
{
DSConfig dsConfig = (DSConfig)app;
String subCommandName = "set-" +
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 433f083..d656306 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
@@ -103,39 +103,41 @@
*/
private class ManagedObjectFinder implements ManagedObjectPathSerializer {
- // The console application.
+ /** The console application. */
private ConsoleApplication app;
- // The index of the next path argument to be retrieved.
+ /** The index of the next path argument to be retrieved. */
private int argIndex;
- // The list of managed object path arguments.
+ /** The list of managed object path arguments. */
private List<String> args;
private AuthorizationException authze;
private CommunicationException ce;
- // Any CLI exception that was caught when attempting to find
- // the managed object.
+ /**
+ * Any CLI exception that was caught when attempting to find the managed
+ * object.
+ */
private ClientException clie;
private ConcurrentModificationException cme;
- // Any operation exception that was caught when attempting to find
- // the managed object.
+ /**
+ * Any operation exception that was caught when attempting to find the
+ * managed object.
+ */
private DefinitionDecodingException dde;
private ManagedObjectDecodingException mode;
private ManagedObjectNotFoundException monfe;
- // The current result.
+ /** The current result. */
private MenuResult<ManagedObject<?>> result;
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
void appendManagedObjectPathElement(
InstantiableRelationDefinition<? super C, ? super S> r,
@@ -211,9 +213,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
void appendManagedObjectPathElement(
OptionalRelationDefinition<? super C, ? super S> r,
@@ -255,9 +255,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
void appendManagedObjectPathElement(
SetRelationDefinition<? super C, ? super S> r,
@@ -349,9 +347,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
void appendManagedObjectPathElement(
SingletonRelationDefinition<? super C, ? super S> r,
@@ -516,28 +512,30 @@
return builder.arguments;
}
- // The list of naming arguments.
+ /** The list of naming arguments. */
private final List<StringArgument> arguments =
new LinkedList<StringArgument>();
- // Any argument exception thrown when creating the naming
- // arguments.
+ /**
+ * Any argument exception thrown when creating the naming arguments.
+ */
private ArgumentException e = null;
- // Indicates whether the sub-command is a create-xxx
- // sub-command, in which case the final path element will
- // have different usage information.
+ /**
+ * Indicates whether the sub-command is a create-xxx sub-command, in which
+ * case the final path element will have different usage information.
+ */
private final boolean isCreate;
- // The sub-command.
+ /** The sub-command. */
private final SubCommand subCommand;
- // The number of path elements to expect.
+ /** The number of path elements to expect. */
private int sz;
- // Private constructor.
+ /** Private constructor. */
private NamingArgumentBuilder(SubCommand subCommand, int sz,
boolean isCreate) {
this.subCommand = subCommand;
@@ -547,9 +545,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
void appendManagedObjectPathElement(
InstantiableRelationDefinition<? super C, ? super S> r,
@@ -594,9 +590,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
void appendManagedObjectPathElement(
OptionalRelationDefinition<? super C, ? super S> r,
@@ -606,9 +600,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
void appendManagedObjectPathElement(
SetRelationDefinition<? super C, ? super S> r,
@@ -638,9 +630,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
void appendManagedObjectPathElement(
SingletonRelationDefinition<? super C, ? super S> r,
@@ -696,23 +686,24 @@
*/
private static final char OPTION_DSCFG_SHORT_UNIT_TIME = 'm';
- // The argument which should be used to specify zero or more
- // property names.
+ /**
+ * The argument which should be used to specify zero or more property names.
+ */
private StringArgument propertyArgument;
- // The argument which should be used to request record mode.
+ /** The argument which should be used to request record mode. */
private BooleanArgument recordModeArgument;
- // The tags associated with this sub-command handler.
+ /** The tags associated with this sub-command handler. */
private final Set<Tag> tags = new HashSet<Tag>();
- // The argument which should be used to request specific size units.
+ /** The argument which should be used to request specific size units. */
private StringArgument unitSizeArgument;
- // The argument which should be used to request specific time units.
+ /** The argument which should be used to request specific time units. */
private StringArgument unitTimeArgument;
- // The command builder associated with this handler.
+ /** The command builder associated with this handler. */
private CommandBuilder commandBuilder;
@@ -731,9 +722,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public final int compareTo(SubCommandHandler o) {
String s1 = getSubCommand().getName();
String s2 = o.getSubCommand().getName();
@@ -743,9 +732,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public final boolean equals(Object obj) {
if (this == obj) {
@@ -822,9 +809,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public final int hashCode() {
return getSubCommand().getName().hashCode();
@@ -1426,9 +1411,7 @@
protected static <T> String castAndGetArgumentValue(
PropertyDefinition<T> propertyDefinition, Object o)
{
- String value = propertyDefinition.encodeValue(
- propertyDefinition.castValue(o));
- return value;
+ return propertyDefinition.encodeValue(propertyDefinition.castValue(o));
}
/**
@@ -1442,9 +1425,7 @@
protected static <T> String getArgumentValue(
PropertyDefinition<T> propertyDefinition, T o)
{
- String value;
- value = propertyDefinition.encodeValue(o);
- return value;
+ return propertyDefinition.encodeValue(o);
}
@@ -1472,12 +1453,12 @@
// If the top-level definition is instantiable, we use the value
// "generic" or "custom".
- if (!d.hasOption(ManagedObjectOption.HIDDEN)) {
- if (d instanceof ManagedObjectDefinition) {
- ManagedObjectDefinition<? extends C, ? extends S> mod =
+ if (!d.hasOption(ManagedObjectOption.HIDDEN)
+ && d instanceof ManagedObjectDefinition)
+ {
+ ManagedObjectDefinition<? extends C, ? extends S> mod =
(ManagedObjectDefinition<? extends C, ? extends S>) d;
- map.put(getShortTypeName(d, mod), mod);
- }
+ map.put(getShortTypeName(d, mod), mod);
}
// Process its sub-definitions.
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java
index 866178d..9015d4e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java
@@ -60,9 +60,7 @@
private final class Visitor implements
RelationDefinitionVisitor<Void, ManagedObjectPath<?, ?>> {
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
Void visitInstantiable(
InstantiableRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) {
@@ -86,9 +84,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
Void visitOptional(
OptionalRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) {
@@ -112,9 +108,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
Void visitSet(
SetRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) {
@@ -138,9 +132,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
Void visitSingleton(
SingletonRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) {
@@ -161,40 +153,40 @@
}
- // The set of all available sub-commands.
+ /** The set of all available sub-commands. */
private final SortedSet<SubCommandHandler> allHandlers =
new TreeSet<SubCommandHandler>();
- // The set of create-xxx available sub-commands.
+ /** The set of create-xxx available sub-commands. */
private final SortedSet<CreateSubCommandHandler<?, ?>> createHandlers =
new TreeSet<CreateSubCommandHandler<?, ?>>();
- // The set of delete-xxx available sub-commands.
+ /** The set of delete-xxx available sub-commands. */
private final SortedSet<DeleteSubCommandHandler> deleteHandlers =
new TreeSet<DeleteSubCommandHandler>();
- // Any exception that occurred whilst creating the sub-commands.
+ /** Any exception that occurred whilst creating the sub-commands. */
private ArgumentException exception = null;
- // The set of get-xxx-prop available sub-commands.
+ /** The set of get-xxx-prop available sub-commands. */
private final SortedSet<GetPropSubCommandHandler> getPropHandlers =
new TreeSet<GetPropSubCommandHandler>();
- // The help sub-command handler.
+ /** The help sub-command handler. */
private HelpSubCommandHandler helpHandler = null;
- // The set of list-xxx available sub-commands.
+ /** The set of list-xxx available sub-commands. */
private final SortedSet<ListSubCommandHandler> listHandlers =
new TreeSet<ListSubCommandHandler>();
- // The sub-command argument parser.
+ /** The sub-command argument parser. */
private final SubCommandArgumentParser parser;
- // The set of set-xxx-prop available sub-commands.
+ /** The set of set-xxx-prop available sub-commands. */
private final SortedSet<SetPropSubCommandHandler> setPropHandlers =
new TreeSet<SetPropSubCommandHandler>();
- // The relation visitor.
+ /** The relation visitor. */
private final Visitor visitor = new Visitor();
@@ -297,8 +289,10 @@
- // Process the relations associated with the managed object
- // definition identified by the provided path.
+ /**
+ * Process the relations associated with the managed object definition
+ * identified by the provided path.
+ */
private void processPath(ManagedObjectPath<?, ?> path) {
AbstractManagedObjectDefinition<?, ?> d = path.getManagedObjectDefinition();
@@ -312,7 +306,7 @@
- // Process an instantiable relation.
+ /** Process an instantiable relation. */
private <C extends ConfigurationClient, S extends Configuration>
void processRelation(
ManagedObjectPath<?, ?> path, InstantiableRelationDefinition<C, S> r) {
@@ -333,7 +327,7 @@
- // Process an optional relation.
+ /** Process an optional relation. */
private <C extends ConfigurationClient, S extends Configuration>
void processRelation(
ManagedObjectPath<?, ?> path, OptionalRelationDefinition<C, S> r) {
@@ -354,7 +348,7 @@
- // Process a set relation.
+ /** Process a set relation. */
private <C extends ConfigurationClient, S extends Configuration>
void processRelation(
ManagedObjectPath<?, ?> path, SetRelationDefinition<C, S> r) {
@@ -375,7 +369,7 @@
- // Process a singleton relation.
+ /** Process a singleton relation. */
private <C extends ConfigurationClient, S extends Configuration>
void processRelation(
ManagedObjectPath<?, ?> path, SingletonRelationDefinition<C, S> r) {
--
Gitblit v1.10.0