Web authoring application sample details

You use Decision Center to run this sample.

Running this sample

Before you run this sample, note that Decision Center manages different user groups. The 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 definition property 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.

In the following procedures, you learn these tasks:
  • 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.
To view the security settings of Loan Validation Service:
  1. Open a web browser and enter the following URL to access Decision Center:

    http://localhost:<PORT>/decisioncenter/

  2. Sign in to Decision Center by using the following details:

    User name: Paul

    Password: Paul

  3. Click the Administration menu, and open the Project Security tab.

  4. Inspect Loan Validation Service. Notice that security is enforced on all the rule projects, and that rmtUserGroup has security access.

  5. Sign out of Decision Center.

To use the web authoring application that is connected to Decision Center:
  1. Open your web browser and enter the following URL:

    http://localhost:<PORT>/dcclient

  2. 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.

  3. Click the Choose your Action Rule drop-down list and select an action rule in the Loan Validation Scoring project.

  4. 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.
  5. 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 rmtuser and can update only the rules that were created by your group, rmtUserGroup.

  6. 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.

  7. Return to the Rule tab.

  8. 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.

  9. Click the Logout button.

To check the permission of the projects in the Loan Validation Service decision service:
  1. 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.

  2. Sign in by using Paul as the username and password.

  3. 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

To rebuild this sample:
  1. Open the Samples Console (see Running samples from the Samples Console).
  2. In the Samples Commands tab, expand Samples Commands > Decision Center > Web authoring application.

  3. Double-click build to compile the code.

Note:

To restore the initial security settings for the Loan Validation Service project, run the run.remove.permission Ant command.

How this sample works

In this sample you learn:
  • 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.

The following APIs come with this sample:
  • 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.

The editing component is managed by three servlets declared in the WEB-INF/web.xml description file:
  • 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.

To lock or unlock objects, use the class RTSHelper in <InstalDir>teamserver/samples/servercomponents/src/com/ibm/rules/web/sample/utils. It provides functions that call the Decision Center API before and after editing:
  • 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.

The connection to the Decision Center data is allowed by utils/ConnectionBean.java. It is used in servercomponents/webapp/header.jsp, and uses the following methods for logging in and out:
  • 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/
The installer package modifies the Loan Validation Service project security with Ant tasks. They are not used by the web application. This class manages the permissions:
  • 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.