CommandManager.java revision 231b2dbbbc26e620c41026c9211d248e47859b51
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (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
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: CommandManager.java,v 1.37 2010/01/28 00:47:10 bigfatrat Exp $
*
*/
/*
* Portions Copyrighted 2010-2015 ForgeRock AS.
* Portions Copyrighted 2014 Nomura Research Institute, Ltd
*/
/**
* This is the "engine" that drives the CLI. This is a singleton class.
*/
public class CommandManager {
public static ResourceBundle resourceBundle;
private ResourceBundle rbMessages;
private Map environment;
private String commandName;
private FileOutputStream statusOS;
private IOutput outputWriter;
private List definitionObjects;
private boolean bContinue;
public static InitializeSystem initSys;
private static boolean importSvcCmd;
static {
}
/**
* Entry point to the engine.
*/
boolean bBootstrapped = true;
if (importSvcCmd) {
try {
initSys = new InitializeSystem();
} catch (FileNotFoundException ex) {
ex.getMessage());
} catch (IOException ex) {
ex.getMessage());
} catch (LDAPServiceException ex) {
ex.getMessage());
}
} else {
try {
//Set specific modules for the Guice InjectorHolder to be initialised with.
// Initialize AdminTokenAction
} catch (ConfiguratorException ex) {
bBootstrapped = false;
) {
}
} catch (Exception e) {
e.getMessage());
}
if (bBootstrapped) {
}
}
}
if (bBootstrapped) {
Crypt.checkCaller();
}
new CommandManager(argv);
}
/**
* Constructs a command line manager.
*
* @param env Map of option name to values.
*/
throws CLIException {
}
/**
* Constructs a command line manager.
*
* @param argv Options from the command shell.
*/
int exitCode = 0;
try {
} catch (CLIException e) {
// cannot print debugger for import service configuration
// sub command before CLI is not bootstrapped.
if (!importSvcCmd) {
}
if (!requestQueue.isEmpty()) {
}
// If cannot get L10N Message, then get the detail message.
msg = e.getMessage();
msg = "An unknown error has occurred. Please check the debug logs.";
}
}
if (outputWriter != null) {
}
} else {
}
}
exitCode = e.getExitCode();
} finally {
}
}
private void printUsageOnException(CLIException e) {
int exitCode = e.getExitCode();
try {
}
}
}
} catch (CLIException ex) {
}
}
throws CLIException {
environment = new HashMap();
}
try {
} catch (MissingResourceException e) {
}
"exception-message-missing-command-name"),
}
if (outputWriter == null) {
throw new CLIException("output writer is not defined.",
}
}
}
if (webEnabledURL != null) {
}
}
throws CLIException
{
environment = new HashMap();
"exception-message-missing-command-name"),
}
) {
}
) {
}
) {
}
}
throws CLIException
{
"exception-message-missing-definition-class"),
}
}
throws CLIException
{
if (isVerbose()) {
"verbose-reading-definition-files"));
}
definitionObjects = new ArrayList();
while (st.hasMoreTokens()) {
}
}
throws CLIException
{
try {
} catch (ClassNotFoundException e) {
"exception-message-definition-class-not-found"), param);
} catch (IllegalAccessException e) {
e.printStackTrace();
"exception-message-illegal-access-definition-class"),
param);
throw new CLIException(message,
} catch (InstantiationException e) {
e.printStackTrace();
"exception-message-instantiation-definition-class"), param);
throw new CLIException(message,
} catch (ClassCastException e) {
"exception-message-class-cast-definition-class"), param);
throw new CLIException(message,
}
}
/**
* Returns resource bundle.
*
* @return resource bundle.
*/
public ResourceBundle getResourceBundle() {
return rbMessages;
}
/**
* Returns commandline interface name.
*
* @return commandline interface name.
*/
public String getCommandName() {
return commandName;
}
/**
* Sets status file name.
*
* @param statusFileName Status file name.
* @throws CLIException if status file cannot be created.
*/
throws CLIException {
) {
try {
} catch (FileNotFoundException ex) {
throw new CLIException(ex,
}
}
}
/**
* Returns a list of definition objects. Since this class is just
* a engine, it requires definition objects to dictate the behavior
* of the CLI.
*
* @return a list of definition objects.
*/
public List getDefinitionObjects() {
return definitionObjects;
}
/**
* Returns <code>true</code> is log is turned off.
*
* @return <code>true</code> is log is turned off.
*/
public boolean isLogOff() {
}
/**
* Returns log name.
*
* @return log name.
*/
public String getLogName() {
return logName;
}
/**
* Returns locale object.
*
* @return locale object.
*/
}
/**
* Returns true of the CLI has verbose set.
*
* @return true of the CLI has verbose set.
*/
public boolean isVerbose() {
}
/**
* Returns true of the CLI has debug turned on.
*
* @return true of the CLI has debug turned on.
*/
public boolean isDebugOn() {
}
/**
* Returns debugger.
*
* @return debugger.
*/
public static Debug getDebugger() {
return debugger;
}
/**
* Returns output writer.
*
* @return output writer.
*/
public IOutput getOutputWriter() {
return outputWriter;
}
/**
* Returns the sub command of a given name.
*
* @param name Name of Sub Command.
* @return the sub command.
*/
) {
}
return subcmd;
}
/**
* Returns product name.
*
* @return product name.
*/
public String getProductName() {
}
return productName;
}
throws CLIException
{
try {
} else {
}
} catch (Exception e) {
// cannot localize yet - have not gotten resource bundle
}
}
/**
* Services the request queue.
*
* @throws CLIException if request cannot be processed.
*/
public void serviceRequestQueue()
throws CLIException {
if (isVerbose()) {
}
try {
while (!requestQueue.isEmpty()) {
try {
}
} catch (CLIException e) {
if (isVerbose()) {
}
e.getExitCode());
}
if (bContinue) {
} else {
throw e;
}
}
}
} catch (IOException e) {
} finally {
try {
} catch (IOException ex) {
// ignored
}
}
}
}
if (exitCode < 10) {
} else if (exitCode < 100) {
}
}
}
private static boolean getFlag(
) throws CLIException
{
boolean flag = false;
) {
flag = true;
int nextIdx = i+1;
throw new CLIException(
}
}
}
}
return flag;
}
throws CLIException
{
if (s.equals(
s.equals(
) {
int nextIdx = i+1;
throw new CLIException("Incorrect locale option.",
} else {
if (strLocale.startsWith(
) {
throw new CLIException("Incorrect locale option.",
} else {
}
}
}
}
}
try {
} catch (MissingResourceException e) {
}
}
}
private static void getIsInstallTime() {
/*
* Set the property to inform AdminTokenAction that
* "amadmin" CLI is executing the program
*/
}
}
}
/**
* in the event that one or more requests are errornous if this flag is
* set. On the other hand, queue of requests shall be terminated at the
* first encountered errorous request if this flag is reset.
*
* @param bContinue Continue status flag.
*/
public void setContinueFlag(boolean bContinue) {
}
/**
* Adds request to request queue.
*
* @param request CLI Request object to be added to the queue.
*/
}
/**
* Returns Web enabled URL.
*
* @return Web enabled URL.
*/
public String getWebEnabledURL() {
}
/**
* Returns <code>true</code> if command manager is created from JSP.
*
* @return <code>true</code> if command manager is created from JSP.
*/
public boolean webEnabled() {
}
/**
* Registers Single Single On Token which will be destroyed after
* CLI is done.
*
* @param ssoToken Single Sign On Token.
*/
}
private void destroySSOTokens() {
try {
}
if (!importSvcCmd) {
}
} catch (SSOException e) {
}
}
}