This article describes how the Design time Policy Management be managed from the CentraSite Business UI.
Design Time Policy Management provides governance controls that you can use to effectively administer and manage web services and other assets. Most of the time we would like to write our own rules or policies that will help our enterprise-specific needs in the form of say custom policy actions.
We will see how a custom policy action be created and use it in a Design Time policy.
Use Case Scenario:
At the "Ready to Consume" state of a service , a user or an application may request for approval of consumer registration. Once the request is approved the registration process is completed we will set "Terms of Service" and change the state to "Consumed".
In addition,the registration system sends information about the number of consumers to a specific user using a custom action.
Now comes an additional requirement , where the registration system should include the asset owner in the email notification. Typically we are not allowed to modify any changes to the implementation of the custom action template that is used in at least one policy .
But we can include this new change in our implementation without removing the policy action from the policy.
a. Create Organization with users configured with email ids.
(i) Organization Name- EDF Energy
b. User Details (listed below as userid - role name)
(i) orgadminuser - Organization Administrator
(ii) policyadmin - Policy Administrator
(iii) assetconsumer - Asset Consumer
(iv) assetprovider - Asset Provider
(v) approver1 - Approver
c. As the orgadminuser of EDF Energy, create a Lifecycle Model (LCM) for Service type with Name: EDF Service Consumption Lifecycle
(listed below are the Lifecycle states and their transition states)
(i) Initial -> Ready to Consume -> Consumed -> Deprecated -> Retired
(ii) Consumed -> Initial
(iii) Initial -> Deprecated
(iv) Initial -> Retired
Below is the screen shot of the LCM in BUI
Step1 : Add custom actions and templates
1. Prepare the Java implementation zip file (or) use a command "CentraSiteCommand.cmd setup Custom Actions" to setup an eclipse project and implement the custom action. ( Refer the CentraSite User's Guide , Policy Management -> Setting Up an Eclipse Java Project for Action Implementation)
a. Create a directory name "ConsumerlListImpl"
b. Execute the command as shown below
c. This will create the eclipse project shown below
d. You can implement the Java file
PLEASE NOTE : Custom action category & action templates should be created or updated as a user having CentraSite Administrator role.
e. Once the implementation is ready, run the build.xml, to generate the implementation as an archive file, which should inturn be used as a parameter for the CentraSiteCommand.
2. We can either add a custom template in the existing Design/Change Time Category or use a custom category. In our case we will use custom category
3. Let's list the existing categories using the command "list Action Categories", to get the category ID
4. Use the Category Name and ID in the custom template's XML file as shown below
5. Execute the command to add the custom action template
CentraSiteCommand.cmd add Action Template -user Administrator -password manage -implementationzip C:\CustomlistImpl.zip -file C:\MailNotificationTemplate.xml
Step2 : Add a Design Time Policy
1. As a Policy Administrator, login to BUI, and click on the new Design Time activity.
2. Now click on the Add Design Time Policy action
Screenshot showing the Design Time screen : Applicable Scope will also show LifeCycleModel which will be listed upon selection.
Step3 : Filling in the Policy Details
We have the details of the policies defined under profiles, replacing the tabs from Control UI:
- Basic Information
- Policy Actions
1. Basic Information Details
Fill in the policy name, description , organization , version and priority
2. Defining Scopes:
Selection of the Applicable Object Types , Event Types and Filtering options are done in this profile.
Screenshot shows how multiple applicable types can also be selected in Scope Profile where the Applicable Types are Service & REST Service & Event Type is OnConsumerRegistration
3. States (if applicable)
If we select the Event Type : Pre-State Change (or) Post-State Change we should select the applicable state(s) .
In our example this can be skipped as we are not using the mentioned Event Types
Below is a screenshot that shows how states can be selected
4. Policy Actions selection and setting parameter values
a. Click on Policy Actions Profile and select the policy actions
- Validate State - for state "Ready to Consume"
- Initiate Approval - select approver group containing the userid approver1
- Register Consumer
- Set Attribute Value - for attribute "Terms Of Service" in Specification profile, provide a valid and proper URL
- Set State - to "Consumed" state
b. Also add the custom action
From the policy actions , select the ConsumerListMailNotification under the ConsumptionCategory & fill in the relevant values.
5. Save and activate
a. Click on the Save action, which enables the Activate action.
b. Activate action enables the Deactivate action and disables the editable text fields
c. OnTrigger : If the onTrigger option is selected for a policy , post-activation, we should be able to see the Run Now action as shown below
Step3 : Execute the use case (Case1)
1. Login as the Asset Provider - assetprovider
ensure that the Service asset is in "Ready to Consume" lifecycle state by performing a state change.
2. Login to BUI as Asset Consumer - assetconsumer
Consume an application asset or as a user or group
3. Login as Approver user - approver1
Approve the registration request.
Check the consumer count being increased
Check the value for "Terms of Service" in Specification Profile.
Verify that the Asset's state now changes to "Consumed"
4. In the meanwhile we can also verify that the mail notification to the user is being sent
Attached screenshot of the email generated
Step4 : Modifying the implementation (Case2)
In our usecase, we want to include a slight change to of having an additional option to send e-mail notification to the asset owner also.
But typically when an implementation is undergoing certain changes, CentraSite does not allow the edit of a policy action template. We have to deactivate a current policy and then remove the action from the Policy.
Right now we will deactivate the policy and execute the "update Action Template" command.
CentraSiteCommand.cmd | sh update Action Template -user Administrator -password manage -id <customTemplateID> -implementationzip <updateImplemenation.zip> -forceedit true
**** The parameter option "forceedit" is essential in this use case - this allows to forcibly modify the implementation details of the action template that is used in one or more policies ****
To get the action template ID, you can also execute the command which will either show only the templates from a specific category
CentraSiteCommand.cmd | .sh list Action Templates -user Administrator -password manage -actioncategory ConsumptionCategory
To list all the templates
CentraSiteCommand.cmd | .sh list Action Templates -user Administrator -password manage
Step5 : Execute the use case (Case2)
Perform the same steps as mentioned in Step3 for a different service asset.
This time emails are sent to the asset's owner and also the user given in the Policy parameter.
Attached screenshot of the email sent to the chosen user (policyadminuser) and asset owner (assetprovider)
- "update Action Template" does not allow the changes for a custom template file. Only Implementation changes are allowed.
- We have to restart the Tomcat to get the updated implementation working.
- In BUI, auto-approval does not work for non-CSA user. As the approver , you must still go to the Pending Approvals and perform the approval.
From the Users Guide https://documentation.softwareag.com/webmethods/centrasite/inm10-3/10-3_Centrasite_Users_Guide.pdf
- For the LCM creation in BUI, refer Section 8 > Topic Managing Lifecycle Models through CentraSite Business UI
- Working with Policy actions from Command Line , refer Section 10 > Managing Design-Time and Change-Time Policies through Command Line Interface
- For other features related to Design Time Policy in BUI, refer Section 10 > Managing Design and Change-Time Policies through CentraSite Business UI
- Archive contains both the first and updated implementation archives.Extract the zip first and use it for the Case1 and Case2 accordingly.
- First implementation archive file (PolicyActionImplementation.zip\PolicyActionImplementation\FirstImplementation\ConsumerListImpl\ConsumerListImpl.zip)
- Updated implementation archive file - (PolicyActionImplementation.zip\PolicyActionImplementation\UpdatedImplementation\ConsumerListImpl\ConsumerListImpl.zip)
- Custom Policy Template XML - click here
- Email template format that is given in the policy parameter - click here