jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nandana Mihindukulasooriya" <nandana....@gmail.com>
Subject Using Observation
Date Sun, 12 Aug 2007 07:17:41 GMT

    I want to use observation in my blog application and the node structure
of the application is follows. I want
to catch the event of adding a new comment to a blog entry. This will be
used to generate email alerts when a
comment is added to a blog entry of our interest.

    - blogRoot[nt:folder]
       - <username>[blog:user]
           - <yyyy> [nt:folder]
               - <mm>[nt:folder]
                  - <blogEntry>[blog:blogEntry]
                       - <comment> [blog:Comment]

    In the application, I initiate a session at the application start up and
logout that session at the application shutdown
as I want my listener to be alive throughout the application. Is that the
correct way to go ? It is also said that it is
good to use the superuser account or a special account to create that
session to have full read access to the Workspace.
How can create a session as superuser ?

   The specification(JSR-170) says " The set of events can be filtered by
specifying restrictions based on characteristics
of the associated parent node of the event. The associated parent node of an
event is the parent node of the item at (or
formerly  at) the path returned by Event.getPath.So I tried using the code
below but it doesn't work. When I remove the
nodeTypes constraint it works fine and give me all the NODE_ADDED events. Am
I missing something ?

    Workspace ws = session.getWorkspace();
    ObservationManager observationMgr = ws.getObservationManager();
    AlertManager alertMgr = new AlertManager(repository);
String[]{"blog:blogEntry"}, false);

    AlertManager implements the javax.jcr.observation.EventListener  .

  What I really want is to catch the event of adding a new comment. Is there
a way to constrain the events by the node type
of the node actually being added and not it's parent ? Or else do I have to
use the path returned by the event and do a
work around if there are many types of nodes are added to the
parent(blogEntry, in the current context) and I am interested
in only one type(comment).

   Thank you in advance.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message