You can run and rebuild this sample, and you can also look at source files to understand how this sample works.
Before running this sample, note that:
autUser is an author user, whose job is to write rules
revUser is a reviewer user, whose job is to review defined rules written by autUser
tesUser is a tester user, whose job is to test reviewed rules
depUser is a deployer user, whose job is to deploy rules
admUser is an administrator user, whose job is to administrate the project
You run this sample using the following steps:
Step 1: View project security settings
Step 2: Manage a rule lifecycle
Step 3: Control query actions
Step 4: View rule status changes using RSS
First, you look at the current security settings for the user roles. This example uses the author role.
To view the current project security settings:
Step 1: View project security settings
Open a web browser and enter the following URL to access Decision Center: http://localhost:<PORT>/teamserver.
Sign in to Decision Center using the following details:
Username: rtsAdmin
Password: rtsAdmin
On the Home page, select loanvalidation-rules as the Project in use.
Click the Configure tab.
Click Edit Branch Security.
Notice how Enforce and configure security for this branch is selected, and a number of groups are associated with this main branch of the project.
Click Cancel to return to the Configure tab.
In the Configure tab, click Edit Permissions.
Select author from the drop-down list and view the security settings for that role.
Sign out of Decision Center.
Next, you investigate how each user role processes rules at each stage of the rule lifecycle. You sign in as an author, a reviewer, a tester, a deployer, and an administrator.
To sign in as an author:
Step 2: Manage a rule lifecycle
Connect to Decision Center using the following URL: http://localhost:<PORT>/teamserver
Sign in to Decision Center using the following details:
Username: autUser
Password: autUser
On the Home page, select loanvalidation-rules as the Project in use.
Click the Explore tab.
Notice that the author role has access only to the New Rules and Refused Rules smart folders.
Hover your mouse over New Rules smart folder and click the Details icon to access the Details page. Then click Edit or Delete.
Notice that you cannot update or delete smart folders.
Click the Explore tab.
In the table, select the approval rule and click Edit.
In the Properties step, click the Status list box.
Decision Center displays two values. These are the only transitions available for an author when a rule has a status of new.
Select Defined.
Type a comment in Status Comment.
Click Next.
Notice that you can edit the contents of the rule.
Click Finish. The rule now has a status of Defined.
Click Edit, and then click the Properties step.
Notice that the rule is now read-only.
Sign out of Decision Center.
To sign in as a reviewer with defined status:
Connect to Decision Center using the following URL: http://localhost:<PORT>/teamserver/
Sign in to Decision Center using the following details:
Username: revUser
Password: revUser
On the Home page, select loanvalidation-rules as the Project in use.
Click the Explore tab.
Notice that the reviewer role has access to the Defined Rules, Deployed Rules, Deprecated Rules, and Inactive Rules smart folders.
Select the approval rule and click Edit.
In the Properties step, click the Status list box.
Decision Center displays three values. These are the only transitions available for a reviewer when a rule has a status of Defined.
Select Reviewed.
Type a comment in Status Comment.
Click Next.
Notice that you cannot edit the contents of the rule.
Click the Documentation step.
You can enter data in this field because the reviewer role can update the documentation property when the status of the rule is Defined, Deprecated, or Inactive.
Click Finish. The rule now has a status of Reviewed.
Click the Edit button, and then click the Properties step.
Notice that the rule properties are now read-only.
Click the Documentation step.
Notice that the documentation property is now read only.
Click Cancel.
On the Explore tab you notice that the approval rule is no longer displayed and Defined Rules is empty.
Sign out of Decision Center.
To sign in as a tester:
Connect to Decision Center using the following URL: http://localhost:<PORT>/teamserver/
Sign in to Decision Center using the following details:
Username: tesUser
Password: tesUser
On the Home page, select loanvalidation-rules as the Project in use.
Click the Explore tab.
Notice that a tester can see only Reviewed Rules.
Select the approval rule and click Edit.
In the Properties step, click the Status list box.
Decision Center displays three values. These are the only transitions available for a tester when a rule has a status of Reviewed.
Select Tested.
Enter a comment in Status Comment.
Click Next.
Notice that you cannot edit the contents of the rule.
Click Finish. The rule now has a status of Tested.
Click the Edit button, and then click the Properties step.
Notice that the rule properties are now read-only.
Click Cancel.
In the Explore tab, notice that the approval rule is no longer displayed and Reviewed Rules is empty.
Sign out of Decision Center.
To sign in as a deployer:
Connect to Decision Center using the following URL: http://localhost:<PORT>/teamserver/
Sign in to Decision Center using the following details:
Username: depUser
Password: depUser
On the Home page, select loanvalidation-rules as the Project in use.
Click the Explore tab.
Notice that as a deployer, you can see only Tested Rules.
Select the approval rule and click Edit.
In the Properties step, click the Status list box.
Decision Center displays three values. These are the only transitions available for a deployer when a rule has a status of Tested.
Select Deployed.
Type a comment in Status Comment.
Click Next.
Notice that you cannot edit the contents of the rule.
Click Finish. The rule now has a status of Deployed.
Click the Edit button, and then click the Properties step.
Notice that the rule properties are now read-only.
Click Cancel.
In the Explore tab, notice that the approval rule is no longer displayed and Tested Rules is empty.
Sign out of Decision Center.
To sign in as a reviewer with deployed rule status:
Connect to Decision Center using the following URL: http://localhost:<PORT>/teamserver/
Sign in to Decision Center using the following details:
Username: revUser
Password: revUser
On the Home page, select loanvalidation-rules as the Project in use.
Click the Explore tab.
Click Deployed Rules.
Select the approval rule, and then click Delete.
Decision Center displays a message stating that you cannot delete the item because of its status, because reviewers can only delete rules that have a status of Deprecated or Inactive. To demonstrate this, change the status to Inactive and then try to delete the item again.
Click Back.
Select the approval rule and click Edit.
In the Properties step, set the Status to Inactive.
Click Finish.
Click Explore to return to the main page of the Explore tab.
Click the Inactive Rules smart folder.
Select the approval rule.
Click Delete, but do not confirm the deletion to keep the project clean.
You notice that you can now delete this rule because it has a status of Inactive.
Sign out of Decision Center.
By going through each role, you have completed the rule approval lifecycle.
This sample also uses a special role: the administrator.
To sign in as the administrator:
Connect to Decision Center using the following URL: http://localhost:<PORT>/teamserver/
Sign in to Decision Center using the following details:
Username: admUser
Password: admUser
On the Home page, select loanvalidation-rules as the Project in use.
Click the Explore tab.
Notice that an administrator can see all rule statuses: Defined, Deployed, Deprecated, Inactive, New, Refused, Reviewed, and Tested.
Click Inactive Rules. The approval rule is available.
Sign out of Decision Center.
Then, you look at the controls that restrict the actions that an author role can perform.
To control query actions:
Step 3: Control query actions
Connect to Decision Center using the following URL: http://localhost:<PORT>/teamserver/.
Sign in using the following details:
Username: autUser
Password: autUser
On the Home page, select loanvalidation-rules as the Project in use.
Click the Query tab.
Click New.
Create the following query:
Find all business rules
[such that]
Do
set the status of each business rule to validated
Click Run Query.
On the table displayed, select the approval rule.
Click Apply Actions.
Decision Center displays the message Cannot apply actions : You cannot update this element, because as an author you cannot set the status to validated.
Sign out of Decision Center.
The sample generates RSS data whenever the status value changes, and makes it available from the web server. A URL pointing to the updated rule is attached to the RSS data so that the user can edit the rule directly.
Step 4: View rule status changes using RSS
To display the RSS data, open your browser and enter the following URL:
http://localhost:<PORT>/teamserver/RSSRawProvider.jsp?project=loanvalidation-rules
The URL is built partially with information from the serverrulegovernance/data/server.properties file.
You can use any RSS reader to subscribe to the RSS feeds. To view loanvalidation-rules, configure it to point to http://localhost:<PORT>/teamserver/RSSRawProvider.jsp?project=loanvalidation-rules.
To rebuild this sample, you compile the sample and modify the configuration file. You can also customize the sample.
To compile this sample, execute the build command in the samples console.
Modify the configuration file
Using a text editor, open the file <INSTALL_DIR>/teamserver/samples/serverrulegovernance/data/configuration.properties.
The configuration syntax is fully explained in the configuration file.
Update and save the file.
If you have modified roles, status, or user configurations:
In the samples console, execute the run.printprofiles command to print the application server roles configuration.
Use the WebSphere® Application Server administration console to define the groups and users shown by the run.printprofiles command.
Restart the server to apply the changes.
In the samples console, execute the run command to redeploy and reconfigure Decision Center.
Customize the sample
Modify the configuration file, as described earlier in this section.
To add a role:
Locate the following line: roles = administrator;author;reviewer;deployer;tester
Add the role newrole, as follows: roles = administrator;author;reviewer;deployer;tester;newrole
In the samples console, execute the run.generatepermission command to generate default permission templates for all defined roles.
Copy <INSTALL_DIR>/teamserver/samples/serverrulegovernance/newpermissions/newrole.permissions to:
<INSTALL_DIR>/teamserver/samples/serverrulegovernance/data/permission/role.
Remove the <INSTALL_DIR>/teamserver/samples/serverrulegovernance/newpermissions directory.
Modify the newrole.permission file, as required.
To add a user newUser with 1 role (newrole):
Locate the line user.XXXXX=YYYYY.
Add the user newUser as follows: user.newUser=newrole.
To add a new status newstatus to the rules:
Locate the line status.property.BusinessRule.status.values = new;defined ...
Add the new status newstatus as follows:
* status.property.BusinessRule.status.values = newstatus;new;defined...
To give a new role named newrole permissions to delete:
Add the following line to grant permission to delete an item to any status value: BusinessRule.delete.newrole = *
Add the following line to restrict the permission to delete an item to a status value of inactive or newstatus: BusinessRule.delete.reviewer = inactive;newstatus
To define the status for which a property can be updated for a new role named newrole:
Add the following line to allow updates to any property, regardless of its status: BusinessRule.update.*.newrole = *
Add the following line allow any updates to any property when its status is new: BusinessRule.update.*.newrole = new
Add the following line to allow updates to a specific property when its status is newstatus: BusinessRule.update.XXXXX.newrole = newstatus
To define the initial status of a rule as newstatus, change the line transition.BusinessRule.status.initial...' to: transition.BusinessRule.status.initial = newstatus
To define the status transition for a given role (newrole), add the following line for each allowed transaction. Here, the newrole role is authorized to change the status from new to new, defined, or newstatus: transition.BusinessRule.status.newrole.new = new;defined;newstatus
In this sample, you manage the rule lifecycle of the loanvalidation-rules project. The data used for controlling the lifecycle is read from the <INSTALL_DIR>/teamserver/samples/serverrulegovernance/data/configuration.properties file.
To customize Decision Center and deploy it to the application server:
Install the custom controller
Execute the ant targets set-extensions and upload-messages of the build.xml.
The set-extensions target modifies the Decision Center model. The status and statuscomment properties of the model manage the lifecycle of the rule. See extensionModel.brmx and extensionModel.brdx in <INSTALL_DIR>/teamserver/samples/serverrulegovernance/data/model/
The upload-messages target adds a label to these properties which are displayed in the UI when editing the status or the statuscomment. See the file:
<INSTALL_DIR>/teamserver/samples/serverrulegovernance/data/message/serverrulegovernance_en_US.properties
To deploy, execute the deploy command of the build.xml.
To configure the target project by executing the run.install command of build.xml:
Configure the target project (loanvalidation-rules)
Connect to Decision Center.
Create a group for each possible status value (newGroup, reviewedGroup, THE_STATUS_VALUEGroup) defined in the configuration file.
Create a smart folder for each possible status value.
Syntax: Find all business rules such that the status of each business rule is THE_STATUS_VALUE.
Group: THE_STATUS_VALUEGroup.
Create a group for each role defined in the configuration file.
Set the security for the target project to ON.
Assign all created groups to the target project.
Install permission reads from data/permission/ROLE_NAME.permissions.
Sign out of Decision Center.
When you start using Decision Center, the CustomController class is loaded and it reads the configuration file. The controller is now ready to manage the rule lifecycle, processed as follows:
Connect to Decision Center
When you edit a rule, for each rule property, Decision Center calls IlrSessionController.checkUpdate(IlrElementHandle handle, IlrElementDetails details, EStructuralFeature feature). The property is read only when this method throws an IlrPermissionException, otherwise it is editable. You use getPossibleValues(IlrElementHandle element, org.eclipse.emf.ecore.EStructuralFeature feature) to return the list of possible values for the status.
When you persist a modification after editing a rule:
Decision Center calls IlrSessionController.checkUpdate(IlrElementHandle handle, IlrElementDetails details, EStructuralFeature feature). For each property, the method verifies whether the property can be updated. This authorization depends on the user role and on the current status of the rule.
Decision Center calls IlrSessionController.onCommitElement(IlrCommitableObject cobject). This method prepares a modification event. If you had entered a comment, the comment is appended to the comment history of the rule.
The IlrSessionController.elementCommitted(IlrCommitableObject cobject,IlrElementHandle newHandle) method records the modification event when you modify the status of a rule. Otherwise, the method releases the event. The default implementation of a modification event consumer is an RSS feeder (NotificationListenerDefaultImpl class). This class translates a modification event into RSS entries.
When you try to delete a rule, Decision Center calls IlrSessionController.checkDelete(IlrElementHandle element). The controller verifies that the delete operation is authorized. The authorization depends on the user role and on the current status of the rule. If the user is not authorized to delete, an IlrPermissionException is thrown.
An RSS Reader requests the RSS raw data for a project, that is, the list of rules with a changed status.
The RSSRawProvider.jsp receives the request.
The JSP calls NotificationListenerDefaultImpl.getRSSStream(the project).
The getRSSStream (..) method returns all modification events recorded on the day as RSS raw data.
This sample is located in: <InstallDir>/teamserver/samples/serverrulegovernance/src/rulegovernance.
You can also view and modify the sample source files in Rule Designer. To import the sample into your workspace, click the Import projects link in the Samples and Tutorials view, and switch to the Java™ perspective.