Decision Center API

ilog.rules.teamserver.model
Interface IlrSessionController

All Superinterfaces:
IlrSessionCallback
All Known Implementing Classes:
IlrDefaultSessionController

public interface IlrSessionController
extends IlrSessionCallback

IlrSessionController is the base interface for all classes that define security settings and interactive behavior for Decision Center.

Overview

To keep the default behavior for customized session controller, subclass IlrDefaultSessionController, then enhance only the features you want to change, each method in your customized session controller class must call its super method first.

Code examples

This section contains two code examples. The first example shows how to customize Decision Center security; the second shows how to trace user activity to a log file.

Note: The custom classes implement IlrDefaultSessionController, and not IlrSessionController directly. This makes sure that the default behavior of Decision Center in all other domains is retained.

You register these classes with Decision Center by adding the following line to the preferences.properties file:

teamserver.controller.class=ilog.rules.rts.samples.permissiontuning.WorkflowSessionController

Customizing Decision Center Security

The following code example shows a custom session controller implementation that will be used by Decision Center to check if the current user has the rights to update an element:

  public class WorkflowSessionController extends IlrDefaultSessionController {

     // Constants for role definition
     public static final String ADMINISTRATOR_ROLE = "rtsAdministrator";

     // This method is called in the GUI to find out whether or not a property should be grayed and,
     // before committing a change, to check the permissions.
     public void checkUpdate(IlrElementHandle element, IlrElementDetails details, org.eclipse.emf.ecore.EStructuralFeature feature)
       throws IlrPermissionException, IlrObjectNotFoundException {

       IlrSession session = element.getSession();
       IlrElementDetails elementDetails = session.getElementDetails(element);
       // If we are checking a Business Rule...
       if (elementDetails!=null && elementDetails.isInstanceOf("BusinessRule")) {
         // Get the status of the rule
         String status = (String)elementDetails.getPropertyValue("status");
         // If the status is 'deployable', forbid any change
         if (status.equals("deployable") &&! session.isUserInRole(ADMINISTRATOR_ROLE))
           throw new IlrPermissionException("Unable to change a deployable rule");
       }
    }
  }
 

Logging Decision Center User Activity

The following code example shows a custom session controller implementation that will be used by Decision Center to log actions by the current user:

 public class LogController extends IlrDefaultSessionController {

   private BufferedWriter outfile = null;

   public LogController() throws  IOException{
      Date myDate = new Date();
        String outputFile = "RTSLog" + myDate.getTime();
        outfile = new BufferedWriter(new FileWriter(outputFile, true));
   }

   public void elementDeleted(IlrElementHandle handle)
          throws IlrObjectNotFoundException {
      // Always call the super method
      super.elementDeleted(handle);
      try{
        log((IlrModelElement) handle, "DELETE");
      } catch(IOException e){;}
   }

   public void elementCommitted(IlrCommitableObject cobject,
          IlrElementHandle newHandle) throws IlrObjectNotFoundException {
      // Always call the super method
      super.elementCommitted(cobject, newHandle);
      Object detail = session.getElementDetails(newHandle);
      if (!(detail instanceof IlrModelElement))
          return;
      try {
        log( (IlrModelElement) detail, "COMMITTED");
      }catch(IOException e){;}
   }

   public void log(IlrModelElement element, String action) throws IOException
   {
        String logComment = action + " " + element.getName();
      logComment += " uuid " + element.getUuid();
      logComment += " changed on " + element.getLastChangedOn();
      logComment += " by " + element.getLastChangedBy();
      logComment += " committed by " + session.getUserName();
      outfile.write( logComment);
      outfile.flush();
   }
 }
 


Field Summary
 
Fields inherited from interface ilog.rules.teamserver.model.IlrSessionCallback
CHANGE_ACTIVITY_CONTROLLER_CALLBACK, CONTROLLER_CALLBACK, ISUSERINROLE_CALLBACK, RELEASE_CONTROLLER_CALLBACK, VALIDATION_ACTIVITY_CONTROLLER_CALLBACK
 
