Methods Summary |
---|
private java.lang.String | createFillString(char fillChar, int size)Will create a string of the size specified filled with the fillChar.
String fillString = "";
for (int i=0; i<size; i++)
{
fillString += fillChar;
}
return fillString;
|
protected com.sun.jbi.ui.common.JBIManagementMessage | extractJBIManagementMessage(java.lang.Exception ex)Will extract the JBIManagementMessgae from the Remote exception.
JBIManagementMessage mgmtMsg = null;
if (ex instanceof JBIRemoteException)
{
JBIRemoteException rEx = (JBIRemoteException)ex;
mgmtMsg = rEx.extractJBIManagementMessage();
}
else
{
String exMessage = ex.getMessage();
mgmtMsg = JBIManagementMessage.createJBIManagementMessage(exMessage);
}
return mgmtMsg;
|
private java.lang.String | formatDescription(java.lang.String description, int maxLength, int indentAmount)Will format the description text that is displayed in the show commands. The
formatting will consist of removing all new lines and extra white space, then
adding back in line breaks at the first avaliable location that is less then
or equal to the given max line length.
// Strip out the leading white spaces in each row, and remove any "\n"
int endIndex = 0;
int startIndex = 0;
String finalString = "";
String rowString = "";
String space = "";
endIndex = description.indexOf("\n",startIndex);
while (endIndex != -1)
{
rowString = description.substring(startIndex,endIndex).trim();
finalString += space + rowString;
startIndex = endIndex + 1;
endIndex = description.indexOf("\n",startIndex);
space = " ";
}
rowString = description.substring(startIndex).trim();
finalString += space + rowString;
// Format the string by adding the line breaks in the correct location and adding
// the indention amount at that beginning of each row.
endIndex = 0;
startIndex = 0;
int spaceIndex = 0;
int indentSize = 0;
String newString = "";
boolean done = false;
int totalLength = finalString.length();
while (!(done))
{
endIndex = ((startIndex + maxLength) > totalLength) ? totalLength : (startIndex + maxLength);
rowString = finalString.substring(startIndex,endIndex);
spaceIndex = startIndex + rowString.lastIndexOf(" ");
if (endIndex < totalLength)
{
spaceIndex = startIndex + rowString.lastIndexOf(" ");
if (spaceIndex != -1)
{
endIndex = spaceIndex;
}
}
rowString = finalString.substring(startIndex,endIndex) + "\n";
startIndex = endIndex + 1;
newString += createFillString(' ",indentSize) + rowString;
indentSize = indentAmount;
if (startIndex >= totalLength)
{
done = true;
}
}
finalString = newString.trim();
return finalString;
|
protected java.lang.String | getOption(java.lang.String optionName, java.lang.String[] validOptions, java.lang.String defaultValue)Method that will return the option value or if no option value
was specified, the default value will be returned.
boolean found = false;
String option = getOption(optionName);
if (option == null)
{
option = defaultValue;
found = true;
}
else
{
for (int i=0; i<validOptions.length; i++)
{
if (option.equalsIgnoreCase(validOptions[i]))
{
found = true;
break;
}
}
}
if (found) {
return option;
}
else {
throw new CommandValidationException(getLocalizedString("InvalidValueInOption",
new Object[]{optionName}));
}
|
protected java.lang.String | getOption(java.lang.String optionName, java.lang.String[] validOptions)Method that will return the option value or if no option value
was specified, the default value will be returned.
String defaultValue = null;
return getOption(optionName, validOptions, defaultValue);
|
protected boolean | preRunInit()Perform the pre run initialization. This will validate the options as
well as retrieve the MBean Server Connection.
boolean uploadFlag = false;
return preRunInit(uploadFlag);
|
protected boolean | preRunInit(boolean uploadFlag)Perform the pre run initialization. This will validate the options as
well as retrieve the MBean Server Connection.
// Validate the options and opeands
validateOptions();
// For Testing only -- Will remove later --
//validateUsageText();
// Retrieve the MBean Server Connection and the JBIAdminCommands object.
mbsc = getMBeanServerConnection(getHost(),
getPort(),
getUser(),
getPassword());
// Retrieve the JBI Admin Command object
try {
mJbiAdminCommands = JBIAdminCommandsClientFactory.getInstance(mbsc,uploadFlag);
}
catch (Exception e) {
displayExceptionMessage(e);
}
// Make sure we have a valid command object
if (mJbiAdminCommands == null)
{
throw new CommandException(getLocalizedString("CouldNotInvokeCommand",
new Object[]{name}));
}
return true;
|
protected void | processJBIAdminAsseblyListResult(java.lang.String result)Will process the list results for the Service Assemblies
List list = ServiceAssemblyInfo.readFromXmlTextWithProlog(result);
if (list.size() == 0)
{
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("NoElementsToList",new Object[] {result}));
}
else
{
Iterator it = list.iterator();
String listBreak = "";
int count = 0;
while (it.hasNext())
{
ServiceAssemblyInfo info = ((ServiceAssemblyInfo)it.next());
String assemblyName = info.getName();
CLILogger.getInstance().printDetailMessage (assemblyName);
// TBD append global state info to end of name
//String assemblyName = info.getName();
//String state = info.getState();
//String outputString = assemblyName + " : " + state;
//CLILogger.getInstance().printDetailMessage (outputString);
}
}
|
protected void | processJBIAdminComponentListResult(java.lang.String result)Will process the list results for the components (Service Engines,
Binding Components and Shared Libraries).
was specified, the default value will be returned.
List list = JBIComponentInfo.readFromXmlText(result);
if (list.size() == 0)
{
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("NoElementsToList",new Object[] {result}));
}
else
{
Iterator it = list.iterator();
String listBreak = "";
int count = 0;
while (it.hasNext())
{
JBIComponentInfo info = ((JBIComponentInfo)it.next());
String componentName = info.getName();
CLILogger.getInstance().printDetailMessage (componentName);
// TBD append global state info to end of name
//String componentName = info.getName();
//String state = info.getState();
//String outputString = componentName + " : " + state;
//CLILogger.getInstance().printDetailMessage (outputString);
}
}
|
protected void | processJBIAdminResult(java.lang.String result, java.lang.String successKey)** Still Under Development **
Will process the list results for the Service Assemblies
JBIManagementMessage mgmtMsg =
JBIManagementMessage.createJBIManagementMessage(result);
if (mgmtMsg == null)
{
CLILogger.getInstance().printDetailMessage (
getLocalizedString (successKey, new Object[] {result}));
}
else
{
if (mgmtMsg.isSuccessMsg())
{
String msg = mgmtMsg.getMessage();
int index = msg.indexOf(")");
if (index != -1)
{
msg = msg.substring(index+1);
}
CLILogger.getInstance().printDetailMessage (msg);
}
else
{
String msg = mgmtMsg.getMessage();
throw new CommandException(msg);
}
}
|
protected void | processJBIAdminShowAssemblyResult(java.lang.String result, java.lang.String aName)Will format and display the Service Assembly show results.
List list = ServiceAssemblyInfo.readFromXmlTextWithProlog(result);
if ( list.size() <= 0 )
{
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBINoServiceAssemblyToShow",new Object[] {aName}));
}
else
{
Iterator itr = list.iterator();
ServiceAssemblyInfo saInfo = (ServiceAssemblyInfo) itr.next();
List suInfoList = saInfo.getServiceUnitInfoList();
String saName = saInfo.getName();
String saState = saInfo.getState();
String saDescription = saInfo.getDescription();
String saSize = Integer.toString(suInfoList.size());
String formattedSADescription = formatDescription(saDescription,50,16);
CLILogger.getInstance().printDetailMessage ("");
String SAHeader = getLocalizedString ("JBIServiceAssemblyShowHeader");
CLILogger.getInstance().printDetailMessage (SAHeader);
CLILogger.getInstance().printDetailMessage (createFillString('-",SAHeader.length()));
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBIServiceAssemblyName",new Object[] {saName}));
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBIServiceAssemblyState",new Object[] {saState}));
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBIServiceAssemblyServiceUnits",new Object[] {saSize}));
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBIServiceAssemblyDescription",new Object[] {formattedSADescription}));
String indentString = " ";
CLILogger.getInstance().printDetailMessage ("");
String SUHeader = getLocalizedString ("JBIServiceUnitShowHeader");
CLILogger.getInstance().printDetailMessage (indentString + SUHeader);
CLILogger.getInstance().printDetailMessage (indentString + createFillString('-",SUHeader.length()));
boolean firstTime = true;
for (Iterator suItr = suInfoList.iterator(); suItr.hasNext();)
{
ServiceUnitInfo suInfo = (ServiceUnitInfo ) suItr.next();
String suState = suInfo.getState();
String suDepoyedOn = suInfo.getDeployedOn();
String suName = suInfo.getName();
String suDescription = suInfo.getDescription();
String formattedSUDescription = formatDescription(suDescription,50,18);
if (!(firstTime))
{
CLILogger.getInstance().printDetailMessage ("");
}
CLILogger.getInstance().printDetailMessage (indentString +
getLocalizedString ("JBIServiceUnitName",new Object[] {suName}));
CLILogger.getInstance().printDetailMessage (indentString +
getLocalizedString ("JBIServiceUnitState",new Object[] {suState}));
CLILogger.getInstance().printDetailMessage (indentString +
getLocalizedString ("JBIServiceUnitDeployedOn",new Object[] {suDepoyedOn}));
CLILogger.getInstance().printDetailMessage (indentString +
getLocalizedString ("JBIServiceUnitDescription",new Object[] {formattedSUDescription}));
firstTime = false;
}
}
|
protected void | processJBIAdminShowComponentResult(java.lang.String result, java.lang.String aName)Will format and display the component (binding or engine) show results.
List list = JBIComponentInfo.readFromXmlText(result);
if (list.size() == 0)
{
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBINoComponentToShow",new Object[] {aName}));
}
else
{
CLILogger.getInstance().printDetailMessage ("");
String header = getLocalizedString ("JBIComponentShowHeader");
CLILogger.getInstance().printDetailMessage (header);
CLILogger.getInstance().printDetailMessage (createFillString('-",header.length()));
Iterator it = list.iterator();
JBIComponentInfo info = ((JBIComponentInfo)it.next());
String componentName = info.getName();
String componentState = info.getState();
String componentDescription = info.getDescription();
String formattedDescription = formatDescription(componentDescription,50,14);
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBIComponentName",new Object[] {componentName}));
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBIComponentState",new Object[] {componentState}));
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBIComponentDescription",new Object[] {formattedDescription}));
}
|
protected void | processJBIAdminShowLibraryResult(java.lang.String result, java.lang.String aName)Will format and display the Shared Library show results.
List list = JBIComponentInfo.readFromXmlText(result);
if (list.size() == 0)
{
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBINoLibraryToShow",new Object[] {aName}));
}
else
{
CLILogger.getInstance().printDetailMessage ("");
String header = getLocalizedString ("JBISharedLibraryShowHeader");
CLILogger.getInstance().printDetailMessage (header);
CLILogger.getInstance().printDetailMessage (createFillString('-",header.length()));
Iterator it = list.iterator();
JBIComponentInfo info = ((JBIComponentInfo)it.next());
String libraryName = info.getName();
String libraryDescription = info.getDescription();
String formattedDescription = formatDescription(libraryDescription,50,14);
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBISharedLibraryName",new Object[] {libraryName}));
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("JBISharedLibraryDescription",new Object[] {formattedDescription}));
}
|
protected void | processTaskException(java.lang.Exception ex)Will process the task exception to display the error message.
JBIManagementMessage mgmtMsg = extractJBIManagementMessage(ex);
if (mgmtMsg == null)
{
displayExceptionMessage(ex);
}
else
{
// Display the exception message which was returned from the runtime.
String msg = mgmtMsg.getMessage();
CLILogger.getInstance().printDetailMessage (msg);
// Display the CLI success or failure message.
if (msg.trim().startsWith("WARNING")) {
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("CommandSuccessful",new Object[] {name}));
}
else {
CLILogger.getInstance().printDetailMessage (
getLocalizedString ("CommandUnSuccessful",new Object[] {name}));
}
}
|
protected java.lang.String | validateFilePath(java.lang.String filePath)Method that will validate that the given file path exists and is not
a directory.
return validateFilePath ("FileDoesNotExist",filePath);
|
protected java.lang.String | validateFilePath(java.lang.String errorKey, java.lang.String filePath)Method that will validate that the given file path exists and is not
a directory.
File file = new File(filePath);
String absolutePath = file.getAbsolutePath();
if ((!file.exists()) || (file.isDirectory()))
{
throw new CommandException(getLocalizedString(errorKey,
new Object[]{filePath}));
}
return absolutePath;
|
public boolean | validateOptions()An abstract method that validates the options
on the specification in the xml properties file
This method verifies for the correctness of number of
operands and if all the required options are supplied by the client.
return super.validateOptions();
|