com.ibm.mmconsole.extension.er
Class ExecuteTaskImpl

java.lang.Object
  extended by com.ibm.mmconsole.extension.er.BaseExtensionPointImpl
      extended by com.ibm.mmconsole.extension.er.ExecuteTaskImpl
All Implemented Interfaces:
IBaseExtensionPoint, IExecuteTask

public class ExecuteTaskImpl
extends BaseExtensionPointImpl
implements IExecuteTask

This is the execute task extension point for Express Runtime. IExecuteTask.


Field Summary
static java.lang.String IRU_CERT_ERROR
           
static java.lang.String NO_FILES_TO_SEND_ERROR
           
 
Fields inherited from interface com.ibm.mmconsole.extension.IExecuteTask
STARTED, STOPPED, UNAVAILABLE, UNKNOWN
 
Constructor Summary
ExecuteTaskImpl()
          Default constructor
ExecuteTaskImpl(java.util.Locale userLocale)
          A constructor that takes a Locale object.
 
Method Summary
 void addDirectoryToSend(java.io.File directory, java.lang.String directoryToPerverse)
          This method allows you to specify a directory to send to the console agent.
 void addFileToSend(java.io.File file, java.lang.String directoryToPerverse)
          This method allows you to specify an individual file to send to the console agent.
 void destroy()
          Clean up objects
 java.lang.String getAntTaskResult()
          Returns the result of the Ant task.
 java.lang.String getErrorMessage()
          Returns the error message that occurred during execution.
 int getResourceStatus(javax.portlet.PortletRequest request, Resource resource, IConsoleConfiguration consoleConfiguration)
          This method will retrieve the status of the specified resource.
 boolean isThereAFileNotFoundError()
          This method indicates if there was a file not found error when executing a task in which an ANT or a Jython file was specified.
 boolean isThereAuthenticationError()
          This method indicates if the was an authentication error during a task execution.
 boolean launchAntTask(java.lang.String filename, java.lang.String targetName, java.util.Properties properties, Resource resource, javax.portlet.PortletRequest request, IConsoleConfiguration consoleConfiguration, boolean encodeResourceProperties)
          This methods allows you to run an Ant task.
 boolean runWsAdminJythonScript(javax.portlet.PortletRequest request, ApplicationServerResource resource, java.lang.String wasJythonFile, IConsoleConfiguration consoleConfiguration)
          This method enables you to run a Jython script against a specified application server object.
 boolean sendFilesToAgent(Resource resource, javax.portlet.PortletRequest request, IConsoleConfiguration consoleConfiguration)
          This method allows you to send files to the console agent.
 boolean startResource(javax.portlet.PortletRequest request, Resource resource, IConsoleConfiguration consoleConfiguration)
          This method attempts to start the specified resource.
 boolean stopResource(javax.portlet.PortletRequest request, Resource resource, IConsoleConfiguration consoleConfiguration)
          This method attempts to stop the specified resource.
 
Methods inherited from class com.ibm.mmconsole.extension.er.BaseExtensionPointImpl
getUserLocale, setUserLocale
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.mmconsole.extension.IBaseExtensionPoint
getUserLocale, setUserLocale
 

Field Detail

NO_FILES_TO_SEND_ERROR

public static final java.lang.String NO_FILES_TO_SEND_ERROR
See Also:
Constant Field Values

IRU_CERT_ERROR

public static final java.lang.String IRU_CERT_ERROR
See Also:
Constant Field Values
Constructor Detail

ExecuteTaskImpl

public ExecuteTaskImpl()
Default constructor


ExecuteTaskImpl

public ExecuteTaskImpl(java.util.Locale userLocale)
A constructor that takes a Locale object.

Parameters:
userLocale - - - The Locale object representing the user's locale (which is also known as the browser's locale).
Method Detail

getAntTaskResult

public java.lang.String getAntTaskResult()
Returns the result of the Ant task. The result may contain details to truly determine whether the task was successfully completed. Generally, Ant fails if there is an error. However, that might not be true when executing an external script (such as wsadmin). It is not recommended that the result be displayed to the user.

Specified by:
getAntTaskResult in interface IExecuteTask
Returns:
String

getErrorMessage

public java.lang.String getErrorMessage()
Returns the error message that occurred during execution.

Specified by:
getErrorMessage in interface IExecuteTask
Returns:
String

destroy

public void destroy()
Clean up objects

Specified by:
destroy in interface IBaseExtensionPoint
Overrides:
destroy in class BaseExtensionPointImpl

getResourceStatus

public int getResourceStatus(javax.portlet.PortletRequest request,
                             Resource resource,
                             IConsoleConfiguration consoleConfiguration)
This method will retrieve the status of the specified resource.

Specified by:
getResourceStatus in interface IExecuteTask
Parameters:
request - - An instance of PortletRequest.
resource - - An instance of Resource.
consoleConfiguration - - An instance of the IConsoleConfiguration
Returns:
IExecuteTask.STARTED, IExecuteTask.STOPPED, IExecuteTask.UNAVAILABLE, IExecuteTask.UNKNOWN

startResource

public boolean startResource(javax.portlet.PortletRequest request,
                             Resource resource,
                             IConsoleConfiguration consoleConfiguration)
This method attempts to start the specified resource.

Specified by:
startResource in interface IExecuteTask
Parameters:
request - - An instance of PortletRequest.
resource - - An instance of Resource.
consoleConfiguration - - An instance of the IConsoleConfiguration
Returns:
Returns true or false. True means that the task was successfully completed. False means that there was an error.

stopResource