Method Summary
 void checkCreate(org.eclipse.emf.ecore.EClass eclass)
          Checks whether the current user has the right to create elements of the given class.
 void checkDelete(IlrElementHandle element)
          Checks whether the current user has the right to delete the given element.
 void checkUpdate(IlrElementHandle element, IlrElementDetails details, org.eclipse.emf.ecore.EStructuralFeature feature)
          Checks whether the current user has the right to update the given element.
 void elementAddedToBaseline(IlrElementHandle element, IlrBaseline baseline)
          Implements a custom session controller that changes the way in which Decision Center reacts to an action.
 void elementCommitted(IlrCommitableObject cobject, IlrElementHandle newHandle)
          This method is called just after an element has been committed.
 void elementDeleted(IlrBaseline baseline)
          This method is called just after a baseline has been deleted.
 void elementDeleted(IlrElementHandle element)
          This method is called just after an element has been deleted.
 void elementDeleted(IlrProjectInfo prjInfo)
          This method is called just after a project info has been deleted.
 void elementRemovedFromBaseline(IlrElementHandle element, IlrBaseline baseline)
          Implements a custom session controller that changes the way in which Decision Center reacts to an action.
 Object getInitialValue(IlrElementDetails element, org.eclipse.emf.ecore.EStructuralFeature feature)
          Gets the initial value for the given feature.
 IlrBusinessVersion getNextVersion(boolean isNew, boolean isNewInBranch, IlrBusinessVersion previousVersion)
          Called By RTS when creating or updating an element to get the new version details.
 List getPossibleValues(IlrElementHandle element, org.eclipse.emf.ecore.EStructuralFeature feature)
          Gets the possible values for the given feature.
 boolean isEditable(IlrElementHandle element, String feature)
          Tests whether the given feature for a specific element is editable.
 boolean isHidden(IlrElementHandle element, String feature)
          Tests whether the given feature for a specific element must be hidden.
 boolean isServerVisible(IlrServer server, IlrRuleApp ruleApp)
          Called when the list of servers to deploy on is displayed.
 boolean isServerVisible(IlrServer server, IlrScenarioSuite suite)
          This method is called when the list of servers that can be set on the test suite is displayed.
 String isValid(IlrElementHandle element, String feature, Object value)
          Tests whether the given value for a specific feature and element is valid.
 void onAddElementToBaseline(IlrElementHandle element, IlrBaseline baseline)
          Implements a custom session controller that changes the way in which Decision Center reacts to an action.
 void onCheckRulesetArchive(ilog.rules.archive.IlrRulesetArchive rulesetArchive, IlrBaseline baseline, IlrSearchCriteria ruleArtifactquery, ilog.rules.commonbrm.extractor.IlrExtractorValidator extractorValidator, List generationErrors)
          Called when a generated ruleset archive is being checked.
 void onCommitElement(IlrCommitableObject cobject)
          This method is called when entering the IlrSession.commit method, just before effectively committing an element.
 void onDeleteElement(IlrElementHandle element)
          This method is called when entering the IlrSession.delete method, just before deleting an element.
 void onGenerateRulesetArchive(ilog.rules.engine.IlrRulesetArchiveBuilder rulesetArchiveBuilder, IlrBaseline baseline, IlrSearchCriteria ruleArtifactquery, ilog.rules.commonbrm.extractor.IlrExtractorValidator extractorValidator)
          Called at the end of the generation of a ruleset archive.
 void onRemoveElementFromBaseline(IlrElementHandle element, IlrBaseline baseline)
          Implements a custom session controller that changes the way in which Decision Center reacts to an action.
 IlrSearchCriteria redefineSearch(IlrSearchCriteria searchCriteria)
          Called each time a search is performed using search criteria.
 void securityProfileCommitted(String role, IlrSecurityProfileData profile)
          Called when new permissions for a given role have been committed.
 void securityProfileDeleted(String role)
          Called when permissions for a given role have been deleted.
 
Methods inherited from interface ilog.rules.teamserver.model.IlrSessionCallback
setSession
 

Method Detail

checkDelete

void checkDelete(IlrElementHandle element)
                 throws IlrPermissionException,
                        IlrObjectNotFoundException
Checks whether the current user has the right to delete the given element.

This method is called by the IlrSession.deleteElement(IlrElementHandle) method, just before element is finally deleted. For Decision Center GUI front ends, this method might also be called in order to check if the "Delete" button is grayed out for element.

Throws:
IlrPermissionException - if the current user does not have the right to delete element.
IlrObjectNotFoundException - if element is not found in the Decision Center database.
Parameters:
element - The handle of the element to be deleted.
See Also:
Overview

checkCreate

void checkCreate(org.eclipse.emf.ecore.EClass eclass)
                 throws IlrPermissionException,
                        IlrObjectNotFoundException
