Your CentraSite installation contains two sample custom action rules. One rule is a Java rule, and the other is a Groovy script rule.
The content is organized under the following sections:
Your CentraSite installation contains a sample Java action rule (which is contained in uniquenamechecker.zip) that you can use to create a custom action that ensures that the name and version combination of a newly-created asset is unique within the CentraSite catalog. If it is not unique, the action returns Failure, and the asset is not allowed to be created.
To create the custom action, you will use the CentraSite user interface to:
Create a custom action category
Create a custom action template, to which you upload the sample Java rule
Create a Design/Change-Time policy and add the custom action template to it
Create and test the custom action as follows.
To create and test the custom action Enforce Unique Asset Names
In CentraSite Control, go to
> .Click the
button.In the
dialog box, do the following:Specify a name for the new custom category, for example My
Custom Actions
. An action category name can contain any character
(including spaces).
Choose Design/Change-Time as the action category type.
Click
.The action category that you created appears as a custom category next to an icon in the Policy Information panel.
Click
.On the Add Action Template page, specify the following fields:
In this field... | Do the following... |
---|---|
Category |
Select the custom action category you just created. |
Name |
Enter the name |
Description |
Optional. Type a description for the new action
template. For example: |
Implementation |
Select Java. |
Uploaded File |
Click the button and upload the following rule file:<CentraSite_Install_Dir>\demos\Custom actions\Java\uniquenamechecker.zip This .zip file that contains the following:
For more information about creating and uploading actions rules, see Creating Action Rules. |
In the Scope panel, specify the following fields:
In this field... | Do the following... |
---|---|
Object Types |
Select Service as the type of object to which this action template applies. |
Event Types |
Select PreCreate as the type of event to which this action template applies. |
Click
.The Edit Action Template Detail page is displayed.
Create a policy and add the sample action to the policy as follows:
In CentraSite Control, go to
.Click
.In the Policy Information panel, enter a name
for the new policy, for example, Ensure Unique Asset Names Policy
.
A policy name can contain any character (including spaces).
In the Scope panel, specify the object and event types to which the policy applies as follows:
In the Object Types field, select Service as the type of object to which this policy applies.
In the Event Types field, select PreCreate as the type of event to which this policy applies.
In the Organization field, select your organization name as the organization to which this policy belongs (and to whose objects the policy will be applied).
Click
.From the Available Actions list, choose the custom action Enforce Unique Asset Names action that you created.
Click
to save the new policy. The Design/Change-Time Policy Details page is displayed.Activate the policy by choosing the Productive state.
button and choosing theYour CentraSite installation contains a sample Groovy action rule (ServiceAttributeChecker.groovy) that you can use to create a custom action that checks for a particular value of a service attribute.
To create and test the custom action, you will use the CentraSite user interface to:
Create a custom action category
Create a custom action template, to which you upload the sample Groovy script rule
Create a Design/Change-Time policy and add the custom action template to it
Test the custom action "on demand" (manually) on the policy's detail page
Create and test the custom action as follows.
To create and test the custom action Service Attribute Checker
In CentraSite Control, go to
> .Click the
button.In the
dialog box, do the following:Specify a name for the new custom category, for example My
Custom Actions
. An action category name can contain any character
(including spaces).
Choose Design/Change-Time as the action category type.
Click
.The action category that you created appears as a custom category next to an icon in the Policy Information panel.
Click
.On the Add Action Template page, specify the following fields:
In this field... | Do the following... |
---|---|
Category |
Select the custom action category you just created. |
Name |
Enter the name |
Description |
Optional. Type a description for the new action
template. For example: |
Implementation |
Select Groovy. |
Uploaded File |
Click the button and upload the following rule file:<CentraSite_Install_Dir>\demos\Custom actions\Groovy\ServiceAttributeChecker.groovy |
In the Scope panel, specify the following fields and click :
In this field... | Do the following... |
---|---|
Object Types |
Select Service as the type of object to which this action template applies. |
Event Types |
Select OnTrigger as the type of event to which this action template applies. This will enable you to test the action "on demand" (manually) in the Actions profile of the Design/Change Time Policy Detail page. |
In the Edit Action Template Detail page, select the Parameter Templates profile in order to add the action's parameter templates and click the Add Parameter Template button.
Set the first parameter template for the action as follows:
In this field... | Do the following... |
---|---|
Name |
Enter |
Type |
Choose the data type Attribute for this parameter template. |
Default Value |
Leave blank. |
Array |
Leave blank. |
Required |
Select this check box. |
Click the Add Parameter Template button again to set the second parameter template as follows:
In this field... | Do the following... |
---|---|
Name |
Enter |
Type |
Select the data type String for this parameter template. |
Default Value |
Enter an attribute value that you want to check. |
Array |
Leave blank. |
Required |
Select this check box. |
Click
and then .The parameter template that you added appears in the Parameter Templates profile.
Create a policy and add the sample action to the policy as follows:
In CentraSite Control, go to
.Click
.In the Policy Information panel, enter a name
for the new policy, for example, Service Attribute Checker Policy
.
A policy name can contain any character (including spaces).
In the Scope panel, specify the object and event types to which the policy applies as follows:
In the Object Types field, select Service as the type of object to which this policy applies.
In the Event Types field, select OnTrigger as the type of event to which this policy applies.
In the Organization field, select your organization name as the organization to which this policy belongs (and to whose objects the policy will be applied).
Click
.From the Available Actions list, choose the custom action Service Attribute Checker action that you created.
Click
to save the new (as yet incomplete) policy. The Design/Change-Time Policy Details page is displayed.To configure the two parameters for the action, choose the action name on the Actions profile. For the Attribute Name parameter, choose an attribute. For the Possible Attribute Value parameter, select the default value that you defined for the Possible Attribute Value parameter in the action template.
Click
and then . The policy detail page is displayed.Activate the policy by choosing the Productive state.
button and choosing theSelect the Actions profile.
To test the action, click the Possible Attribute Value
. All
other services will also be displayed, with Failure in the Result column.
After you have completed testing, you can use this custom action in other Design/Change-Time policies. To do this, go to its Scope panel, change the event type from OnTrigger to PreCreate or PreUpdate, and include the action in other Design/Change-Time policies whose event type scope is either PreCreate or PreUpdate.