| | |
| | | import org.opends.server.admin.client.ConcurrentModificationException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.util.args.ArgumentException; |
| | |
| | | /** |
| | | * Creates a new list-xxx sub-command for an instantiable relation. |
| | | * |
| | | * @param app |
| | | * The console application. |
| | | * @param parser |
| | | * The sub-command argument parser. |
| | | * @param p |
| | |
| | | * @throws ArgumentException |
| | | * If the sub-command could not be created successfully. |
| | | */ |
| | | public static ListSubCommandHandler create(SubCommandArgumentParser parser, |
| | | ManagedObjectPath<?, ?> p, InstantiableRelationDefinition<?, ?> r) |
| | | throws ArgumentException { |
| | | return new ListSubCommandHandler(parser, p, r, r.getPluralName(), r |
| | | public static ListSubCommandHandler create(ConsoleApplication app, |
| | | SubCommandArgumentParser parser, ManagedObjectPath<?, ?> p, |
| | | InstantiableRelationDefinition<?, ?> r) throws ArgumentException { |
| | | return new ListSubCommandHandler(app, parser, p, r, r.getPluralName(), r |
| | | .getUserFriendlyPluralName()); |
| | | } |
| | | |
| | |
| | | /** |
| | | * Creates a new list-xxx sub-command for an optional relation. |
| | | * |
| | | * @param app |
| | | * The console application. |
| | | * @param parser |
| | | * The sub-command argument parser. |
| | | * @param p |
| | |
| | | * @throws ArgumentException |
| | | * If the sub-command could not be created successfully. |
| | | */ |
| | | public static ListSubCommandHandler create(SubCommandArgumentParser parser, |
| | | ManagedObjectPath<?, ?> p, OptionalRelationDefinition<?, ?> r) |
| | | throws ArgumentException { |
| | | return new ListSubCommandHandler(parser, p, r, r.getName(), r |
| | | public static ListSubCommandHandler create(ConsoleApplication app, |
| | | SubCommandArgumentParser parser, ManagedObjectPath<?, ?> p, |
| | | OptionalRelationDefinition<?, ?> r) throws ArgumentException { |
| | | return new ListSubCommandHandler(app, parser, p, r, r.getName(), r |
| | | .getUserFriendlyName()); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | // Private constructor. |
| | | private ListSubCommandHandler(SubCommandArgumentParser parser, |
| | | ManagedObjectPath<?, ?> p, RelationDefinition<?, ?> r, String rname, |
| | | String rufn) throws ArgumentException { |
| | | private ListSubCommandHandler(ConsoleApplication app, |
| | | SubCommandArgumentParser parser, ManagedObjectPath<?, ?> p, |
| | | RelationDefinition<?, ?> r, String rname, String rufn) |
| | | throws ArgumentException { |
| | | super(app); |
| | | |
| | | this.path = p; |
| | | this.relation = r; |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int run(DSConfig app, PrintStream out, PrintStream err) |
| | | public int run() |
| | | throws ArgumentException, ClientException { |
| | | // Get the property names. |
| | | Set<String> propertyNames = getPropertyNames(); |
| | |
| | | } |
| | | |
| | | PropertyValuePrinter valuePrinter = new PropertyValuePrinter(getSizeUnit(), |
| | | getTimeUnit(), app.isScriptFriendly()); |
| | | getTimeUnit(), getConsoleApplication().isScriptFriendly()); |
| | | |
| | | // Get the naming argument values. |
| | | List<String> names = getNamingArgValues(namingArgs); |
| | |
| | | } |
| | | |
| | | // List the children. |
| | | ManagementContext context = app.getManagementContext(); |
| | | ManagedObject<?> parent; |
| | | try { |
| | | parent = getManagedObject(context, path, names); |
| | | parent = getManagedObject(path, names); |
| | | } catch (AuthorizationException e) { |
| | | int msgID = MSGID_DSCFG_ERROR_LIST_AUTHZ; |
| | | String msg = getMessage(msgID, ufn); |
| | |
| | | } |
| | | |
| | | // Output the results. |
| | | if (app.isScriptFriendly()) { |
| | | if (getConsoleApplication().isScriptFriendly()) { |
| | | // Output just the names of the children. |
| | | PrintStream out = getConsoleApplication().getOutputStream(); |
| | | for (String name : children.keySet()) { |
| | | out.println(name); |
| | | } |
| | |
| | | for (String propertyName : propertyNames) { |
| | | try { |
| | | PropertyDefinition<?> pd = d.getPropertyDefinition(propertyName); |
| | | displayProperty(app, builder, child, pd, valuePrinter); |
| | | displayProperty(builder, child, pd, valuePrinter); |
| | | } catch (IllegalArgumentException e) { |
| | | // Assume this child managed object does not support this |
| | | // property. |
| | | if (app.isScriptFriendly()) { |
| | | if (getConsoleApplication().isScriptFriendly()) { |
| | | builder.appendCell(); |
| | | } else { |
| | | builder.appendCell("-"); |
| | |
| | | } |
| | | } |
| | | |
| | | if (app.isScriptFriendly()) { |
| | | PrintStream out = getConsoleApplication().getOutputStream(); |
| | | if (getConsoleApplication().isScriptFriendly()) { |
| | | TablePrinter printer = createScriptFriendlyTablePrinter(out); |
| | | builder.print(printer); |
| | | } else { |
| | |
| | | |
| | | |
| | | // Display the set of values associated with a property. |
| | | private <T> void displayProperty(DSConfig app, TableBuilder builder, |
| | | ManagedObject<?> mo, PropertyDefinition<T> pd, |
| | | PropertyValuePrinter valuePrinter) { |
| | | private <T> void displayProperty(TableBuilder builder, ManagedObject<?> mo, |
| | | PropertyDefinition<T> pd, PropertyValuePrinter valuePrinter) { |
| | | SortedSet<T> values = mo.getPropertyValues(pd); |
| | | if (values.isEmpty()) { |
| | | if (app.isScriptFriendly()) { |
| | | if (getConsoleApplication().isScriptFriendly()) { |
| | | builder.appendCell(); |
| | | } else { |
| | | builder.appendCell("-"); |