Checks whether the current user has the right to create elements of the given class.

For Decision Center GUI front ends, this method is called in order to check if a "New" button can be grayed out, or to compute the list of available types.

Throws:
IlrPermissionException - if the current user does not have the right to create eclass.
IlrObjectNotFoundException - If element cannot be found in the Decision Center database.
Parameters:
eclass - The element class.
See Also:
Overview

checkUpdate

void checkUpdate(IlrElementHandle element,
                 IlrElementDetails details,
                 org.eclipse.emf.ecore.EStructuralFeature feature)
                 throws IlrPermissionException,
                        IlrObjectNotFoundException
Checks whether the current user has the right to update the given element.

Decision Center calls this method in several places. It is called by the Decision Center GUI front end to check if:

It is also called at the beginning of the commit method to check if the details of an edited object can be committed.

Throws:
IlrPermissionException - if the current user does not have the rights to change element.
IlrObjectNotFoundException - if feature is not found in the Decision Center database.
Parameters:
element - The element handle. This parameter may be set to null.
details - The object that will be committed if this method does not throw any exceptions. This parameter may be set to null.
feature - The feature to modify. If set to null, you should consider whether the entire object can be modified in your custom session controller.
See Also:
Overview

getPossibleValues

List getPossibleValues(IlrElementHandle element,
                       org.eclipse.emf.ecore.EStructuralFeature feature)
                       throws IlrObjectNotFoundException
Gets the possible values for the given feature.

Optionally, the element for which the framework wants the possible values can be given. This allows implementors to dynamically compute the possible values according to the current state of the element.

Throws:
IlrObjectNotFoundException - if feature is not found in the Decision Center database.
Parameters:
element - The element handle. This parameter may be set to null.
feature - The feature whose possible values you want to retrieve. This must be an attribute whose type is enumerated (EEnum).
Returns:
A list of the possible values. This method cannot return null. Set your custom implementation to return List.EMPTY_LIST if there are no possible values to return.
See Also:
Overview

getInitialValue

Object getInitialValue(IlrElementDetails element,
                       org.eclipse.emf.ecore.EStructuralFeature feature)
                       throws IlrObjectNotFoundException
Gets the initial value for the given feature.

Throws:
IlrObjectNotFoundException - if feature is not found in the Decision Center database.
Parameters:
element - The element handle. This parameter may be set to null.
feature - The feature whose initial value is to be returned.
Returns:
The initial value for the object. May return null.
See Also:
Overview

elementCommitted

void elementCommitted(IlrCommitableObject cobject,
                      IlrElementHandle newHandle)
                      throws IlrApplicationException
This method is called just after an element has been committed.

Implements a custom session controller to change the way in which Decision Center reacts to this action.

Throws:
IlrObjectNotFoundException - if object is not found in the database.
IlrApplicationException
Parameters:
cobject - The committed object.
newHandle -
See Also:
IlrSession.commit(IlrCommitableObject), Overview

elementDeleted

void elementDeleted(IlrElementHandle element)
                    throws IlrObjectNotFoundException
This method is called just after an element has been deleted.

Implements a custom session controller to change the way in which Decision Center reacts to this action.

Throws:
IlrObjectNotFoundException - if element is not found in the database.
Parameters:
element - The deleted object.
See Also:
IlrSession.deleteElement(IlrElementHandle), Overview

elementDeleted

void elementDeleted(IlrBaseline baseline)
                    throws IlrObjectNotFoundException
This method is called just after a baseline has been deleted.

Implements a custom session controller to change the way in which Decision Center reacts to this action.

Throws:
IlrObjectNotFoundException - if baseline is not found in the database.
Parameters:
baseline - The deleted baseline.
See Also:
IlrSession.deleteElement(IlrElementHandle), Overview

elementDeleted

void elementDeleted(IlrProjectInfo prjInfo)
                    throws IlrObjectNotFoundException
This method is called just after a project info has been deleted.

Implements a custom session controller to change the way in which Decision Center reacts to this action.

Throws:
IlrObjectNotFoundException - if prjInfo is not found in the database.
Parameters:
prjInfo - The deleted project info.
See Also:
IlrSession.deleteElement(IlrElementHandle), Overview

elementAddedToBaseline

void elementAddedToBaseline(IlrElementHandle element,
                            IlrBaseline baseline)
                            throws IlrApplicationException
