Search in sources :

Example 6 with EventContext

use of org.nuxeo.ecm.core.event.EventContext in project nuxeo-drive-server by nuxeo.

the class NuxeoDriveVirtualEventLogger method handleEvent.

@Override
public void handleEvent(EventBundle events) {
    AuditLogger logger = Framework.getService(AuditLogger.class);
    if (logger != null) {
        for (Event event : events) {
            EventContext ctx = event.getContext();
            Object[] args = ctx.getArguments();
            if (ArrayUtils.isEmpty(args)) {
                return;
            }
            List<LogEntry> logEntries = new ArrayList<>();
            for (int i = 0; i < args.length; i++) {
                Object arg = args[i];
                if (arg instanceof LogEntry) {
                    logEntries.add((LogEntry) arg);
                }
            }
            if (!logEntries.isEmpty()) {
                logger.addLogEntries(logEntries);
            }
        }
    } else {
        log.error("Can not reach AuditLogger");
    }
}
Also used : EventContext(org.nuxeo.ecm.core.event.EventContext) AuditLogger(org.nuxeo.ecm.platform.audit.api.AuditLogger) ArrayList(java.util.ArrayList) Event(org.nuxeo.ecm.core.event.Event) LogEntry(org.nuxeo.ecm.platform.audit.api.LogEntry)

Aggregations

EventContext (org.nuxeo.ecm.core.event.EventContext)6 Event (org.nuxeo.ecm.core.event.Event)4 DocumentEventContext (org.nuxeo.ecm.core.event.impl.DocumentEventContext)4 DocumentModel (org.nuxeo.ecm.core.api.DocumentModel)3 ArrayList (java.util.ArrayList)2 CoreSession (org.nuxeo.ecm.core.api.CoreSession)2 AuditLogger (org.nuxeo.ecm.platform.audit.api.AuditLogger)2 LogEntry (org.nuxeo.ecm.platform.audit.api.LogEntry)2 Date (java.util.Date)1 FileSystemItem (org.nuxeo.drive.adapter.FileSystemItem)1 DocumentModelList (org.nuxeo.ecm.core.api.DocumentModelList)1 DocumentRef (org.nuxeo.ecm.core.api.DocumentRef)1 EventProducer (org.nuxeo.ecm.core.event.EventProducer)1 EventService (org.nuxeo.ecm.core.event.EventService)1 EventContextImpl (org.nuxeo.ecm.core.event.impl.EventContextImpl)1 ConfigurationService (org.nuxeo.runtime.services.config.ConfigurationService)1