/*
* 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
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2012-2013 ForgeRock AS
*/
/**
* Tool for getting information and managing tasks in the Directory Server.
*/
// This CLI is always using the administration connector with SSL
private static final boolean alwaysSSL = true;
/**
* The main method for TaskInfo tool.
*
* @param args The command-line arguments provided to this program.
*/
if (errorLogPublisher != null) {
}
if (retCode != 0) {
}
}
/**
* Processes the command-line arguments and invokes the process for
* displaying task information.
*
* @param args The command-line arguments provided to this program.
* @return int return code
*/
}
/**
* Processes the command-line arguments and invokes the export process.
*
* @param args The command-line arguments provided to this
* @param in Input stream from which to solicit user input.
* @param out The output stream to use for standard output, or
* {@code null} if standard output is not needed.
* @param err The output stream to use for standard error, or
* {@code null} if standard error is not needed.
* @param initializeServer Indicates whether to initialize the server.
* @return int return code
*/
boolean initializeServer) {
}
/**
* Processes the command-line arguments and invokes the export process.
*
* @param args The command-line arguments provided to this
* @param in Input stream from which to solicit user input.
* @param out The output stream to use for standard output, or
* {@code null} if standard output is not needed.
* @param err The output stream to use for standard error, or
* {@code null} if standard error is not needed.
* @return int return code
*/
OutputStream err) {
}
/**
* ID of task for which to display details and exit.
*/
/**
* Indicates print summary and exit.
*/
/**
* ID of task to cancel.
*/
/**
* Argument used to request non-interactive behavior.
*/
/**
* Accesses the directory's task backend.
*/
/**
* Constructs a parameterized instance.
*
* @param in Input stream from which to solicit user input.
* @param out The output stream to use for standard output, or
* {@code null} if standard output is not needed.
* @param err The output stream to use for standard error, or
* {@code null} if standard error is not needed.
*/
}
/**
* Processes the command-line arguments and invokes the export process.
*
* @param args The command-line arguments provided to this
* program.
* @return The error code.
*/
{
}
/**
* Processes the command-line arguments and invokes the export process.
*
* @param args The command-line arguments provided to this
* program.
* @param initializeServer Indicates whether to initialize the server.
* @return The error code.
*/
{
if (initializeServer)
{
}
// Create the command-line argument parser for use with this program.
"org.opends.server.tools.TaskInfo",
// Initialize all the command-line argument types and register them with the
// parser.
try {
task = new StringArgument(
"info", 'i', "info",
false, true, INFO_TASK_ID_PLACEHOLDER.get(),
cancel = new StringArgument(
"cancel", 'c', "cancel",
false, true, INFO_TASK_ID_PLACEHOLDER.get(),
summary = new BooleanArgument(
"summary", 's', "summary",
noPrompt = new BooleanArgument(
"help", OPTION_SHORT_HELP,
}
catch (ArgumentException ae) {
return 1;
}
try
{
}
catch (ConfigException ce)
{
// Ignore.
}
// Parse the command-line arguments provided to this program.
try {
}
catch (ArgumentException ae) {
return 1;
}
if (!argParser.usageOrVersionDisplayed()) {
// Checks the version - if upgrade required, the tool is unusable
try
{
}
catch (InitializationException e)
{
println(e.getMessageObject());
return 1;
}
try {
this, argParser.getArguments());
getOutputStream(), getErrorStream()));
if (isMenuDrivenMode()) {
// Keep prompting the user until they specify quit of
// there is a fatal exception
while (true) {
getOutputStream().println();
return 0;
}
}
getOutputStream().println();
MenuResult<TaskEntry> r =
if (r.isAgain()) return 1;
getOutputStream().println();
MenuResult<TaskEntry> r =
if (r.isAgain()) return 1;
} else if (!isInteractive()) {
// no-prompt option
getOutputStream().println();
return 0;
}
} catch (LDAPConnectionException lce) {
return 1;
} catch (Exception e) {
return 1;
}
}
return 0;
}
/**
* {@inheritDoc}
*/
public boolean isAdvancedMode() {
return false;
}
/**
* {@inheritDoc}
*/
public boolean isInteractive() {
}
/**
* {@inheritDoc}
*/
public boolean isMenuDrivenMode() {
}
/**
* {@inheritDoc}
*/
public boolean isQuiet() {
return false;
}
/**
* {@inheritDoc}
*/
public boolean isScriptFriendly() {
return false;
}
/**
* {@inheritDoc}
*/
public boolean isVerbose() {
return false;
}
/**
* Creates the summary table.
*
* @throws IOException if there is a problem with screen I/O
* @throws LDAPException if there is a problem getting information
* out to the directory
* @throws ASN1Exception if there is a problem with the encoding
*/
private void printSummaryTable()
}
}
}
} else {
getOutputStream().println();
}
}
/**
* Creates the summary table.
*
* @return list of strings of IDs of all the tasks in the table in order
* of the indexes printed in the table
* @throws IOException if there is a problem with screen I/O
* @throws LDAPException if there is a problem getting information
* out to the directory
* @throws ASN1Exception if there is a problem with the encoding
*/
}
}
int index = 0;
new TaskDrilldownMenu(taskId),
index++;
if (taskEntry.isCancelable()) {
}
}
} else {
getOutputStream().println();
}
new PrintSummaryTop());
}
return menuBuilder.toMenu();
}
/**
* Gets the client that can be used to interact with the task backend.
*
* @return TaskClient for interacting with the task backend.
*/
return this.taskClient;
}
/**
* Base for callbacks that implement top level menu items.
*/
static abstract private class TopMenuCallback
implements MenuCallback<Void> {
/**
* {@inheritDoc}
*/
}
/**
* Called upon task invocation.
*
* @param app this console application
* @return MessageResult result of task
* @throws CLIException if there is a problem
*/
throws CLIException;
}
/**
* Base for callbacks that manage task entries.
*/
static abstract private class TaskOperationCallback
implements MenuCallback<TaskEntry> {
/** ID of the task to manage. */
/**
* Constructs a parameterized instance.
*
* @param taskId if the task to examine
*/
}
/**
* {@inheritDoc}
*/
throws CLIException
{
}
/**
* {@inheritDoc}
*/
throws CLIException;
}
/**
* Executable for printing a task summary table.
*/
throws CLIException
{
// Since the summary table is reprinted every time the
// user enters the top level this task just returns
// 'success'
return MenuResult.success();
}
}
/**
* Exectuable for printing a particular task's details.
*/
/**
* Constructs a parameterized instance.
*
* @param taskId of the task for which information will be displayed
*/
}
/**
* {@inheritDoc}
*/
while (true) {
try {
// Show the menu
menuBuilder.addBackOption(true);
new PrintTaskInfo(taskId));
new ViewTaskLogs(taskId));
}
new CancelTask(taskId));
}
break;
}
} catch (Exception e) {
}
}
} else {
}
return MenuResult.success();
}
}
/**
* Exectuable for printing a particular task's details.
*/
/**
* Constructs a parameterized instance.
*
* @param taskId of the task for which information will be printed
*/
super(taskId);
}
/**
* {@inheritDoc}
*/
throws CLIException
{
Message m;
try {
m = taskEntry.getScheduleTab();
table.appendCell(m);
} else {
m = taskEntry.getScheduledStartTime();
} else {
table.appendCell(m);
}
}
// Create a table for the task options
table = new TableBuilder();
}
table.appendCell();
}
}
}
sw = new StringWriter();
// Print the last log message if any
// Create a table for the last log entry
table = new TableBuilder();
sw = new StringWriter();
}
} catch (Exception e) {
taskId, e.getMessage()));
return MenuResult.again();
}
}
/**
* Writes an attribute and associated values to the table.
* @param table of task details
* @param fieldLabel of attribute
* @param values of the attribute
*/
}
/**
* Writes an attribute and associated values to the table.
*
* @param table of task details
* @param fieldLabel of attribute
* @param values of the attribute
* @param noneLabel label for the value column when there are no values
*/
} else {
}
table.appendCell();
}
}
}
}
/**
* Exectuable for printing a particular task's details.
*/
/**
* Constructs a parameterized instance.
*
* @param taskId of the task for which log records will be printed
*/
super(taskId);
}
/**
* {@inheritDoc}
*/
throws CLIException
{
try {
// Create a table for the last log entry
}
} else {
}
} catch (Exception e) {
}
}
}
/**
* Executable for canceling a particular task.
*/
/**
* Constructs a parameterized instance.
*
* @param taskIds of all known tasks
* @param cancelableIndices list of integers whose elements represent
* the indices of <code>taskIds</code> that are cancelable
*/
this.cancelableIndices = cancelableIndices;
}
/**
* {@inheritDoc}
*/
throws CLIException
{
// Prompt for the task number
}
try {
if (!cancelableIndices.contains(i)) {
} else {
index = i - 1;
}
} catch (NumberFormatException nfe) {
// ignore;
}
try {
return MenuResult.success();
} else {
return MenuResult.again();
}
} catch (Exception e) {
taskId, e.getMessage()));
return MenuResult.again();
}
} else {
return MenuResult.again();
}
} else {
return MenuResult.cancel();
}
} else {
return MenuResult.cancel();
}
}
}
/**
* Executable for canceling a particular task.
*/
/**
* Constructs a parameterized instance.
*
* @param taskId of the task to cancel
*/
super(taskId);
}
/**
* {@inheritDoc}
*/
throws CLIException
{
try {
if (entry.isCancelable()) {
} else {
return MenuResult.again();
}
} catch (Exception e) {
taskId, e.getMessage()));
return MenuResult.again();
}
}
}
}