Element bundle = DomUtil.createElement(document, XML_EVENTBUNDLE, NAMESPACE);
if (transactionId != null) {
DomUtil.setAttribute(bundle, XML_EVENT_TRANSACTION_ID, NAMESPACE, transactionId);
}
while (events.hasNext()) {
Event event = events.nextEvent();
Element eventElem = DomUtil.addChildElement(bundle, XML_EVENT, NAMESPACE);
// href
String eHref = "";
try {
boolean isCollection = (event.getType() == Event.NODE_ADDED || event.getType() == Event.NODE_REMOVED);
eHref = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), event.getPath(), false).getHref(isCollection);
} catch (RepositoryException e) {
// should not occur....
log.error(e.getMessage());
}
eventElem.appendChild(DomUtil.hrefToXml(eHref, document));
// event type
Element eType = DomUtil.addChildElement(eventElem, XML_EVENTTYPE, NAMESPACE);
eType.appendChild(getEventType(event.getType()).toXml(document));
// user id
DomUtil.addChildElement(eventElem, XML_EVENTUSERID, NAMESPACE, event.getUserID());
// Additional JCR 2.0 event information
// user data
try {
DomUtil.addChildElement(eventElem, XML_EVENTUSERDATA, NAMESPACE, event.getUserData());
} catch (RepositoryException e) {
log.error("Internal error while retrieving event user data.", e.getMessage());
}
// time stamp
try {
DomUtil.addChildElement(eventElem, XML_EVENTDATE, NAMESPACE, String.valueOf(event.getDate()));
} catch (RepositoryException e) {
log.error("Internal error while retrieving event date.", e.getMessage());
}
// identifier
try {
DomUtil.addChildElement(eventElem, XML_EVENTIDENTIFIER, NAMESPACE, event.getIdentifier());
} catch (RepositoryException e) {
log.error("Internal error while retrieving event identifier.", e.getMessage());
}
// info
Element info = DomUtil.addChildElement(eventElem, XML_EVENTINFO, NAMESPACE);
try {
@SuppressWarnings({"RawUseOfParameterizedType"}) Map m = event.getInfo();
for (Object o : m.keySet()) {
String key = o.toString();
Object value = m.get(key);
if (value != null) {
DomUtil.addChildElement(info, key, Namespace.EMPTY_NAMESPACE, value.toString());