StatusCli.java revision 3bd997f0d659b0b5280791733d0101a588b01da5
/*
* 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.
*/
/**
* The class used to provide some CLI interface to display status.
*
* This class basically is in charge of parsing the data provided by the user
* in the command line.
*
*/
class StatusCli extends SecureConnectionCliParser
{
private boolean displayMustAuthenticateLegend;
private boolean displayMustStartLegend;
/**
* The Logger.
*/
/**
* The main method which is called by the status command lines.
* @param args the arguments passed by the status command lines.
*/
{
}
/**
* The constructor for this object.
* @param args the arguments of the status command line.
*/
{
INFO_STATUS_CLI_USAGE_DESCRIPTION.get(), false);
}
/**
* Parses the user data and displays usage if something is missing and the
* status otherwise.
*
* @return the return code (SUCCESSFUL, USER_DATA_ERROR or BUG.
*/
int run()
{
try
{
}
catch (ArgumentException ae)
{
}
// Validate user provided data
try
{
}
catch (ArgumentException ae)
{
}
// If we should just display usage or version information,
// then print it and exit.
if (usageOrVersionDisplayed())
{
}
{
return v;
}
else
{
boolean isServerRunning =
/* This is required to retrieve the ldap url to be used by the
* ConfigFromLDAP class.
*/
try
{
if (isServerRunning)
{
if (directoryManagerDn == null)
{
directoryManagerDn = "";
}
if (directoryManagerPwd == null)
{
directoryManagerPwd = "";
}
if (startTLSArg.isPresent())
{
}
{
}
else
{
}
}
else
{
null);
}
}
catch (ConfigException ce)
{
}
}
}
{
{
}
else
{
}
return desc;
}
/**
* Updates the ServerStatusDescriptor object using the information in the
* config.ldif file (we use a ConfigFromFile object to do this).
* @param desc the ServerStatusDescriptor object to be updated.
* @param offLineConf the ConfigFromFile object to be used.
*/
{
}
/**
* Updates the ServerStatusDescriptor object using the LDAP protocol (we use a
* ConfigFromLDAP object to do this).
* @param desc the ServerStatusDescriptor object to be updated.
* @param onLineConf the ConfigFromLDAP object to be used.
*/
{
}
{
{
};
int labelWidth = 0;
{
}
{
}
else if (displayMustAuthenticateLegend)
{
}
}
/**
* Writes the status contents displaying with what is specified in the
* provided ServerStatusDescriptor object.
* @param desc the ServerStatusDescriptor object.
*/
int maxLabelWidth)
{
{
case STARTED:
break;
case STOPPED:
break;
case STARTING:
break;
case STOPPING:
break;
case UNKNOWN:
break;
default:
}
}
/**
* Writes the current connection contents displaying with what is specified
* in the provided ServerStatusDescriptor object.
* @param desc the ServerStatusDescriptor object.
*/
int maxLabelWidth)
{
{
if (nConn >= 0)
{
}
else
{
if (!desc.isAuthenticated())
{
}
else
{
text = getNotAvailableText();
}
}
}
else
{
}
}
/**
* Writes the administrative user contents displaying with what is specified
* in the provided ServerStatusDescriptor object.
* @param desc the ServerStatusDescriptor object.
*/
int maxLabelWidth)
{
{
// First one already printed
{
}
}
else
{
{
if (!desc.isAuthenticated())
{
}
else
{
text = getNotAvailableText();
}
}
else
{
text = getNotAvailableText();
}
}
}
/**
* Writes the install path contents displaying with what is specified in the
* provided ServerStatusDescriptor object.
* @param desc the ServerStatusDescriptor object.
*/
int maxLabelWidth)
{
}
/**
* Updates the server version contents displaying with what is specified in
* the provided ServerStatusDescriptor object.
* This method must be called from the event thread.
* @param desc the ServerStatusDescriptor object.
*/
int maxLabelWidth)
{
}
/**
* Updates the java version contents displaying with what is specified in
* the provided ServerStatusDescriptor object.
* This method must be called from the event thread.
* @param desc the ServerStatusDescriptor object.
*/
int maxLabelWidth)
{
{
{
if (!desc.isAuthenticated())
{
}
else
{
text = getNotAvailableText();
}
}
}
else
{
}
}
/**
* Writes the listeners contents displaying with what is specified in
* the provided ServerStatusDescriptor object.
* @param desc the ServerStatusDescriptor object.
*/
{
{
{
if (!desc.isAuthenticated())
{
}
else
{
}
}
else
{
}
}
else
{
}
}
/**
* Writes the databases contents displaying with what is specified in
* the provided ServerStatusDescriptor object.
* @param desc the ServerStatusDescriptor object.
*/
{
{
{
if (!desc.isAuthenticated())
{
}
else
{
}
}
else
{
}
}
else
{
{
}
}
}
/**
* Writes the error label contents displaying with what is specified in
* the provided ServerStatusDescriptor object.
* @param desc the ServerStatusDescriptor object.
*/
{
{
}
}
/**
* Returns the not available text explaining that the data is not available
* because the server is down.
* @return the text.
*/
{
displayMustStartLegend = true;
return INFO_NOT_AVAILABLE_SERVER_DOWN_CLI_LABEL.get();
}
/**
* Returns the not available text explaining that the data is not available
* because authentication is required.
* @return the text.
*/
{
displayMustAuthenticateLegend = true;
}
/**
* Returns the not available text explaining that the data is not available.
* @return the text.
*/
private Message getNotAvailableText()
{
return INFO_NOT_AVAILABLE_LABEL.get();
}
/**
* Writes the contents of the provided table model simulating a table layout
* using text.
* @param tableModel the TableModel.
* @param desc the Server Status descriptor.
*/
{
{
}
{
{
if (v != null)
{
if (v instanceof String)
{
}
else if (v instanceof Integer)
{
if (nEntries >= 0)
{
}
else
{
if (!desc.isAuthenticated())
{
}
else
{
text = getNotAvailableText();
}
}
}
else
{
throw new IllegalStateException("Unknown object type: "+v);
}
}
}
}
int totalWidth = 0;
{
{
maxWidths[i] += 5;
}
totalWidth += maxWidths[i];
}
{
for (int j=0; j<extra; j++)
{
}
}
MessageBuilder t = new MessageBuilder();
{
t.append("=");
}
{
{
if (v != null)
{
if (v instanceof String)
{
}
else if (v instanceof Integer)
{
if (nEntries >= 0)
{
}
else
{
if (!desc.isAuthenticated())
{
}
else
{
}
}
}
else
{
throw new IllegalStateException("Unknown object type: "+v);
}
}
for (int k=0; k<extra; k++)
{
}
}
}
}
/**
* Writes the contents of the provided database table model. Every base DN
* is written in a block containing pairs of labels and values.
* @param tableModel the TableModel.
* @param desc the Server Status descriptor.
*/
{
boolean isRunning =
int labelWidth = 0;
{
if (i == 5)
{
}
else
{
}
}
{
if (i > 0)
{
}
{
if (v != null)
{
if (v instanceof String)
{
}
else if (v instanceof Message)
{
}
else if (v instanceof Integer)
{
if (nEntries >= 0)
{
}
else
{
if (!isRunning)
{
}
if (!desc.isAuthenticated())
{
}
else
{
value = getNotAvailableText();
}
}
}
else
{
throw new IllegalStateException("Unknown object type: "+v);
}
}
else
{
}
{
if (!isRunning)
{
}
if (!desc.isAuthenticated())
{
}
}
boolean doWrite = true;
if ((j == 4) || (j == 5))
{
// If the suffix is not replicated we do not have to display these
// lines.
{
doWrite = false;
}
}
if (doWrite)
{
}
}
}
}
{
for (int i = 0; i<extra; i++)
{
}
}
{
{
for (int i=0; i<extra; i++)
{
}
}
else
{
}
return centered;
}
}