Permission management sample details

You can run and rebuild this sample, and you can also look at source files to understand how this sample works. The sample uses the Decision Center Business console, but a similar scenario works with the Enterprise console.

Running this sample

To run this sample:

  1. In the sample console under Samples Commands > Decision Center > Permission management, run the set-config-param command. This command changes the controller property in Decision Center to the class of the customized session controller: permissiontuning.WorkflowSessionController.

  2. Open a web browser and enter the following URL to access Decision Center: http://localhost:<PORT>/decisioncenter/.

  3. Sign in to Decision Center by using Bea as the user name and password.

  4. In the Library tab.

  5. Click Loan Validation Service, and select main from the Branches page.

  6. Expand the Loan Validation Determination folder, and edit a rule with a status of New, for example, eligibility > checkCreditScore.

  7. In the rule editor, click Details and change the status of the rule to Defined, and then click Save and create a new version.

  8. Edit the rule again. You can no longer select New for the Status property.

  9. Change the status of the rule to Deployable, and then save and create a new version. Notice that the edit icon is now disabled because the customized session controller prevents rules with a status of Deployable from being edited by normal users.

  10. Sign out and then sign in again as the Administrator by using Paul as the user name and password.

  11. On the Library page, choose Loan Validation Service in the main branch.

  12. Locate the rule that you edited and notice that you can edit the deployable rule, because you are now signed in as the Administrator.

Rebuilding this sample

To rebuild this sample:

  1. In the Samples Commands view, navigate to Samples Commands > Decision Center > Permission management.

  2. Run the build command to compile the code.

How this sample works

This sample defines the WorkflowSessionController class, which inherits functions from the default session controller IlrDefaultSessionController and overrides two methods:

  • public List getPossibleValues(IlrElementHandle element, org.eclipse.emf.ecore.EStructuralFeature feature)

    You call this method whenever you display a list of possible values for a property. The method checks the status property of a BusinessRule object and returns the list of next possible values for the status.

  • public void checkUpdate(IlrElementHandle element, IlrElementDetails details, org.eclipse.emf.ecore.EStructuralFeature feature)

    You call this method to determine whether a property is deactivated in the GUI and to check current permissions before you commit a change.

    The method also tests for the rule artifact status. If the status is Deployable and the user is not part of the Administrator role group, an IlrPermissionException is thrown to prevent any changes to the rule object.

    The IlrSession.isUserInRole() method tests whether the user belongs to the Administrator group.

The WorkflowEditSessionController also inherits from the IlrDefaultSessionController class and overrides two methods:

  • For the getPossibleValues() method, it has the same implementation as the one in WorkflowSessionController class. It provides the possible values for a property. The differences are in the PERMISSION value definition array lists.

    In WorkflowSessionController, when the status is deployable, the possible value contains only { "deployable"}. In WorkflowEditSessionController, there are two possible values: { "deployable", "defined" }.

  • public boolean isEditable(IlrElementHandle element, String property)

    This method checks whether the property of the specified rule artifact is editable based on the user group and status. If the status is deployable and the user is a normal user, only the status field is editable.

Source files

This sample is in <InstallDir>/teamserver/samples/permissiontuning/src/permissiontuning.

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.