Web authoring application sample details
You use Decision Center to run this sample.
Running this sample
Paul user that is provided
by default belongs to an administrative group, which has access to
all projects and all rights to view/create/update/delete project artifacts.
In this sample, the rmtuser user belongs to a group
with permissions that are described in data/rmtUserGroup.properties:-
Create action rules and decision tables.
-
Update the
definitionproperty for action rules and decision tables that are created by users in the group. -
Update any other elements.
-
View any elements.
-
Delete action rules and decision tables if created by users in the group.
-
Delete all other elements.
Decision Center provides a locking mechanism for rule elements to prevent concurrent editing. You cannot edit an element if it is locked. Elements are locked when you edit them, and unlocked afterward, when you close the elements with or without changes.
- Viewing project security settings.
- Using the web application that gives access to Decision Center data.
- Checking security access and fine-grained permissions fro a group of users to the Loan Validation Service project.
-
Open a web browser and enter the following URL to access Decision Center:
http://localhost:<PORT>/decisioncenter/
-
Sign in to Decision Center by using the following details:
User name: Paul
Password: Paul
-
Click the Administration menu, and open the Project Security tab.
-
Inspect Loan Validation Service. Notice that security is enforced on all the rule projects, and that
rmtUserGrouphas security access. -
Sign out of Decision Center.
-
Open your web browser and enter the following URL:
http://localhost:<PORT>/dcclient
-
Sign in by using the following details:
User name: rmtuser
Password: rmtuser
The selected project is Loan Validation Scoring, which is part of the Loan Validation Service decision service.
-
Click the Choose your Action Rule drop-down list and select an action rule in the Loan Validation Scoring project.
- Click the Decision Table tab, and then choose a decision table in the Choose your Decision Table drop-down list to see the decision table.
-
Return to the Rule tab, and select neverBankruptcy in the drop-down list.
Notice that the Save Rule and Remove Rule buttons are enabled but clicking them produces a permission error. This is because you signed in as
rmtuserand can update only the rules that were created by your group,rmtUserGroup. -
Return to the Decision Table tab, and select bankruptcyScore in the drop-down list.
The decision table is displayed. Notice that all the decision table buttons are enabled, but you get a permission error when you click Save Table or Remove Table. This error occurs because the decision table was not created by your group.
-
Return to the Rule tab.
-
Click Create Rule and create a new action rule called NewRule in the computation package.
Notice that the Remove Rule and Save Rule buttons now work.
-
Click the Logout button.
Open a web browser and enter the following URL:
http://localhost:<PORT>/dcclient
The port number can be 9090. It might differ on your computer.
Sign in by using Paul as the username and password.
Select the rule neverBankruptcy.
Notice that the Save Rule and Remove Rule buttons now work. By signing in as Paul, you can update any rule.
Rebuilding this sample
- Open the Samples Console (see Running samples from the Samples Console).
In the Samples Commands tab, expand .
Double-click build to compile the code.
To restore the initial security settings for the Loan Validation Service project, run the run.remove.permission Ant command.
How this sample works
How to set and unset the permissions on a project.
How to use the Decision Center web components.
How to lock and unlock objects.
The main of the class PermissionHelper (located in <InstallDir>/teamserver/samples/servercomponents/src/com/ibm/rules/web/sample/utils) unsets the permission if there is an argument, and sets them otherwise. To set the permissions, see the setPermissionsForRole() function.
addGroup(session, userGroup): Adds the user and group to the Decision Center database.
enForceSecurity(session, project, userGroup): Enforces security and specifies that your new group can access all the rule projects in Loan Validation Service.
loadSorted(resourceName): Reads the properties file and builds a map of permissions. The property file is data/rmtUserGroup.properties.
setPermissionsForRole(session, usergroup, propertiesMap): Sets the permissions map to the user.
To unset the permissions, see the function disableSecurity(session, project). It calls the Decision Center API to disable the security for a project.
- AppServlet: This servlet manages the load of projects from Decision Center, selects the current project to use, and top-level project content (the lists of packages, decision tables, and action rules for the project). The commands for this servlet can be found in src/com/ibm/rules/web/sample/servlet/command/app.
- DecisionTableEditorServlet: This servlet manages the commands for decision tables, for example, create, save, and remove. The commands are in src/com/ibm/rules/web/sample/servlet/command/dt.
- RuleEditorServlet: This servlet manages commands for action rules, for example, load, create, save, and remove. The commands are in src/com/ibm/rules/web/sample/servlet/command/rule.
The editing components are used in sample.jsp. The sample uses drop-down menus for selecting projects, rules, and decision tables. The page is dynamic, and its content is based on Dojo.
- isElementBusy(session, element): Checks whether the element can be edited.
- lockElement(session, element): Locks the element.
- unlockElement(session, element): Unlocks the element.
Source files
This sample is located in <InstallDir>/teamserver/samples/servercomponents/src/com/ibm/rules/web/sample.
-
login()
This method creates a new Decision Center session with the provided parameters.
-
logout()
This method signs you out of the Decision Center session.
A helper class provides functions to create action rules or decision tables in Decision Center, and to check the permissions: utils/RTSHelper.java.
Commands to manage projects, decision tables, and action rules are dispatched to different places based on what is managed:
- src/com/ibm/rules/web/sample/servlet/command/app
- src/com/ibm/rules/web/sample/servlet/command/dt
- src/com/ibm/rules/web/sample/command/rule/
-
utils/PermissionHelper.java
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.