Version 9.6
 —  Developing Custom Actions  —

Adding Custom Actions Using APIs

To create a custom action programmatically, you perform the following high-level steps:

  1. Create a custom action category and template.
    To do this, you create a Java class that uses the com.centrasite.jaxr.CentraSiteLifeCycleManager interface. To view the Javadoc for this interface, see Javadoc: metamodelAPI.

  2. Create a Java class action rule or a Groovy script action rule.
    See Creating Action Rules.

  3. Upload the action rule to the action template.
    See Uploading Action Rules to Action Templates.


Creating Action Rules

Start of instruction setIf creating a rule in a Java class:

  1. Create a Java action executor class that implements the com.softwareag.centrasite.policy.api.IActionExecutor interface. To view the Javadoc for this interface, see Javadoc: policyAPI.

    Important:
    The Java executor class must return an AssertionResult object that contains the completion code ResultStatus.SUCCESS (if the action was successful) or ResultStatus.FAILURE (if the action failed). There are other possible completion codes (for example, ResultStatus.IN_PROCESS), however, these codes are used by internal processes and are not intended to be returned by user-defined actions. Custom actions that you create must only return a completion code of ResultStatus.SUCCESS or ResultStatus.FAILURE. For more information, see the Javadoc for the AssertionResult and ResultStatus classes.

  2. Create a .zip file that contains the following:

  3. Upload the .zip file, as described in Uploading Action Rules to Action Templates.

For example, the sample Java action rule provided in the your CentraSite installation has the following file structure:

For more information about the sample Java action, see Sample Custom Actions.

Start of instruction setIf using a Groovy script rule:

Top of page

Uploading Action Rules to Action Templates

Before you upload a Java action rule, you must first create a .zip file as described in Creating Action Rules.

If you want to upload a Groovy script rule, the .groovy file can contain the following variables. You cannot upload external libraries.

Variable Description
entity

This represents the RegistryObject which is in the context.

The following fields are available in this object:

  • Name

  • Description

  • State

policyContext

The PolicyContext in which the policy is running.

assertion

The IAssertionInstance that is in execution.

result

The result object that has the status and message.

Set the result.successMessage or result.failureMessage.

Based on the message, the status is inferred. If you fail to set a message, the status will be treated as a successful execution with an empty message.

Start of instruction setTo upload an action rule

  1. There are two ways you can upload a rule’s .zip file or .groovy file to a custom action template:

    1. If you are uploading the rule to a custom action template you created using the CentraSite UI, you upload the rule (either a Java .zip file or a .groovy file) when you create the action template, on the Add Action Template page. For procedures, see Adding an Action Template to the Action Category.

      —OR—

    2. If you are uploading the rule to a custom action template that you created programmatically, you upload the rule (either a Java .zip file or a .groovy file) using a JAXR-based call in the action template.

Top of page