[opencms-dev] Catch onsave event in I_CmsEventListener

Chuck Mysak chuck.mysak at gmail.com
Mon Feb 15 15:37:07 CET 2010


Hello,

Thanks Achim for the pointer, yes, it the EVENT_RESOURCES_MODIFIED is good,
but it adds a lot of other files to the picture (on a single file
modification it fires up about 9 times)
I solved it, so for posterity, here's what you have to do:

- catch the EVENT_RESOURCES_MODIFIED event
- from the map of the event, get the resource and the "change" value
- filter out the resources so that the change value equals the modified
static constant from the CmsResource class, and the resource flags don't
have the CmsResource.FLAG_TEMPFILE bits enabled
And that's about all.

Regards,
Chuck

On Mon, Feb 15, 2010 at 2:49 PM, Achim Westermann <
achim.westermann at questico.de> wrote:

> Hi Chuck,
>
> what about EVENT_RESOURCES_MODIFIED? That is fired when a file is written
> (CmsDriverManager.writeFile... writeResource).
>
> Regarding the ~files: Those are temporary files and you might check for a
> leading ~ and then do noting (in case the event is never triggered
> for the original resource without ~ you'll have to find it by a dirty
> substring(1.. routine).
>
> HTH,
>
> Achim
>
> Chuck Mysak wrote:
> > Hello list,
> >
> > I'm trying to catch the save-and-exit event from the editor but from
> > what I see in I_CmsEventListener, this can't be done so easily.
> > I tried EVENT_RESOURCES_AND_PROPERTIES_MODIFIED, but I get the temporary
> > (prefixed with ~) resource, that is created at the moment of editing,
> > and deleted afterwards. I also tried to catch the EVENT_RESOURCE_CREATED
> > event, and then I ended up dubling the two events (the temporary
> > resource is first created and then modified).
> >
> > What I'm trying to achieve is a log of all the resources modified in the
> > offline project, after the user saves from the editor.
> >
> > Thank you in advance
> >
> >
> > Regards,
> >
> > Chuck
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> > _______________________________________________
> > This mail is sent to you from the opencms-dev mailing list
> > To change your list options, or to unsubscribe from the list, please
> visit
> > http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20100215/dfc4fc42/attachment.htm>


More information about the opencms-dev mailing list