No JCR event when using the usermanager
I try to implement an audit mechanism and part of it is to track the changes that happen in the user and group sections. However when I use the REST interface of the usermanager, I don't receive any events when a user is added below /system/userManager/user When I add a node there "by hand" I get the notifications Any obvious reason for that? Thanks, Markus
Re: No JCR event when using the usermanager
On Thu, Jan 27, 2011 at 9:56 AM, Markus Joschko wrote: > I try to implement an audit mechanism and part of it is to track the > changes that happen in the user and group sections. > However when I use the REST interface of the usermanager, I don't > receive any events when a user is added below /system/userManager/user > > When I add a node there "by hand" I get the notifications > > Any obvious reason for that? Just guessing, but I think the user nodes are added to the 'security' workspace, but the event listeners are only listening to events from the 'default' workspace. You could try registering a JCR event listener for the security workspace by repository.login([credentials], "security").getObservationManager().addEventListener(...); -- Vidar S. Ramdal - http://www.idium.no Sommerrogata 13-15, N-0255 Oslo, Norway + 47 22 00 84 00 Quando omni flunkus moritatus!
Re: No JCR event when using the usermanager
Hi Vidar, that also doesn't work. Checking the CreateUserServlet I see that it is using the default workspace. Any other ideas? Thanks, Markus On Thu, Jan 27, 2011 at 10:06 AM, Vidar Ramdal wrote: > On Thu, Jan 27, 2011 at 9:56 AM, Markus Joschko > wrote: >> I try to implement an audit mechanism and part of it is to track the >> changes that happen in the user and group sections. >> However when I use the REST interface of the usermanager, I don't >> receive any events when a user is added below /system/userManager/user >> >> When I add a node there "by hand" I get the notifications >> >> Any obvious reason for that? > > Just guessing, but I think the user nodes are added to the 'security' > workspace, but the event listeners are only listening to events from > the 'default' workspace. > > You could try registering a JCR event listener for the security > workspace by repository.login([credentials], > "security").getObservationManager().addEventListener(...); > > -- > Vidar S. Ramdal - http://www.idium.no > Sommerrogata 13-15, N-0255 Oslo, Norway > + 47 22 00 84 00 > Quando omni flunkus moritatus! >
Sling.getContent() and resourceType
Main Question: How do I get Sling.getContent() to not follow the resourceType on a JCR node? Details: In my main JSP, I'm using /system/sling.js to do a Sling.getContent('/mynode', 1); to see if people have registered pages with me. I then create navigation controls based on the categories and pages available (using attributes on the node). Worked like a charm. I then started to create sling:resourceType on the '/mynode' node and its children to have the data drive the UI and to take advantage of different views of the same page. Very cool. I ended up using a GET.jsp so that sling/JCR would direct all GET requests to my JSP page (i.e. http://server:port/mynode). That is working too. But now I've noticed my navigation is empty because the getContent(...) node is following the resourceType on /mynode and its children and ends up trying to eval the text of the JSP that the resourceType eventually resolves to (GET.jsp). I can see why that is happening if the getContent(...) eventually uses a GET to acquire the nodes information. Is there any way to get both of these working together? Can I get Sling.getContent() to not follow the resourceType? Or is there a (much) better way to do this (it just seemed so simple)? Thanks. Andrew Top
Re: Sling.getContent() and resourceType
On 27.01.11 17:23, "Andrew Top" wrote: >How do I get Sling.getContent() to not follow the resourceType on a JCR >node? >... >I ended up using a GET.jsp so that sling/JCR would direct all GET >requests to my JSP page (i.e. http://server:port/mynode). I think getContent() will use .json, right? Then you should avoid overwriting the json extension in your script, which you do by the generic GET.jsp. If you only generate html in your jsp for example (for handling requests like /something.html), you could use a GET.html.jsp. Regards, Alex -- Alexander Klimetschek Developer // Adobe (Day) // Berlin - Basel
RE: Sling.getContent() and resourceType
Right. That makes sense. But (always a but isn't there)... I have a node at /records say. I want to user to be able to hit that node by specifying the URL: http://server:port/records. I have been using resourceType to accomplish that. But without specifying any selectors, extensions, suffixes, or anything else, I find I need to use GET.jsp. Is there a better way? Or do I require the user to add a 'html'? -Original Message- From: Alexander Klimetschek [mailto:aklim...@adobe.com] Sent: Thursday, January 27, 2011 11:30 AM To: users@sling.apache.org Subject: Re: Sling.getContent() and resourceType On 27.01.11 17:23, "Andrew Top" wrote: >How do I get Sling.getContent() to not follow the resourceType on a JCR >node? >... >I ended up using a GET.jsp so that sling/JCR would direct all GET >requests to my JSP page (i.e. http://server:port/mynode). I think getContent() will use .json, right? Then you should avoid overwriting the json extension in your script, which you do by the generic GET.jsp. If you only generate html in your jsp for example (for handling requests like /something.html), you could use a GET.html.jsp. Regards, Alex -- Alexander Klimetschek Developer // Adobe (Day) // Berlin - Basel
Re: Sling.getContent() and resourceType
On 27.01.11 17:55, "Andrew Top" wrote: >I have a node at /records say. I want to user to be able to hit that >node by specifying the URL: http://server:port/records. What do you mean by "hit that node"? How do the responses look like - html, xml, etc.? > I have been using resourceType to accomplish that. But without >specifying any selectors, extensions, suffixes, or anything else, I find >I need to use GET.jsp. Is there a better way? Or do I require the user >to add a 'html'? You add whatever extension (and selectors) you are using. Using extensions based on the response format is such a good practice that it is built into the heart of Sling. Using no extension at all is possible, but then you need to manually handle the default servlets if you rely on them. For example, for the json needed by getContent() you would have a GET.json.jsp and do sth. like (where default-json-servlet needs to be replaced with the right type, I don't know it at the moment). Regards, Alex -- Alexander Klimetschek Developer // Adobe (Day) // Berlin - Basel
RE: Sling.getContent() and resourceType
I think "Using extensions based on the response format is such a good practice" is my answer. I was hoping to not force the user to enter an HTML extension (in the browser URL). Sounds like that is bad practice. (Just for completeness): By 'hit that node' I mean entering the URL in the browser to the node (i.e. http://server:port/records), like 'hit that website'. Thanks. -Original Message- From: Alexander Klimetschek [mailto:aklim...@adobe.com] Sent: Thursday, January 27, 2011 12:07 PM To: users@sling.apache.org Subject: Re: Sling.getContent() and resourceType On 27.01.11 17:55, "Andrew Top" wrote: >I have a node at /records say. I want to user to be able to hit that >node by specifying the URL: http://server:port/records. What do you mean by "hit that node"? How do the responses look like - html, xml, etc.? > I have been using resourceType to accomplish that. But without >specifying any selectors, extensions, suffixes, or anything else, I find >I need to use GET.jsp. Is there a better way? Or do I require the user >to add a 'html'? You add whatever extension (and selectors) you are using. Using extensions based on the response format is such a good practice that it is built into the heart of Sling. Using no extension at all is possible, but then you need to manually handle the default servlets if you rely on them. For example, for the json needed by getContent() you would have a GET.json.jsp and do sth. like (where default-json-servlet needs to be replaced with the right type, I don't know it at the moment). Regards, Alex -- Alexander Klimetschek Developer // Adobe (Day) // Berlin - Basel
Re: Sling.getContent() and resourceType
With a server like apache httpd in the mix you could of course rewrite or proxy the URL so the user would not need to type the .html extension. Not sure, but I suppose that sling might have similar capability. -james. On Thu, Jan 27, 2011 at 11:15 AM, Andrew Top wrote: >I think "Using extensions based on the response format is such a > good practice" is my answer. I was hoping to not force the user to enter an > HTML extension (in the browser URL). Sounds like that is bad practice. > >(Just for completeness): By 'hit that node' I mean entering the URL > in the browser to the node (i.e. http://server:port/records), like 'hit > that website'. > >Thanks. > > -Original Message- > From: Alexander Klimetschek [mailto:aklim...@adobe.com] > Sent: Thursday, January 27, 2011 12:07 PM > To: users@sling.apache.org > Subject: Re: Sling.getContent() and resourceType > > On 27.01.11 17:55, "Andrew Top" wrote: > >I have a node at /records say. I want to user to be able to hit that > >node by specifying the URL: http://server:port/records. > > What do you mean by "hit that node"? How do the responses look like - > html, xml, etc.? > > > > I have been using resourceType to accomplish that. But without > >specifying any selectors, extensions, suffixes, or anything else, I find > >I need to use GET.jsp. Is there a better way? Or do I require the user > >to add a 'html'? > > You add whatever extension (and selectors) you are using. Using extensions > based on the response format is such a good practice that it is built into > the heart of Sling. > > Using no extension at all is possible, but then you need to manually > handle the default servlets if you rely on them. For example, for the json > needed by getContent() you would have a GET.json.jsp and do sth. like > (where > default-json-servlet needs to be replaced with the right type, I don't > know it at the moment). > > Regards, > Alex > > -- > Alexander Klimetschek > Developer // Adobe (Day) // Berlin - Basel > > > > >
Re: No JCR event when using the usermanager
>> On Thu, Jan 27, 2011 at 9:56 AM, Markus Joschko >> wrote: >>> I try to implement an audit mechanism and part of it is to track the >>> changes that happen in the user and group sections. >>> However when I use the REST interface of the usermanager, I don't >>> receive any events when a user is added below /system/userManager/user >>> >>> When I add a node there "by hand" I get the notifications >>> >>> Any obvious reason for that? > On Thu, Jan 27, 2011 at 10:06 AM, Vidar Ramdal wrote: >> Just guessing, but I think the user nodes are added to the 'security' >> workspace, but the event listeners are only listening to events from >> the 'default' workspace. >> >> You could try registering a JCR event listener for the security >> workspace by repository.login([credentials], >> "security").getObservationManager().addEventListener(...); On Thu, Jan 27, 2011 at 4:59 PM, Markus Joschko wrote: > Hi Vidar, > that also doesn't work. > Checking the CreateUserServlet I see that it is using the default workspace. Hmm, yes, the CreateUserServlet uses a session for the default workspace to get the UserManager, which in turn is used to create the user. But I'm pretty sure that Jackrabbit internally stores users in the security workspace. Maybe you could post the code of your EventListener, and of ObservationManager.addEventListener call? -- Vidar S. Ramdal - http://www.idium.no Sommerrogata 13-15, N-0255 Oslo, Norway + 47 22 00 84 00 Quando omni flunkus moritatus!
Re: No JCR event when using the usermanager
Hi, Vidar is right. In Jackrabbit 1 users used to be stored in the security workspace. In Jackrabbit 2 this has been made a bit more pluggable, but IIRC users are still stored in the security workspace. IIRC the session to access the security workspace is encapsulated in the UserManager. Regards Felix Am Donnerstag, den 27.01.2011, 19:05 + schrieb Vidar Ramdal: > >> On Thu, Jan 27, 2011 at 9:56 AM, Markus Joschko > >> wrote: > >>> I try to implement an audit mechanism and part of it is to track the > >>> changes that happen in the user and group sections. > >>> However when I use the REST interface of the usermanager, I don't > >>> receive any events when a user is added below /system/userManager/user > >>> > >>> When I add a node there "by hand" I get the notifications > >>> > >>> Any obvious reason for that? > > > On Thu, Jan 27, 2011 at 10:06 AM, Vidar Ramdal wrote: > >> Just guessing, but I think the user nodes are added to the 'security' > >> workspace, but the event listeners are only listening to events from > >> the 'default' workspace. > >> > >> You could try registering a JCR event listener for the security > >> workspace by repository.login([credentials], > >> "security").getObservationManager().addEventListener(...); > > On Thu, Jan 27, 2011 at 4:59 PM, Markus Joschko > wrote: > > Hi Vidar, > > that also doesn't work. > > Checking the CreateUserServlet I see that it is using the default workspace. > > Hmm, yes, the CreateUserServlet uses a session for the default > workspace to get the UserManager, which in turn is used to create the > user. > But I'm pretty sure that Jackrabbit internally stores users in the > security workspace. > > Maybe you could post the code of your EventListener, and of > ObservationManager.addEventListener call? > >
Re: No JCR event when using the usermanager
On Thu, Jan 27, 2011 at 10:29 PM, Felix Meschberger wrote: > Hi, > > Vidar is right. In Jackrabbit 1 users used to be stored in the security > workspace. In Jackrabbit 2 this has been made a bit more pluggable, but > IIRC users are still stored in the security workspace. > > IIRC the session to access the security workspace is encapsulated in the > UserManager. Regardless of where users are actually stored by Jackrabbit, perhaps it would make sense to have CreateUserServlet fire an OSGi event (like org/apache/sling/api/resource/Resource/ADDED) when adding a user? The same would obviously apply to the other servlets under o.a.s.jackrabbit.usermanager.impl.post. > Am Donnerstag, den 27.01.2011, 19:05 + schrieb Vidar Ramdal: >> >> On Thu, Jan 27, 2011 at 9:56 AM, Markus Joschko >> >> wrote: >> >>> I try to implement an audit mechanism and part of it is to track the >> >>> changes that happen in the user and group sections. >> >>> However when I use the REST interface of the usermanager, I don't >> >>> receive any events when a user is added below /system/userManager/user >> >>> >> >>> When I add a node there "by hand" I get the notifications >> >>> >> >>> Any obvious reason for that? >> >> > On Thu, Jan 27, 2011 at 10:06 AM, Vidar Ramdal wrote: >> >> Just guessing, but I think the user nodes are added to the 'security' >> >> workspace, but the event listeners are only listening to events from >> >> the 'default' workspace. >> >> >> >> You could try registering a JCR event listener for the security >> >> workspace by repository.login([credentials], >> >> "security").getObservationManager().addEventListener(...); >> >> On Thu, Jan 27, 2011 at 4:59 PM, Markus Joschko >> wrote: >> > Hi Vidar, >> > that also doesn't work. >> > Checking the CreateUserServlet I see that it is using the default >> > workspace. >> >> Hmm, yes, the CreateUserServlet uses a session for the default >> workspace to get the UserManager, which in turn is used to create the >> user. >> But I'm pretty sure that Jackrabbit internally stores users in the >> security workspace. >> >> Maybe you could post the code of your EventListener, and of >> ObservationManager.addEventListener call? >> >> > > > -- Vidar S. Ramdal - http://www.idium.no Sommerrogata 13-15, N-0255 Oslo, Norway + 47 22 00 84 00 Quando omni flunkus moritatus!