use of org.nuxeo.ecm.core.event.impl.EventContextImpl in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveFileSystemDeletionListener method fireVirtualEventLogEntries.
protected void fireVirtualEventLogEntries(DocumentModel doc, String eventName, Principal principal, String impactedUserName, CoreSession session) {
if (Framework.getService(AuditLogger.class) == null) {
// The log is not deployed (probably in unittest)
return;
}
List<LogEntry> entries = new ArrayList<>();
// XXX: shall we use the server local for the event date or UTC?
Date currentDate = Calendar.getInstance(NuxeoDriveManagerImpl.UTC).getTime();
FileSystemItem fsItem = getFileSystemItem(doc, eventName);
if (fsItem == null) {
// roots in order to make Drive add / remove them if needed
if (NuxeoDriveEvents.SECURITY_UPDATED_EVENT.equals(eventName)) {
for (DocumentModel childSyncRoot : getChildSyncRoots(doc, session)) {
FileSystemItem childSyncRootFSItem = getFileSystemItem(childSyncRoot, eventName);
if (childSyncRootFSItem != null) {
entries.add(computeLogEntry(eventName, currentDate, childSyncRoot.getId(), childSyncRoot.getPathAsString(), principal.getName(), childSyncRoot.getType(), childSyncRoot.getRepositoryName(), childSyncRoot.getCurrentLifeCycleState(), impactedUserName, childSyncRootFSItem));
}
}
}
} else {
entries.add(computeLogEntry(eventName, currentDate, doc.getId(), doc.getPathAsString(), principal.getName(), doc.getType(), doc.getRepositoryName(), doc.getCurrentLifeCycleState(), impactedUserName, fsItem));
}
if (!entries.isEmpty()) {
EventContext eventContext = new EventContextImpl(entries.toArray());
Event event = eventContext.newEvent(NuxeoDriveEvents.VIRTUAL_EVENT_CREATED);
Framework.getService(EventProducer.class).fireEvent(event);
}
}
Aggregations