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 class action rule named "uniquenamechecker", you can use to create a custom action, "Unique Name Checker". This action to ensures that the name and version combination of a newly-created asset is unique within the CentraSite catalog.
Note:  
If the name and version combination of a newly-created asset is not unique, then the action returns a "Failure" message, and does not create the new asset in CentraSite registry.
For information about creating your own custom Java class action rule, see Creating Action Rules.
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 Java class action rule:
<CentraSite_Install_Dir>\demos\CustomActions\Java\uniquenamechecker.zip
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 Pre-Create 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 Pre-Create 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 © 2005-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback