This sample shows how to plug a custom session controller in Rule Team Server, in order to tune permission management. The session controller defines the behavior of Rule Team Server when committing or deleting an element, computing the possible values for a feature, and so on.
In this sample, we define a custom session controller to change the following behaviors:
-
filter the list of possible values the user can choose from in the status field pop-up
-
forbid the editing of a rule artifact depending on its status
Key Features
The Session controller is the key feature of this sample.
Installing this Sample
To install this sample:
-
In the Samples Console locate the
teamserver > permissiontuning sample.
-
Check that the Samples Server is started. For information on how to start and stop the Samples Server, see Stopping and Restarting the Samples Server from the Samples Console.
-
Execute the
repack command to package the compiled code inside the Rule Team Server EAR.
-
Execute the
deploy command to deploy the new EAR.
-
Wait for the Java EE application to start before continuing. (The server trace displays the message:
[EARDeployer] Started J2EE application.)
-
Execute the
set-config-param command. This command changes the controller property in Rule Team Server to the class of the customized session controller: permissiontuning.WorkflowSessionController.
Running this Sample
This sample can only be opened and run in the Samples Console.
To open and run the sample:
-
Open a web browser and enter the following URL to access Rule Team Server:
http://localhost:8080/teamserver/.
-
Sign in to Rule Team Server using the following details:
-
Click the Home tab and set loanvalidation-rules as the current project.
-
Click the Explore tab.
-
Edit a rule with a status of New (for example: eligibility > checkCreditScore).
-
Change the status of the rule to Defined, and then click Finish.
-
Edit the rule again. Note that you can no longer select New for the Status property.
-
Change the status of the rule to Deployable, and then click Finish.
Notice that
Edit in the toolbar is deactivated. This is because the customized session controller prevents rules with a status of
Deployable from being edited by normal users.
If you click the
Explore tab and try to edit the rule from the Rules list, an error message is displayed explaining why you cannot edit the rule.
-
Sign out, and then sign in again as the administrator:
-
In the Home tab, make sure loanvalidation-rules is the current project.
-
Locate the rule you just edited and notice that since you are now signed in as the administrator, you can edit the deployable rule.
Source Files
This sample is located in <InstallDir>/teamserver/samples/permissiontuning.
WorkflowSessionController.java - The customized session controller.
Highlights
The WorkflowSessionController we define inherits from the default session controller IlrDefaultSessionController and overrides two methods:
-
public List getPossibleValues(IlrElementHandle element, org.eclipse.emf.ecore.EStructuralFeature feature)
It is called whenever a list of possible values for a property is to be displayed.
In this method, we test that we are dealing with the status feature of a
BusinessRule object. If so, we compute the list of next possible values for the status, and return it.
-
public void checkUpdate(IlrElementHandle element, IlrElementDetails details, org.eclipse.emf.ecore.EStructuralFeature feature)
It is called to determine whether a property should be deactivated (grayed out) in the GUI and to check current permissions before committing a change.
In this method, we test for
BusinessRule objects whose status is
Deployable. If it is, we throw an
IlrPermissionException to prevent any changes to the object.
Note that we also use the
IlrSession.isUserInRole() method to test whether the user belongs to the Administrator group. If they do, we do not raise the exception, and it is still possible to modify the rule.
Rebuilding this Sample
To rebuild this sample, execute the build command to compile the code.
Related Tasks