[opencms-dev] RE: Retrieve data from CmsEvent
Roman Uhlig
roman.uhlig at knve.de
Thu Oct 12 15:47:28 CEST 2006
Thanks Jon, this definitely points me in the right direction.
Your side note states that you have experienced strange behaviour using
OpenCms events? While playing around with it, I didn't notice any unusual
behaviour, at least not with the basic events like
EVENT_RESOURCE_CREATED/DELETED. Do you think it's unsafe to rely on these
events?
Just a little side question: I noticed you are using a LOG var in your
sample code. Do you use it to write into the opencms.log file? How would I
obtain such an instance? I planned to investigate this during the next days,
so maybe you could please give me another hint?
Thanks,
Roman
Jonathan Woods wrote:
>
> Here's what I used before I gave up trying to guess in what order and for
> what reason CmsEvents were called...
>
> Jon
> --------------
>
> // Get a list of all file resources concerned with this event. There may
> be
> only one resource, presented via map
> // key "resource", or there may be a list underneath "resources". See
> I_CmsEventListener for documentation.
>
> Map eventData = event.getData();
> int eventType = event.getType();
>
> List<CmsResource> resourceList;
>
> try {
> if (eventData.containsKey("resources")) {
> resourceList = (List<CmsResource>)
> eventData.get("resources");
> }
> else if (eventData.containsKey("resource")) {
> resourceList = new ArrayList<CmsResource>(1);
> resourceList.add((CmsResource) eventData.get("resource"));
> }
> else {
> LOG.error("handleEvent called for event with no associated
> resource(s) - may be indication that module code is incompatible with
> OpenCms version");
> return;
> }
> }
> catch (ClassCastException e) {
> // Should not be possible; may indicate that OpenCms version has
> bumped.
> LOG.error("Unexpected type met in event data - may be
> indication that module code is incompatible with OpenCms version", e);
> return;
> }
>
> -----Original Message-----
> From: opencms-dev-bounces at opencms.org
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Uhlig, Roman
> Knuepfer
> Verlag
> Sent: 12 October 2006 14:19
> To: The OpenCms mailing list
> Subject: [opencms-dev] Retrieve data from CmsEvent
>
>
> Hi,
> what would be the right way to retrieve the data related to a CmsEvent,
> let's say the resource name of a deleted resource in case of a
> EVENT_RESOURCE_DELETED event?
>
> CmsEvent.getData() returns a map, but it has only one key ("resources"):
>
> resources = [[org.opencms.file.CmsResource, path:
> /sites/default/test/bla, structure id
> 86ff16fb-59ec-11db-bc78-000c29e71d53, resource id:
> 86ff16fc-59ec-11db-bc78-000c29e71d53, type id: 1, folder: false, flags:
> 0, project: 4, state: 2, date created: Thu Oct 12 12:23:54 GMT 2006, user
> created: d12bc550-4199-11db-a4a5-000c29e71d53, date lastmodified:
> Thu Oct 12 12:23:54 GMT 2006, user lastmodified:
> d12bc550-4199-11db-a4a5-000c29e71d53, date released: Thu Jan 01 00:00:00
> GMT
> 1970, date expired: Sun Aug 17 07:12:55 GMT 292278994, size: 0 sibling
> count: 1]]
>
> I also can't find the I_CmsEventListener.KEY_* values in this list. Am I
> doing something wrong? Any help would be very appreciated.
>
> Thanks,
> Roman
>
> _______________________________________________
> 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
>
>
--
View this message in context: http://www.nabble.com/Retrieve-data-from-CmsEvent-tf2430225.html#a6776579
Sent from the OpenCMS - Dev mailing list archive at Nabble.com.
More information about the opencms-dev
mailing list