Implements a custom session controller that changes the way in which Decision Center reacts to an action. This method is called just after an element has been added to a baseline.

Throws:
IlrApplicationException - if element cannot be added to baseline.
Parameters:
element - The element to add.
baseline - The baseline to update.
See Also:
IlrBaselineManagementFacility.addToBaseline(IlrElementHandle, IlrBaseline), Overview

elementRemovedFromBaseline

void elementRemovedFromBaseline(IlrElementHandle element,
                                IlrBaseline baseline)
                                throws IlrApplicationException
Implements a custom session controller that changes the way in which Decision Center reacts to an action. This method is called just after an element has been removed from a baseline.

Throws:
IlrApplicationException - if element cannot be removed from baseline.
Parameters:
element - The element that has been removed.
baseline - The baseline to update.
See Also:
IlrBaselineManagementFacility.addToBaseline(IlrElementHandle, IlrBaseline), Overview

onCommitElement

void onCommitElement(IlrCommitableObject cobject)
                     throws IlrApplicationException
This method is called when entering the IlrSession.commit method, just before effectively committing an element.

Implements a custom session controller to change the way in which Decision Center reacts to this action.

Throws:
IlrObjectNotFoundException - if cobject is not found in the database.
IlrPermissionException - if the current user does not have the rights to commit cobject.
IlrInvalidElementException - if cobject is invalid. For example, if the name of a project element is null.
IlrActivityObjectLockedException
IlrApplicationException - if an operation throws one.
Parameters:
cobject - The object to be committed.
See Also:
IlrSession.commit(IlrCommitableObject), Overview

onDeleteElement

void onDeleteElement(IlrElementHandle element)
                     throws IlrApplicationException
This method is called when entering the IlrSession.delete method, just before deleting an element.

Implements a custom session controller to change the way in which Decision Center reacts to this action.

Throws:
IlrApplicationException
Parameters:
element - The object to be deleted.
See Also:
IlrSession.deleteElement(IlrElementHandle), Overview

onAddElementToBaseline

void onAddElementToBaseline(IlrElementHandle element,
                            IlrBaseline baseline)
                            throws IlrApplicationException
Implements a custom session controller that changes the way in which Decision Center reacts to an action. This method is called on entering the IlrSession.addToBaseline method, just before the element is added to a baseline.

Throws:
IlrApplicationException - if element cannot be added to baseline.
Parameters:
element - The element to be added.
baseline - The baseline to be updated.
See Also:
IlrBaselineManagementFacility.addToBaseline(IlrElementHandle, IlrBaseline), Overview

onRemoveElementFromBaseline

void onRemoveElementFromBaseline(IlrElementHandle element,
                                 IlrBaseline baseline)
                                 throws IlrApplicationException
Implements a custom session controller that changes the way in which Decision Center reacts to an action. This method is called on entering the IlrSession.removeFromBaseline method, just before the element is removed from a baseline.

Throws:
IlrApplicationException - if element cannot be removed from baseline.
Parameters:
element - The element to be removed.
baseline - The baseline to be updated.
See Also:
IlrBaselineManagementFacility.addToBaseline(IlrElementHandle, IlrBaseline), Overview

isHidden

boolean isHidden(IlrElementHandle element,
                 String feature)
                 throws IlrObjectNotFoundException
Tests whether the given feature for a specific element must be hidden.

This method is used in the UI to test if the current user has the rights to see the feature.

Throws:
IlrObjectNotFoundException - If element is not found in the database.
Parameters:
element - The element handle.
feature - The feature to test.
Returns:
True if feature is hidden.
See Also:
Overview

isEditable

boolean isEditable(IlrElementHandle element,
                   String feature)
                   throws IlrObjectNotFoundException
Tests whether the given feature for a specific element is editable.

This method is used in the UI to check if feature may be edited by the current user.

Throws:
IlrObjectNotFoundException - If an object is not found in the database.
Parameters:
element - The element handle.
feature - The feature to test.
Returns:
True if feature is editable.
See Also:
Overview

isValid

String isValid(IlrElementHandle element,
               String feature,
               Object value)
               throws IlrObjectNotFoundException
Tests whether the given value for a specific feature and element is valid.

This method is used in the UI to check if value can be entered by the current user.

Throws:
IlrObjectNotFoundException - If an object is not found in the database.
Parameters:
element - The element handle.
feature - The feature to test.
Returns:
An error message when the value is not valid, null otherwise.
See Also:
Overview

