OPENDJ-1343 Migrate dsconfig
- Removed unnecessary interface ManagementContextFactory.
- Minor code cleanup.
1 files deleted
10 files modified
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | LDAPManagementContextFactory factory) throws ArgumentException, |
| | | ClientException { |
| | | LocalizableMessage ufn = relation.getUserFriendlyName(); |
| | | |
| | |
| | | /** The sub-command handler. */ |
| | | private final SubCommandHandler handler; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new sub-command handler call-back. |
| | | * |
| | |
| | | this.handler = handler; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> invoke(ConsoleApplication app) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * The interactive mode sub-menu implementation. |
| | | */ |
| | |
| | | /** The menu. */ |
| | | private final Menu<Integer> menu; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new sub-menu implementation. |
| | | * |
| | |
| | | this.menu = builder.toMenu(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final MenuResult<Integer> invoke(ConsoleApplication app) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Provides the command-line arguments to the main application for |
| | | * processing and returns the exit code as an integer. |
| | |
| | | OutputStream errStream) |
| | | { |
| | | JDKLogging.disableLogging(); |
| | | DSConfig app = |
| | | new DSConfig(System.in, outStream, errStream); |
| | | final DSConfig app = new DSConfig(System.in, outStream, errStream); |
| | | app.sessionStartTime = System.currentTimeMillis(); |
| | | /* |
| | | * FIXME: obtain path info from system properties. |
| | |
| | | * The factory which the application should use to retrieve its management |
| | | * context. |
| | | */ |
| | | private ManagementContextFactory factory = null; |
| | | private LDAPManagementContextFactory factory = null; |
| | | |
| | | /** |
| | | * Flag indicating whether or not the global arguments have already been |
| | |
| | | retCode = runSubCommand(handler); |
| | | } |
| | | |
| | | try { |
| | | // Close the Management context ==> an LDAP UNBIND is sent |
| | | factory.close(); |
| | | } catch (Exception e) { |
| | | // Nothing to report in this case |
| | | } |
| | | factory.close(); |
| | | |
| | | return retCode; |
| | | } |
| | |
| | | String[] allArgsArray = allArguments.toArray(new String[]{}); |
| | | |
| | | int exitCode = main(allArgsArray, getOutputStream(), getErrorStream()); |
| | | if (exitCode != 0) |
| | | if (exitCode != ReturnCode.SUCCESS.get()) |
| | | { |
| | | System.exit(filterExitCode(exitCode)); |
| | | } |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | LDAPManagementContextFactory factory) throws ArgumentException, |
| | | ClientException { |
| | | // Get the naming argument values. |
| | | List<String> names = getNamingArgValues(app, namingArgs); |
| | |
| | | */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | LDAPManagementContextFactory factory) throws ArgumentException, |
| | | ClientException { |
| | | // Get the property names. |
| | | Set<String> propertyNames = getPropertyNames(); |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | ClientException { |
| | | LDAPManagementContextFactory factory) throws ArgumentException, |
| | | ClientException |
| | | { |
| | | |
| | | String categoryName = categoryArgument.getValue(); |
| | | String typeName = typeArgument.getValue(); |
| | |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | /** |
| | | * An LDAP management context factory. |
| | | * An LDAP management context factory for the DSConfig tool. |
| | | */ |
| | | public final class LDAPManagementContextFactory implements ManagementContextFactory |
| | | public final class LDAPManagementContextFactory |
| | | { |
| | | |
| | | /** The management context. */ |
| | |
| | | factory = cfp.getAuthenticatedConnectionFactory(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | /** |
| | | * Closes this management context. |
| | | */ |
| | | public void close() |
| | | { |
| | | closeSilently(context); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | /** |
| | | * Returns the command builder that provides the equivalent arguments in |
| | | * interactive mode to get the management context. |
| | | * |
| | | * @return the command builder that provides the equivalent arguments in |
| | | * interactive mode to get the management context. |
| | | */ |
| | | public CommandBuilder getContextCommandBuilder() |
| | | { |
| | | return contextCommandBuilder; |
| | |
| | | SubCommandArgumentParser parser, ManagedObjectPath<?, ?> p, |
| | | RelationDefinition<?, ?> r, String rname, LocalizableMessage rufn) |
| | | throws ArgumentException { |
| | | this.path = p; |
| | | this.relation = r; |
| | | path = p; |
| | | relation = r; |
| | | |
| | | // Create the sub-command. |
| | | String name = "list-" + rname; |
| | | LocalizableMessage desc = INFO_DSCFG_DESCRIPTION_SUBCMD_LIST.get(rufn); |
| | | this.subCommand = new SubCommand(parser, name, false, 0, 0, null, desc); |
| | | subCommand = |
| | | new SubCommand(parser, "list-" + rname, false, 0, 0, null, |
| | | INFO_DSCFG_DESCRIPTION_SUBCMD_LIST.get(rufn)); |
| | | |
| | | // Create the naming arguments. |
| | | this.namingArgs = createNamingArgs(subCommand, path, false); |
| | | namingArgs = createNamingArgs(subCommand, path, false); |
| | | |
| | | // Register arguments. |
| | | registerPropertyNameArgument(this.subCommand); |
| | | registerUnitSizeArgument(this.subCommand); |
| | | registerUnitTimeArgument(this.subCommand); |
| | | registerPropertyNameArgument(subCommand); |
| | | registerUnitSizeArgument(subCommand); |
| | | registerUnitTimeArgument(subCommand); |
| | | |
| | | // Register the tags associated with the child managed objects. |
| | | addTags(relation.getChildDefinition().getAllTags()); |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | LDAPManagementContextFactory factory) throws ArgumentException, |
| | | ClientException { |
| | | // Get the property names. |
| | | Set<String> propertyNames = getPropertyNames(); |
| | |
| | | @SuppressWarnings("unchecked") |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | ClientException { |
| | | LDAPManagementContextFactory factory) throws ArgumentException, |
| | | ClientException |
| | | { |
| | | // Get the naming argument values. |
| | | List<String> names = getNamingArgValues(app, namingArgs); |
| | | |
| | |
| | | * @param app |
| | | * The console application. |
| | | * @param factory |
| | | * The management context factory. |
| | | * The LDAP management context factory context factory. |
| | | * @return Returns a {@link MenuResult#success()} containing zero if |
| | | * the sub-command completed successfully or non-zero if it |
| | | * did not, or {@link MenuResult#quit()}, or |
| | |
| | | * If the management context could not be created. |
| | | */ |
| | | public abstract MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | LDAPManagementContextFactory factory) throws ArgumentException, |
| | | ClientException; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> |
| | | Void visitOptional( |
| | | OptionalRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) { |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitOptional( |
| | | OptionalRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) |
| | | { |
| | | try { |
| | | // Create the sub-commands. |
| | | createHandlers.add(CreateSubCommandHandler.create(parser, p, rd)); |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> |
| | | Void visitSet( |
| | | SetRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) { |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSet( |
| | | SetRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) |
| | | { |
| | | try { |
| | | // Create the sub-commands. |
| | | createHandlers.add(CreateSubCommandHandler.create(parser, p, rd)); |