Sample Custom Actions
CentraSite includes the following sample custom actions:
Change Owner Action
Runtime Policy Action
The sample custom actions are available in the demos folder in the <CentraSiteInstall_Directory>.
Change Owner Action
The Change Owner Action does not have any UI associated with it. This action is applicable for both single and multiple objects. When the action is selected, the ownership of the selected objects are automatically transferred to the current logged in user provided the logged in user has the CentraSite Administrator role.
Runtime Policy Action
The Runtime Policy Action has a UI associated with it. This action is applicable only for a single object. When the action is selected in the Asset Details page, CentraSite displays a list of policies that are applicable for the selected asset, and the user can select a policy for the execution. When the user selects the policy, the policy is executed, and the results of the execution are displayed to the user.
To create a custom action in CentraSite Business UI, the following classes or interfaces are required:
Interface CSOAction
If you are writing a custom action, you must create a class implementing the
CSOAction interface. The fully qualified name of this class must be mentioned in the element
<Action> in the
centrasite.xml file.
The
ChangeOwnerAction.java contains the implementation for the
Change Owner action.
You can find the ChangeOwnerAction.java file in the folder changeowner in the <CentraSiteInstall_Directory>\demos\CentraSiteBUIExtension\BusinessUIActions\WithoutUI\src\com\softwareag\centrasite\demos\bui\actions directory.
The
RunPolicyAction.java is the implementation class for the
Execute Policy action.
You can find the RunPolicyAction.java file in the folder runpolicy in the <CentraSiteInstall_Directory>\demos\CentraSiteBUIExtension\BusinessUIActions\WithoutUI\src\com\softwareag\centrasite\demos\bui\actions directory.
Class ActionInfo
CentraSite Business UI makes use of GWT (Google Web Toolkit) to for the UI. To transmit data between the client and server side applications in GWT, the object must be serializable. The
ActionInfo is a serializable class that holds the data from the class
CSOAction such as the action ID, current action state, and so on. It also holds additional data, such as the selected assets on which the action has to be performed and any other inputs that are provided by the user. If your custom action does not require any user input other than the selected assets, then you can make use of the
ActionInfo class, otherwise you have to create your own class inheriting the
ActionInfo class.
The
Change Owner action does not need any other information. Therefore the
ActionInfo implementation class itself is used for it.
The
Execute Policy action has additional information that has to be presented to the user and to be set in the
CSOAction implementation class. Therefore, it uses the class
RunPolicyActionInfo.java that is inheriting the
ActionInfo class.
Interface IActionConverter
This handles the conversion of the data from class
CSOAction to class
ActionInfo and vice versa. There must be a class implementing this interface. If your action does not require any new data other than the selected objects for executing the action, then we provide a default converter class, called as
DefaultActionConverter. On the other hand, you require additional inputs from the user, then they must be handled separately. In this case, you must create your own
IActionConverter class and specify the same in the
ActionConverterFactory.getActionConverter() method so that this converter is used for your action.
The
Change Owner action uses the class
DefaultActionConverter as it does not have any new data to be converted.
The
Execute Policy action uses the class
RunPolicyActionConverter.java to handle the conversion of the additional data.
Interface IActionHandler
This handles the UI for the action. If your action does not have a UI, then we provide a default handler class, called as
DefaultActionHandler. If your action requires a UI, then you have to implement the
IActionHandler interface and handle the UI using this class based on the action states. The action handler for your action must be specified in the
ActionHandlerFactory.getActionHandler() method.
The
Change Owner action does not have any UI associated with it, and uses the class
DefaultActionHandler.
The
Execute Policy action has a UI, and uses the class
RunPolicyActionHandler.java.
Once the above classes are ready and available to use, you would compile them, and then deploy the extensions. You will include your custom action in the centrasite.xml file as follows.
<Action id="{CustomActionName}" inbox="{true|false}" bulk="{true|false}"
group="{group_name}" icon='{URL/relative_path}'
class="fully.qualified.class.name">{Custom_Action_Name}</Action>
The input parameters are:
Parameter | Description |
id="{CustomActionName} | Name of the custom action. The name should be unique as it would be referenced throughout the action execution. |
inbox="{true|false}" | Enable or disable the visibility of the action in the Actions bar of the Inbox. |
bulk="{true|false}" | Enable or disable the visibility of the action in the Search Results page. If the value of this parameter is set to false, then the visibility of the action is restricted to the Asset Details page. |
group="{group_name}" | A grouping for your action. This will help to group the actions according to the group name. By default, you can provide "basic" as the grouping. |
icon='{URL/relative_path}' | The URL of the icon that is to be used to represent this action in the Actions bar in CentraSite Business UI. You can specify the URL for the icon, or if the icon is located on your file system specify the file location relative to the <CentraSiteInstall_Directory>\cast\cswebapps\BusinessUI directory. |
class="fully.qualified.class.name" | The fully qualified class name of the implementation class CSOAction. |
{Custom_Action_Name} | Display name of the action in the Actions bar in CentraSite Business UI. |