You can run and rebuild this sample, and you can also look at source files to understand how this sample works.
To trigger notification for modifications:
In the Samples Commands view, navigate to
.To open the Samples Commands view, you can click the View sample commands link in the Samples and Tutorials view.
Execute the run command to create a project, some packages, and two rules to trigger notification.
The sample handles the ActionRule element only.
The console displays the RSS data in XML format.
Click the following link to subscribe to the RSS feed:
http://localhost:<PORT>/teamserver/RSSRawProvider.jsp
You can also configure notification for your RSS reader each time a user modifies a rule.
Certain browser versions might not recognize the RSS format. In this case, the tree is shown as XML.
Look at the changes that you have made.
To use permanent links and enable anonymous sign-in:
In the RSS reader, copy the permanent link from either rulename1 or rulename1Active to your browser.
This link has the format http://localhost:<PORT>/teamserver/anonymous/faces/explore/details.jsp?project=...
Notice from the top banner that you are not signed in, and that as an anonymous user, you do not have access to any of the editing buttons in the toolbar.
Click the Query tab.
You still do not have any editing buttons available.
Click the Explore tab.
Click the folder
.Notice how you see only rules with a status of new.
In the samples console, double-click the resetrss command to reset the RSS data on the server.
Refresh your browser to see how recent changes are cleared.
To rebuild this sample:
In the Samples Commands view, navigate to
.Execute the build command to recompile the code.
In the Sample Server view, click Restore the Sample Server database to return the sample server to its initial state.
When you create or update an element, the NotificationController.onCommitElement() method is called when entering the IlrSession.commit method, just before committing an element. An event containing all relevant data is created and stored in a thread-local storage. The NotificationController.elementCommitted() is called just after an element has been committed. The event is retrieved from a thread-local storage and an RSS item is created in memory.
When you delete an element, the NotificationController.onDeleteElement() method is called when entering the IlrSession.delete() method, just before deleting an element. The NotificationController.elementDeleted() method is called just after an element has been deleted.
To make RSS data available, you use an HTTP request. Whenever an RSS reader requests RSS data, the JSP script is executed and an RSS-formatted string is returned. All RSS items generated by creating, updating, or deleting are stored in memory, as shown above. When the application server shuts down, items are persisted in a file and when the application server is restarted, items are read from the file and loaded into memory.
To configure Decision Center to use the new controller, you implement a custom session controller, specify it in a preferences.properties file (teamserver.controller.class=ilog.rules.rts.samples.notification.model.NotificationController), and store it in a JAR file. You also specify the isUserInRole class as follows: teamserver.isUserInRole.class = ilog.rules.rts.samples.notification.model.MyIsUserInRoleCallback.
Included are three additional JAR files containing the sample code and an RSS library.
You perform the customization in the build.xml file. The repack command calls a predefined target named repackage-war which repackages the Decision Center EAR. This command uses the following parameters:
sourceWar, the initial WAR file.
targetWar, the customized WAR file.
additionalJars, the additional JAR files required by this sample:
sample-controller.jar: This file contains the sample code, the preference.properties file, and the messages.properties file.
rome-0.8.jar — ROME is an open source (Apache license) set of Atom and RSS Java™ utilities that make it easy to work in Java with most syndication formats, including RSS 0.90, RSS 0.91 Netscape, RSS 0.91 Userland, RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0, RSS 2.0, Atom 0.3, and Atom 1.0.
webResourcesDir, a directory that includes the .jsp files, the web.xml descriptor with the anonymous sign-in enabled, the extended-faces-config.xml JSF configuration file, and the sample-web.jar containing the sample code to customize the UI for read-only users.
To get a permanent link on the modified element, you use the method getElementDetailsURL from the class ilog.rules.teamserver.model.permalink.IlrPermanentLinkHelper.
You create an instance of IlrPermanentLinkHelper with anonymous enabled.
To enable anonymous sign-in, you add the extensionsFilter, the accessFilter, and the Faces Servlet mapping for anonymous in the web.xml descriptor. These lines are already present in the delivered web.xml file, remove the comments from the code. In the sample, to do this automatically when repackaging the WAR, two descriptors are merged: anonymous-web.xml located in the \data directory and the original one from the Decision Center WAR (see the build.xml file for more details).
To customize the UI, the following bean classes are redefined DetailsToolbarBean, QueryToolbarBean, TableToolbarBean, TreeToolbarBean, and LinkBean to disable the editing features in the toolbars as well as the Compose tab.
After these classes are redefined, they are added to the JSF configuration file for extended features, extended-faces-config.xml, and this file is added to the repackaged EAR.
To redefine the search criteria to have anonymous users view only rules with the status new, redefine the redefineSearch method on the controller.
This sample is located in <InstallDir>/teamserver/samples/serveractionnotification/src/ilog/rules/rts/samples/notification.
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, and switch to the Java perspective.