ListSubCommandHandler.java revision a03d3e5abfd98a38eea4a1dceb522001530910ab
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
/**
* A sub-command handler which is used to list existing managed
* objects.
* <p>
* This sub-command implements the various list-xxx sub-commands.
*/
final class ListSubCommandHandler extends SubCommandHandler {
/**
* Creates a new list-xxx sub-command for an instantiable relation.
*
* @param parser
* The sub-command argument parser.
* @param p
* The parent managed object path.
* @param r
* The instantiable relation.
* @return Returns the new list-xxx sub-command.
* @throws ArgumentException
* If the sub-command could not be created successfully.
*/
public static ListSubCommandHandler create(
InstantiableRelationDefinition<?, ?> r) throws ArgumentException {
}
/**
* Creates a new list-xxx sub-command for an optional relation.
*
* @param parser
* The sub-command argument parser.
* @param p
* The parent managed object path.
* @param r
* The optional relation.
* @return Returns the new list-xxx sub-command.
* @throws ArgumentException
* If the sub-command could not be created successfully.
*/
public static ListSubCommandHandler create(
OptionalRelationDefinition<?, ?> r) throws ArgumentException {
.getUserFriendlyName());
}
// The sub-commands naming arguments.
// The path of the parent managed object.
private final ManagedObjectPath<?, ?> path;
// The relation which should be listed.
private final RelationDefinition<?, ?> relation;
// The sub-command associated with this handler.
private final SubCommand subCommand;
// Private constructor.
private ListSubCommandHandler(
throws ArgumentException {
this.path = p;
this.relation = r;
// Create the sub-command.
// Create the naming arguments.
// Register arguments.
// Register the tags associated with the child managed objects.
}
/**
* Gets the relation definition associated with the type of
* component that this sub-command handles.
*
* @return Returns the relation definition associated with the type
* of component that this sub-command handles.
*/
public RelationDefinition<?, ?> getRelationDefinition() {
return relation;
}
/**
* {@inheritDoc}
*/
public SubCommand getSubCommand() {
return subCommand;
}
/**
* {@inheritDoc}
*/
// Get the property names.
if (propertyNames.isEmpty()) {
// Use a default set of properties.
relation);
}
// Get the naming argument values.
if (relation instanceof InstantiableRelationDefinition) {
(InstantiableRelationDefinition<?, ?>) relation;
} else {
}
// List the children.
try {
} catch (AuthorizationException e) {
msg);
} catch (DefinitionDecodingException e) {
} catch (ManagedObjectDecodingException e) {
} catch (CommunicationException e) {
} catch (ConcurrentModificationException e) {
} catch (ManagedObjectNotFoundException e) {
}
return MenuResult.quit();
return MenuResult.cancel();
}
if (relation instanceof InstantiableRelationDefinition) {
(InstantiableRelationDefinition<?, ?>) relation;
try {
try {
} catch (ManagedObjectNotFoundException e) {
// Ignore - as it's been removed since we did the list.
}
}
} catch (DefinitionDecodingException e) {
// FIXME: just output this as a warnings (incl. the name) but
// continue.
} catch (ManagedObjectDecodingException e) {
// FIXME: just output this as a warnings (incl. the name) but
// continue.
} catch (AuthorizationException e) {
msg);
} catch (ConcurrentModificationException e) {
} catch (CommunicationException e) {
msg);
}
} else if (relation instanceof OptionalRelationDefinition) {
OptionalRelationDefinition<?, ?> orelation =
(OptionalRelationDefinition<?, ?>) relation;
try {
} else {
// Indicate that the managed object does not exist.
throw new ManagedObjectNotFoundException();
}
} catch (AuthorizationException e) {
msg);
} catch (DefinitionDecodingException e) {
} catch (ManagedObjectDecodingException e) {
} catch (ConcurrentModificationException e) {
} catch (CommunicationException e) {
msg);
} catch (ManagedObjectNotFoundException e) {
}
}
// Output the results.
if (app.isScriptFriendly()) {
// Output just the names of the children.
}
} else {
// Create a table of their properties.
}
// First output the name.
// Output the managed object type in the form used in
// create-xxx commands.
- typeSuffix.length()));
} else {
}
// Now any requested properties.
try {
} catch (IllegalArgumentException e) {
// Assume this child managed object does not support this
// property.
if (app.isScriptFriendly()) {
} else {
}
}
}
}
if (app.isScriptFriendly()) {
} else {
if (app.isInteractive()) {
// Make interactive mode prettier.
}
}
}
}
// Display the set of values associated with a property.
if (app.isScriptFriendly()) {
} else {
}
} else {
boolean isFirst = true;
if (!isFirst) {
}
isFirst = false;
}
}
}
}