| | |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | |
| | | import java.io.PrintStream; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | 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.admin.client.MissingMandatoryPropertiesException; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | |
| | | * Creates a new set-xxx-prop sub-command for an instantiable |
| | | * relation. |
| | | * |
| | | * @param app |
| | | * The console application. |
| | | * @param parser |
| | | * The sub-command argument parser. |
| | | * @param path |
| | |
| | | * @throws ArgumentException |
| | | * If the sub-command could not be created successfully. |
| | | */ |
| | | public static SetPropSubCommandHandler create( |
| | | public static SetPropSubCommandHandler create(ConsoleApplication app, |
| | | SubCommandArgumentParser parser, ManagedObjectPath<?, ?> path, |
| | | InstantiableRelationDefinition<?, ?> r) throws ArgumentException { |
| | | return new SetPropSubCommandHandler(parser, path.child(r, "DUMMY"), r); |
| | | return new SetPropSubCommandHandler(app, parser, path.child(r, "DUMMY"), r); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * Creates a new set-xxx-prop sub-command for an optional relation. |
| | | * |
| | | * @param app |
| | | * The console application. |
| | | * @param parser |
| | | * The sub-command argument parser. |
| | | * @param path |
| | |
| | | * @throws ArgumentException |
| | | * If the sub-command could not be created successfully. |
| | | */ |
| | | public static SetPropSubCommandHandler create( |
| | | public static SetPropSubCommandHandler create(ConsoleApplication app, |
| | | SubCommandArgumentParser parser, ManagedObjectPath<?, ?> path, |
| | | OptionalRelationDefinition<?, ?> r) throws ArgumentException { |
| | | return new SetPropSubCommandHandler(parser, path.child(r), r); |
| | | return new SetPropSubCommandHandler(app, parser, path.child(r), r); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * Creates a new set-xxx-prop sub-command for a singleton relation. |
| | | * |
| | | * @param app |
| | | * The console application. |
| | | * @param parser |
| | | * The sub-command argument parser. |
| | | * @param path |
| | |
| | | * @throws ArgumentException |
| | | * If the sub-command could not be created successfully. |
| | | */ |
| | | public static SetPropSubCommandHandler create( |
| | | public static SetPropSubCommandHandler create(ConsoleApplication app, |
| | | SubCommandArgumentParser parser, ManagedObjectPath<?, ?> path, |
| | | SingletonRelationDefinition<?, ?> r) throws ArgumentException { |
| | | return new SetPropSubCommandHandler(parser, path.child(r), r); |
| | | return new SetPropSubCommandHandler(app, parser, path.child(r), r); |
| | | } |
| | | |
| | | // The sub-commands naming arguments. |
| | |
| | | |
| | | |
| | | // Private constructor. |
| | | private SetPropSubCommandHandler(SubCommandArgumentParser parser, |
| | | ManagedObjectPath<?, ?> path, RelationDefinition<?, ?> r) |
| | | throws ArgumentException { |
| | | private SetPropSubCommandHandler(ConsoleApplication app, |
| | | SubCommandArgumentParser parser, ManagedObjectPath<?, ?> path, |
| | | RelationDefinition<?, ?> r) throws ArgumentException { |
| | | super(app); |
| | | |
| | | this.path = path; |
| | | |
| | | // Create the sub-command. |
| | |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | @Override |
| | | public int run(DSConfig app, PrintStream out, PrintStream err) |
| | | public int run() |
| | | throws ArgumentException, ClientException { |
| | | // Get the naming argument values. |
| | | List<String> names = getNamingArgValues(namingArgs); |
| | | |
| | | ManagementContext context = app.getManagementContext(); |
| | | ManagedObject<?> child; |
| | | try { |
| | | child = getManagedObject(context, path, names); |
| | | child = getManagedObject(path, names); |
| | | } catch (AuthorizationException e) { |
| | | int msgID = MSGID_DSCFG_ERROR_MODIFY_AUTHZ; |
| | | String ufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | |
| | | // Confirm commit. |
| | | String prompt = String.format(Messages.getString("modify.confirm"), d |
| | | .getUserFriendlyName()); |
| | | if (!app.confirmAction(prompt)) { |
| | | if (!getConsoleApplication().confirmAction(prompt)) { |
| | | // Output failure message. |
| | | String msg = String.format(Messages.getString("modify.failed"), d |
| | | .getUserFriendlyName()); |
| | | app.displayVerboseMessage(msg); |
| | | getConsoleApplication().printVerboseMessage(msg); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | // Output success message. |
| | | String msg = String.format(Messages.getString("modify.done"), d |
| | | .getUserFriendlyName()); |
| | | app.displayVerboseMessage(msg); |
| | | getConsoleApplication().printVerboseMessage(msg); |
| | | } catch (MissingMandatoryPropertiesException e) { |
| | | throw ArgumentExceptionFactory.adaptMissingMandatoryPropertiesException( |
| | | e, d); |