Saturday, August 9, 2014

Enabling Exemption to Life-cycle Policies in WSO2 Governance Registry

2:01 AM Posted by Vishmi Money , , No comments

This feature is developed to enable the exemption of users, from requiring certain privileges to perform certain life-cycle operations during a given period, based on some exemption policy.

Design and Implementation:

G-reg contains artifacts which can be resources or collections, for which we can assign a specified life-cycle. Life-cycle configuration is a xml file called configuration.xml and we can define the lifecycle elements and attributes there.
Exemption Policy is achieved by introducing new element timeValidation to lifecycle configuration, and a child element timeValidity and the attributes of it. They are startDate and endDate. You can check it in the configurations.xml file which has uploded here.
Then the functionality is achieved from 3 java classes and a jsp file.
DefaultLifeCycle.java - org.wso2.carbon.governance.registry.extensions.aspects.DefaultLifeCycle.java
TimeWindowBean.java - org.wso2.carbon.governance.registry.extensions.beans.TimeWindowBean.java
Utils.java - org.wso2.carbon.governance.registry.extensions.aspects.utils.Utils.java
lifecycles_ajaxprocessor.jsp - org.wso2.carbon.governance.custom.lifecycles.checklist.ui.lifecycles_ajaxprocessor.jsp


  • xml data is taken from getTimeData method implemented in DefaultLifeCycle.java.
  • that data is put in to a Hash map timeValidation which consists of a state and it's time attributes.
  • That Hash map is sent to a method called checkTimeValidity in which the logic is developed according to the time-policy. By comparing currentTime along with the policy, a notification is sent to the user and a boolean value timeValidity is generated.
  • TimeWindowBean is the bean which holds the isTimeValid attribute which is again a boolean value.
  • Generated boolean value from checkTimeValidity is set for isTimeValid attribute in TimeWindowBean.
  • getTimeValidity mehtod in Utils.java and the TimeWIndowBean is sent to that.There the boolean value isTimeValid is maintained and it is sent tolifecycles_ajaxprocessor.jsp.
  • According to the boolean value the UI elements will be enabled and disabled from the jsp.

Functionality:

Scenario 1: If a date which is far ahead of current date is entered, all things will act in normal way.UI element functionality are there. 


Scenario 2: If a date which is within the defined notifying period is entered, it will send a notification to the user. UI element functionality are there. 


Scenario 3: If a date which is passed is entered, it will not only send a notification but also disable the UI elements so that the user cannot take an action. User is exempted. 


Further information on setting up the feature and running can be found in my git hub repository.