UninstallerArgumentParser.java revision bf7236c96ba10b04b60169ee7c84327b4998ffc9
/*
* 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.
*/
/**
* Class used to parse and populate the arguments of the Uninstaller.
*
*/
public class UninstallerArgumentParser extends SecureConnectionCliParser
{
private BooleanArgument cliArg;
private BooleanArgument noPromptArg;
private BooleanArgument quietArg;
private BooleanArgument removeAllArg;
private BooleanArgument removeServerLibrariesArg;
private BooleanArgument removeDatabasesArg;
private BooleanArgument removeLogFilesArg;
private BooleanArgument removeBackupFilesArg;
private BooleanArgument removeLDIFFilesArg;
private StringArgument referencedHostNameArg;
/**
* Creates a new instance of this argument parser with no arguments.
*
* @param mainClassName
* The fully-qualified name of the Java class that should
* be invoked to launch the program with which this
* argument parser is associated.
* @param toolDescription
* A human-readable description for the tool, which will be
* included when displaying usage information.
* @param longArgumentsCaseSensitive
* Indicates whether subcommand and long argument names
* should be treated in a case-sensitive manner.
*/
{
}
/**
* Initialize Global option.
*
* @param outStream
* The output stream used for the usage.
* @throws ArgumentException
* If there is a problem with any of the parameters used
* to create this argument.
*/
throws ArgumentException
{
cliArg = new BooleanArgument(
removeAllArg = new BooleanArgument(
"remove-all",
'a',
"remove-all",
);
"server-libraries",
'l',
"server-libraries",
);
"databases",
'd',
"databases",
);
removeLogFilesArg = new BooleanArgument(
"log-files",
'L',
"log-files",
);
"configuration-files",
'c',
"configuration-files",
);
"backup-files",
'b',
"backup-files",
);
"ldif-files",
'e',
"ldif-files",
);
noPromptArg = new BooleanArgument(
forceOnErrorArg = new BooleanArgument(
"forceOnError",
'f',
"forceOnError",
quietArg = new BooleanArgument(
{
}
if (index != -1)
{
}
else
{
}
OPTION_LONG_REFERENCED_HOST_NAME, false, false, true,
}
/**
* Tells whether the user specified to have an interactive uninstall or not.
* This method must be called after calling parseArguments.
* @return <CODE>true</CODE> if the user specified to have an interactive
* uninstall and <CODE>false</CODE> otherwise.
*/
public boolean isInteractive()
{
return !noPromptArg.isPresent();
}
/**
* Tells whether the user specified to force on non critical error in the non
* interactive mode.
* @return <CODE>true</CODE> if the user specified to force the uninstall in
* non critical error and <CODE>false</CODE> otherwise.
*/
public boolean isForceOnError()
{
return forceOnErrorArg.isPresent();
}
/**
* Tells whether the user specified to have a quiet uninstall or not.
* This method must be called after calling parseArguments.
* @return <CODE>true</CODE> if the user specified to have a quiet
* uninstall and <CODE>false</CODE> otherwise.
*/
public boolean isQuiet()
{
}
/**
* Tells whether the user specified to remove all files.
* This method must be called after calling parseArguments.
* @return <CODE>true</CODE> if the user specified to remove all files and
* <CODE>false</CODE> otherwise.
*/
public boolean removeAll()
{
return removeAllArg.isPresent();
}
/**
* Tells whether the user specified to remove library files.
* This method must be called after calling parseArguments.
* @return <CODE>true</CODE> if the user specified to remove library files and
* <CODE>false</CODE> otherwise.
*/
public boolean removeServerLibraries()
{
return removeServerLibrariesArg.isPresent();
}
/**
* Tells whether the user specified to remove database files.
* This method must be called after calling parseArguments.
* @return <CODE>true</CODE> if the user specified to remove database files
* and <CODE>false</CODE> otherwise.
*/
public boolean removeDatabases()
{
return removeDatabasesArg.isPresent();
}
/**
* Tells whether the user specified to remove configuration files.
* This method must be called after calling parseArguments.
* @return <CODE>true</CODE> if the user specified to remove configuration
* files and <CODE>false</CODE> otherwise.
*/
public boolean removeConfigurationFiles()
{
return removeConfigurationFilesArg.isPresent();
}
/**
* Tells whether the user specified to remove backup files.
* This method must be called after calling parseArguments.
* @return <CODE>true</CODE> if the user specified to remove backup files and
* <CODE>false</CODE> otherwise.
*/
public boolean removeBackupFiles()
{
return removeBackupFilesArg.isPresent();
}
/**
* Tells whether the user specified to remove LDIF files.
* This method must be called after calling parseArguments.
* @return <CODE>true</CODE> if the user specified to remove LDIF files and
* <CODE>false</CODE> otherwise.
*/
public boolean removeLDIFFiles()
{
return removeLDIFFilesArg.isPresent();
}
/**
* Tells whether the user specified to remove log files.
* This method must be called after calling parseArguments.
* @return <CODE>true</CODE> if the user specified to remove log files and
* <CODE>false</CODE> otherwise.
*/
public boolean removeLogFiles()
{
return removeLogFilesArg.isPresent();
}
/**
* Returns the default Administrator UID value.
* @return the default Administrator UID value.
*/
public String getDefaultAdministratorUID()
{
}
/**
* Returns the Host name to update remote references as provided in the
* command-line.
* @return the Host name to update remote references as provided in the
* command-line.
*/
public String getReferencedHostName()
{
if (referencedHostNameArg.isPresent())
{
}
return hostName;
}
/**
* Returns the default value for the Host name to update remote references as
* provided in the command-line.
* @return the default value for the Host name to update remote references as
* provided in the command-line.
*/
public String getDefaultReferencedHostName()
{
return referencedHostNameArg.getDefaultValue();
}
/**
* Indication if provided global options are validate.
*
* @param buf the MessageBuilder to write the error messages.
* @return return code.
*/
{
int returnValue;
{
{
}
}
if (removeAllArg.isPresent())
{
BooleanArgument[] removeArgs = {
};
{
if (removeArgs[i].isPresent())
{
removeArgs[i].getLongIdentifier());
{
}
}
}
}
{
}
else
{
}
return returnValue;
}
/**
* Returns whether the command was launched in CLI mode or not.
* @return <CODE>true</CODE> if the command was launched to use CLI mode and
* <CODE>false</CODE> otherwise.
*/
public boolean isCli()
{
}
/**
* Returns the SecureConnectionCliArgs object containing the arguments
* of this parser.
* @return the SecureConnectionCliArgs object containing the arguments
* of this parser.
*/
{
return secureArgsList;
}
}