From f45aad28ca76ce859bfae6aa9cff650b9a34b85e Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 07 Feb 2014 15:41:31 +0000
Subject: [PATCH] Used StaticUtils.close().
---
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java | 86 ++++++++++++++----------------------------
1 files changed, 29 insertions(+), 57 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
index f372aaa..80285cd 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
@@ -26,13 +26,12 @@
*/
package org.opends.server.admin.client.cli;
-
-
import static org.opends.messages.AdminMessages.*;
import static org.opends.messages.DSConfigMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
import static org.opends.server.tools.ToolConstants.*;
+import static org.opends.server.util.StaticUtils.*;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -44,15 +43,14 @@
import java.util.Map;
import java.util.Set;
-import javax.naming.NamingException;
import javax.naming.ldap.InitialLdapContext;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.admin.ads.ADSContext;
import org.opends.admin.ads.ADSContextException;
import org.opends.admin.ads.ADSContext.ServerProperty;
import org.opends.admin.ads.ADSContextException.ErrorType;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.tools.dsconfig.ArgumentExceptionFactory;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
@@ -62,25 +60,26 @@
import com.forgerock.opendj.cli.SubCommand;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
+
/**
* This class is handling server group CLI.
*/
public class DsFrameworkCliServer implements DsFrameworkCliSubCommandGroup
{
// Strings used in property help.
- private final static LocalizableMessage DESCRIPTION_OPTIONS_TITLE =
+ private static final LocalizableMessage DESCRIPTION_OPTIONS_TITLE =
INFO_DSCFG_HELP_DESCRIPTION_OPTION.get();
- private final static LocalizableMessage DESCRIPTION_OPTIONS_READ =
+ private static final LocalizableMessage DESCRIPTION_OPTIONS_READ =
INFO_DSCFG_HELP_DESCRIPTION_READ.get();
- private final static LocalizableMessage DESCRIPTION_OPTIONS_WRITE =
+ private static final LocalizableMessage DESCRIPTION_OPTIONS_WRITE =
INFO_DSCFG_HELP_DESCRIPTION_WRITE.get();
- private final static LocalizableMessage DESCRIPTION_OPTIONS_MANDATORY =
+ private static final LocalizableMessage DESCRIPTION_OPTIONS_MANDATORY =
INFO_DSCFG_HELP_DESCRIPTION_MANDATORY.get();
- private final static LocalizableMessage DESCRIPTION_OPTIONS_SINGLE =
+ private static final LocalizableMessage DESCRIPTION_OPTIONS_SINGLE =
INFO_DSCFG_HELP_DESCRIPTION_SINGLE_VALUED.get();
/**
@@ -123,25 +122,23 @@
*/
LIST_SERVER_PROPERTIES("list-server-properties");
- // String representation of the value.
+ /** String representation of the value. */
private final String name;
- // Private constructor.
+ /** Private constructor. */
private SubCommandNameEnum(String name)
{
this.name = name;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public String toString()
{
return name;
}
- // A lookup table for resolving a unit from its name.
+ /** A lookup table for resolving a unit from its name. */
private static final List<String> nameToSubCmdName;
static
{
@@ -245,33 +242,29 @@
*/
private String groupName;
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public Set<SubCommand> getSubCommands()
{
return subCommands;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public boolean isHidden()
{
return isHidden;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public String getGroupName()
{
return groupName;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public void initializeCliGroup(DsFrameworkCliParser argParser,
BooleanArgument verboseArg) throws ArgumentException
{
@@ -574,17 +567,15 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public boolean isSubCommand(SubCommand subCmd)
{
return SubCommandNameEnum.isSubCommand(subCmd.getName());
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ @Override
public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
OutputStream outStream, OutputStream errStream)
throws ADSContextException, ArgumentException
@@ -811,44 +802,25 @@
}
else
{
- // Should never occurs: If we are here, it means that the code
- // to
+ // Should never occurs: If we are here, it means that the code to
// handle to subcommand is not yet written.
returnCode = ERROR_UNEXPECTED;
}
}
catch (ADSContextException e)
{
- if (ctx != null)
- {
- try
- {
- ctx.close();
- }
- catch (NamingException x)
- {
- }
- }
throw e;
}
-
- // Close the connection, if needed
- if (ctx != null)
+ finally
{
- try
- {
- ctx.close();
- }
- catch (NamingException x)
- {
- }
+ close(ctx);
}
// return part
return returnCode;
}
- // Compute the options field.
+ /** Compute the options field. */
private String getPropertyOptionSummary(Argument arg)
{
StringBuilder b = new StringBuilder();
--
Gitblit v1.10.0