[opencms-dev] Retrieve data from CmsEvent

Jonathan Woods jonathan.woods at scintillance.com
Thu Oct 12 15:31:26 CEST 2006


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





More information about the opencms-dev mailing list