public boolean stopResource(javax.portlet.PortletRequest request,
                            Resource resource,
                            IConsoleConfiguration consoleConfiguration)
This method attempts to stop the specified resource.

Specified by:
stopResource in interface IExecuteTask
Parameters:
request - - An instance of PortletRequest.
resource - - An instance of Resource.
consoleConfiguration - - An instance of the IConsoleConfiguration
Returns:
Returns true or false. True means that the task was successfully completed. False means that there was an error.

runWsAdminJythonScript

public boolean runWsAdminJythonScript(javax.portlet.PortletRequest request,
                                      ApplicationServerResource resource,
                                      java.lang.String wasJythonFile,
                                      IConsoleConfiguration consoleConfiguration)
This method enables you to run a Jython script against a specified application server object. The Jython file must be located on the remote computer relative to the console agent's scripts directory.

Specified by:
runWsAdminJythonScript in interface IExecuteTask
Parameters:
request - - An instance of PortletRequest.
resource - - An instance of ApplicationServerResource.
wasJythonFile - - The name of the Jython script to execute. The name specified must be relative to console agent's scripts directory. For example: If you have ConsoleAgentInstall/scripts/MyBusApp/jyhton1.py then the name is MyBusApp/jyhton1.py.
consoleConfiguration - - An instance of the IConsoleConfiguration
Returns:
Returns true or false. True means that the task was successfully executed. False means that there was an error. There is a chance that the Ant result may contain an error message. For example, the wsadmin command returns success even though the Ant output indicates an error. In this situation, you have to check the Ant result.

launchAntTask

public boolean launchAntTask(java.lang.String filename,
                             java.lang.String targetName,
                             java.util.Properties properties,
                             Resource resource,
                             javax.portlet.PortletRequest request,
                             IConsoleConfiguration consoleConfiguration,
                             boolean encodeResourceProperties)
This methods allows you to run an Ant task. The Ant file must be located relative to the console agent's scripts directory on the remote computer. Currently, there is a limitation in the SSL verification process. The APIs are unable to reuse the current keystore used by Express Runtime. This is a known issue. The console can use a SSL connection to communicate with the agent. For now, SSL certificates will be accepted automatically for the user. The user still might be prompted through the Express Runtime authentication page.

Specified by:
launchAntTask in interface IExecuteTask
Parameters:
filename - - The name of the Ant file to run. The name specified must be relative to console agent's scripts directory. For example: If the file location is ConsoleAgentInstall/scripts/MyBusApp/ant1.xml then the name is MyBusApp/znt1.xml.
targetName - - The name of the target within the Ant file to run.
properties - - A Properties object representing any properties to pass on to the Ant script. This can be null if there are no properties to pass on.
resource - - An instance of Resource.
request - - An instance of PortletRequest.
consoleConfiguration - - An instance of the IConsoleConfiguration
encodeResourceProperties - - A boolean indicating that you want to add the Express Runtime Ant properties for the given resource. This is useful in case your Ant scripts are referencing the existing Express Runtime Ant scripts.
Returns:
Returns true or false. True means that the task was successfully executed. False means that there was an error. There is a chance that the Ant result may contain an error message. For example, the wsadmin command returns success even though the Ant output indicates an error. In this situation, you have to check the Ant result.

addDirectoryToSend

public void addDirectoryToSend(java.io.File directory,
                               java.lang.String directoryToPerverse)
This method allows you to specify a directory to send to the console agent.

Specified by:
addDirectoryToSend in interface IExecuteTask
Parameters:
directory - - A File that represents the directory to send. It send everything in the directory.
directoryToPerverse - - This would be the directory in which you would like to preserve the path data. For example: You would specify "MyBusApp" if you specifed the directory c:\temp\MyBusApp and wanted to retain "MyBusApp" in path on the console agent machine.

addFileToSend

public void addFileToSend(java.io.File file,
                          java.lang.String directoryToPerverse)
This method allows you to specify an individual file to send to the console agent.

Specified by:
addFileToSend in interface IExecuteTask
Parameters:
directory - - A File that represents the file to send.
directoryToPerverse - - This would be the directory in which you would like to preserve the path data. For example: You would specify "MyBusApp" if you specifed the file c:\temp\MyBusApp\ant1.xml and wanted to retain "MyBusApp" in path on the console agent machine.

sendFilesToAgent

public boolean sendFilesToAgent(Resource resource,
                                javax.portlet.PortletRequest request,
                                IConsoleConfiguration consoleConfiguration)
This method allows you to send files to the console agent. This would be used when your task does not execute due to a IExecuteTask.isThereAFileNotFoundError(). The files should be located somewhere on the console machine. To specify which files to use, see IExecuteTask.addDirectoryToSend(File, String) or IExecuteTask.addFileToSend(File, String). The files are copied over into the console agent's scripts folder.

Specified by:
sendFilesToAgent in interface IExecuteTask
Parameters:
resource - - An instance of Resource.
request - - An instance of PortletRequest.
consoleConfiguration - - An instance of the IConsoleConfiguration
Returns:
Returns true or false. True means that the task was successfully completed. False means that there was an error.

isThereAuthenticationError

public boolean isThereAuthenticationError()
This method indicates if the was an authentication error during a task execution. An authentication error could mean there is a problem with the credentials used or with certificate between the console and the console agent.

Specified by:
isThereAuthenticationError in interface IExecuteTask
Returns:
True or false.

isThereAFileNotFoundError

public boolean isThereAFileNotFoundError()
This method indicates if there was a file not found error when executing a task in which an ANT or a Jython file was specified.

Specified by:
isThereAFileNotFoundError in interface IExecuteTask
Returns:
True or false.