CentraSite Documentation : CentraSite Developer’s Guide : Developing Custom Actions : Sample Custom Actions : Sample Java Action: Enforce Unique Asset Names
Sample Java Action: Enforce Unique Asset Names
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:
1. Create a custom action category
2. Create a custom action template, to which you upload the sample Java rule
3. Create a Design/Change-Time policy and add the custom action template to it
To create and test the custom action Enforce Unique Asset Names
1. In CentraSite Control, go to Policies > Action Templates.
2. Click the Add Action Category button.
3. In the Add Action Category dialog box, do the following:
a. Specify a name for the new custom category, for example My Custom Actions. An action category name can contain any character (including spaces).
b. Choose Design/Change-Time as the action category type.
c. Click OK.
The action category that you created appears as a custom category next to an icon in the Policy Information panel.
4. Click Add Action Template.
5. 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 Enforce Unique Asset Names for the new action template.
Description
Optional. Type a description for the new action template. For example: Ensures that asset names are unique.
Implementation
Select Java.
Uploaded File
Click the Browse button and upload the following rule file:
<CentraSite_Install_Dir>\demos\Custom actions\Java\uniquenamechecker.zip
This .zip file that contains the following:
*A folder named lib, which contains a jar file with the action’s executor class and the external libraries.
*A folder named META-INF, which contains a property file named assertion.properties, which is the build file for the action.
For more information about creating and uploading action rules, see Creating Action Rules.
6. 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.
7. Click Save.
The Edit Action Template Detail page is displayed.
8. Create a policy and add the sample action to the policy as follows:
a. In CentraSite Control, go to Policies > Design/Change Time.
b. Click Add Policy.
c. 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).
d. 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).
e. Click Next.
f. From the Available Actions list, choose the custom action Enforce Unique Asset Names action that you created.
g. Click Finish to save the new policy. The Design/Change-Time Policy Details page is displayed.
h. Activate the policy by choosing the Change State button and choosing the Productive state.
Copyright © Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback