use of org.nuxeo.ecm.platform.audit.api.AuditLogger in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveFileSystemDeletionListener method computeLogEntry.
protected LogEntry computeLogEntry(String eventName, Date eventDate, String docId, String docPath, String principal, String docType, String repositoryName, String currentLifeCycleState, String impactedUserName, FileSystemItem fsItem) {
AuditLogger logger = Framework.getService(AuditLogger.class);
LogEntry entry = logger.newLogEntry();
entry.setEventId(eventName);
entry.setEventDate(eventDate);
entry.setCategory(NuxeoDriveEvents.EVENT_CATEGORY);
entry.setDocUUID(docId);
entry.setDocPath(docPath);
entry.setPrincipalName(principal);
entry.setDocType(docType);
entry.setRepositoryId(repositoryName);
entry.setDocLifeCycle(currentLifeCycleState);
Map<String, ExtendedInfo> extendedInfos = new HashMap<String, ExtendedInfo>();
if (impactedUserName != null) {
extendedInfos.put("impactedUserName", logger.newExtendedInfo(impactedUserName));
}
// We do not serialize the whole object as it's too big to fit in a
// StringInfo column
extendedInfos.put("fileSystemItemId", logger.newExtendedInfo(fsItem.getId()));
extendedInfos.put("fileSystemItemName", logger.newExtendedInfo(fsItem.getName()));
entry.setExtendedInfos(extendedInfos);
return entry;
}
use of org.nuxeo.ecm.platform.audit.api.AuditLogger 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");
}
}
Aggregations