onGenerateRulesetArchive

void onGenerateRulesetArchive(ilog.rules.engine.IlrRulesetArchiveBuilder rulesetArchiveBuilder,
                              IlrBaseline baseline,
                              IlrSearchCriteria ruleArtifactquery,
                              ilog.rules.commonbrm.extractor.IlrExtractorValidator extractorValidator)
Called at the end of the generation of a ruleset archive.

Implement this method in your custom session controller to manipulate the content of an archive using the IlrRulesetArchiveBuilder class. This method is called just before the archive is generated. See IlrRulesetArchiveBuilderBase.generate() for more information.

Parameters:
rulesetArchiveBuilder - The ruleset archive builder, ready to generate a ruleset archive. It contains the execution artifacts resulting from the extraction of the ruleset being generated.
baseline - The baseline from which the execution artifacts were extracted.
ruleArtifactquery - The query used to get the rule artifacts to be extracted. This parameter can be set to null.
extractorValidator - The extractor validator used to filter out the artifacts to be extracted.
See Also:
IlrDeploymentFacility.generateRulesetArchive(IlrSearchCriteria, String, String), Overview

onCheckRulesetArchive

void onCheckRulesetArchive(ilog.rules.archive.IlrRulesetArchive rulesetArchive,
                           IlrBaseline baseline,
                           IlrSearchCriteria ruleArtifactquery,
                           ilog.rules.commonbrm.extractor.IlrExtractorValidator extractorValidator,
                           List generationErrors)
Called when a generated ruleset archive is being checked.

Implements a custom session controller to change the way in which Decision Center reacts to this action. For example, perform a custom check on rulesetArchive and add errors to generationErrors.

Parameters:
rulesetArchive - The ruleset archive that has been generated.
baseline - The baseline from which the execution artifacts were extracted.
ruleArtifactquery - The query used to get the rule artifacts to be extracted. This parameter can be set to null.
extractorValidator - The extractor validator used to filter out the artifacts to be extracted.
generationErrors - A list of IlrElementError objects.
See Also:
IlrElementError, IlrDeploymentFacility.generateRulesetArchive(IlrSearchCriteria, String, String), Overview

redefineSearch

IlrSearchCriteria redefineSearch(IlrSearchCriteria searchCriteria)
Called each time a search is performed using search criteria.

A typical use is to modify the search according to the role of the user. For example, you could redefine a search such that the current user can only view the rules with the status 'new'. In this case, you will return a new search criterion that will add (status, 'new') to the list of features and values of the input search criteria.

Note: Do not modify and return searchCriteria. You must do one of the following:

Parameters:
searchCriteria - The search criteria passed when one of the IlrSession.findElements methods is called.
Returns:
Either a new IlrSearchCriteria instance with overridden criteria, or searchCriteria.

isServerVisible

boolean isServerVisible(IlrServer server,
                        IlrRuleApp ruleApp)
Called when the list of servers to deploy on is displayed.

Implements a custom session controller to filter the displayed servers.

Parameters:
server - The server to manage.
ruleApp - The RuleApp to deploy.
Returns:
True if the server must be displayed, false otherwise.

isServerVisible

boolean isServerVisible(IlrServer server,
                        IlrScenarioSuite suite)
This method is called when the list of servers that can be set on the test suite is displayed.

Implements a custom session controller to filter the displayed servers.

Parameters:
server - The server to manage.
suite - The test suite.
Returns:
True if the server must be displayed, false otherwise.

securityProfileCommitted

void securityProfileCommitted(String role,
                              IlrSecurityProfileData profile)
Called when new permissions for a given role have been committed.

Parameters:
role - The role on which the permissions have changed.
profile - The permissions that have been committed.

securityProfileDeleted

void securityProfileDeleted(String role)
Called when permissions for a given role have been deleted.

Parameters:
role - The role on which the permissions have been deleted.

getNextVersion

IlrBusinessVersion getNextVersion(boolean isNew,
                                  boolean isNewInBranch,
                                  IlrBusinessVersion previousVersion)
Called By RTS when creating or updating an element to get the new version details.

Parameters:
isNew - true if this is a new element to create
isNewInBranch - true if the element is updated for the first time in working branch
previousVersion - latest element version in working branch hierarchy, null if this is a new element
Returns:
the version to set for the element update.

Decision Center API

© Copyright IBM Corp. 1987, 2013