| | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import javax.naming.NamingException; |
| | | import javax.naming.ldap.InitialLdapContext; |
| | | |
| | | import org.opends.admin.ads.ADSContext; |
| | |
| | | import com.forgerock.opendj.cli.SubCommand; |
| | | |
| | | import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class is handling server group CLI. |
| | |
| | | /** |
| | | * The subcommand Parser. |
| | | */ |
| | | DsFrameworkCliParser argParser ; |
| | | private DsFrameworkCliParser argParser; |
| | | |
| | | /** |
| | | * The enumeration containing the different subCommand names. |
| | |
| | | */ |
| | | DELETE_ADS("delete-ads"); |
| | | |
| | | // 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 |
| | | { |
| | |
| | | */ |
| | | private String groupName; |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<SubCommand> getSubCommands() |
| | | { |
| | | return subCommands; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHidden() |
| | | { |
| | | return isHidden ; |
| | | return isHidden; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getGroupName() |
| | | { |
| | | return groupName ; |
| | | return groupName; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeCliGroup(DsFrameworkCliParser argParser, |
| | | BooleanArgument verboseArg) |
| | | throws ArgumentException |
| | |
| | | deleteAdsSubCmd.addArgument(deleteAdsBackendNameArg); |
| | | } |
| | | |
| | | /** |
| | | * {@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 |
| | |
| | | |
| | | try |
| | | { |
| | | // |
| | | // create-ads subcommand |
| | | if (subCmd.getName().equals(createAdsSubCmd.getName())) |
| | | { |
| | |
| | | } |
| | | 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 |