Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.platform.audit.service
Class NXAuditEventsService

java.lang.Object
  extended by org.nuxeo.runtime.model.DefaultComponent
      extended by org.nuxeo.ecm.platform.audit.service.NXAuditEventsService
All Implemented Interfaces:
AuditAdmin, AuditLogger, AuditReader, Logs, NXAuditEvents, Adaptable, Component, Extensible

public class NXAuditEventsService
extends DefaultComponent
implements NXAuditEvents

Event service configuration.

Author:
Julien Anguenot

Field Summary
static ComponentName NAME
           
 
Constructor Summary
NXAuditEventsService()
           
 
Method Summary
 void addLogEntries(EntityManager em, List<LogEntry> entries)
           
 void addLogEntries(List<LogEntry> entries)
          Adds given log entries.
 void addLogEntry(EntityManager em, LogEntry entry)
           
 void addLogEntry(LogEntry entry)
           
 void deactivate(ComponentContext context)
          Deactivates the component.
 Set<String> getAuditableEventNames()
          Returns the list of auditable event names.
 Long getEventsCount(EntityManager em, String eventId)
           
 Long getEventsCount(String eventId)
           
 List<LogEntry> getLogEntriesFor(EntityManager em, String uuid)
           
 List<LogEntry> getLogEntriesFor(EntityManager em, String uuid, Map<String,FilterMapEntry> filterMap, boolean doDefaultSort)
           
 List<LogEntry> getLogEntriesFor(String uuid)
          Returns the logs given a doc uuid.
 List<LogEntry> getLogEntriesFor(String uuid, Map<String,FilterMapEntry> filterMap, boolean doDefaultSort)
           
 LogEntry getLogEntryByID(EntityManager em, long id)
           
 LogEntry getLogEntryByID(long id)
          Returns a given log entry given its id.
 List<String> getLoggedEventIds()
           
 List<String> getLoggedEventIds(EntityManager em)
           
 PersistenceProvider getOrCreatePersistenceProvider()
           
 AdapterDescriptor[] getRegisteredAdapters()
           
 void logEvent(EntityManager em, Event event)
           
 void logEvent(Event event)
          Logs an Event.
 void logEvents(EntityManager em, EventBundle eventBundle)
           
 void logEvents(EventBundle eventBundle)
          Logs a bundle of events
 List<?> nativeQuery(EntityManager em, String query, int pageNb, int pageSize)
           
 List<?> nativeQuery(EntityManager em, String query, Map<String,Object> params, int pageNb, int pageSize)
           
 List<?> nativeQuery(String query, int pageNb, int pageSize)
          Returns a batched list of entries.
 List<?> nativeQuery(String query, Map<String,Object> params, int pageNb, int pageSize)
          Returns a batched list of entries.
 List<LogEntry> nativeQueryLogs(EntityManager em, String whereClause, int pageNb, int pageSize)
           
 List<LogEntry> nativeQueryLogs(String whereClause, int pageNb, int pageSize)
          Returns a batched list of log entries.
 ExtendedInfo newExtendedInfo(Serializable value)
          Create a new ExtendedInfo instance
 LogEntry newLogEntry()
          Create a new LogEntry instance.
 List<LogEntry> queryLogs(EntityManager em, String[] eventIds, String dateRange)
           
 List<LogEntry> queryLogs(String[] eventIds, String dateRange)
          Returns the list of log entries.
 List<LogEntry> queryLogsByPage(EntityManager em, String[] eventIds, Date limit, String[] category, String path, int pageNb, int pageSize)
           
 List<LogEntry> queryLogsByPage(EntityManager em, String[] eventIds, Date limit, String category, String path, int pageNb, int pageSize)
           
 List<LogEntry> queryLogsByPage(EntityManager em, String[] eventIds, String dateRange, String[] category, String path, int pageNb, int pageSize)
           
 List<LogEntry> queryLogsByPage(EntityManager em, String[] eventIds, String dateRange, String category, String path, int pageNb, int pageSize)
           
 List<LogEntry> queryLogsByPage(String[] eventIds, Date limit, String[] category, String path, int pageNb, int pageSize)
           
 List<LogEntry> queryLogsByPage(String[] eventIds, Date limit, String category, String path, int pageNb, int pageSize)
          Returns the batched list of log entries.
 List<LogEntry> queryLogsByPage(String[] eventIds, String dateRange, String[] category, String path, int pageNb, int pageSize)
           
 List<LogEntry> queryLogsByPage(String[] eventIds, String dateRange, String category, String path, int pageNb, int pageSize)
          Returns the batched list of log entries.
 void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
           
 long syncLogCreationEntries(EntityManager em, String repoId, String path, Boolean recurs)
           
 long syncLogCreationEntries(String repoId, String path, Boolean recurs)
          Forces log Synchronisation for a branch of the repository.
 void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
           
 
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, applicationStarted, getAdapter, registerExtension, unregisterExtension
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final ComponentName NAME
Constructor Detail

NXAuditEventsService

public NXAuditEventsService()
Method Detail

getOrCreatePersistenceProvider

public PersistenceProvider getOrCreatePersistenceProvider()

deactivate

public void deactivate(ComponentContext context)
                throws Exception
Description copied from interface: Component
Deactivates the component.

This method is called by the runtime when a component is deactivated.

Specified by:
deactivate in interface Component
Overrides:
deactivate in class DefaultComponent
Parameters:
context - the runtime context
Throws:
Exception - if an error occurs during activation

registerContribution

public void registerContribution(Object contribution,
                                 String extensionPoint,
                                 ComponentInstance contributor)
                          throws Exception
Overrides:
registerContribution in class DefaultComponent
Throws:
Exception

unregisterContribution

public void unregisterContribution(Object contribution,
                                   String extensionPoint,
                                   ComponentInstance contributor)
                            throws Exception
Overrides:
unregisterContribution in class DefaultComponent
Throws:
Exception

getAuditableEventNames

public Set<String> getAuditableEventNames()
Description copied from interface: NXAuditEvents
Returns the list of auditable event names. Is there any no reason to expose event names outside of audit service ? If not, we will remove that API.

Specified by:
getAuditableEventNames in interface NXAuditEvents
Returns:
list of String representing event names.

getRegisteredAdapters

public AdapterDescriptor[] getRegisteredAdapters()

addLogEntries

public void addLogEntries(List<LogEntry> entries)
Description copied from interface: AuditLogger
Adds given log entries.

Specified by:
addLogEntries in interface AuditLogger
Parameters:
entries - the list of log entries.

addLogEntries

public void addLogEntries(EntityManager em,
                          List<LogEntry> entries)

getLogEntriesFor

public List<LogEntry> getLogEntriesFor(String uuid)
Description copied from interface: AuditReader
Returns the logs given a doc uuid.

:XXX: add parameters to this method for paging.

Specified by:
getLogEntriesFor in interface AuditReader
Parameters:
uuid - the document uuid
Returns:
a list of log entries

getLogEntriesFor

public List<LogEntry> getLogEntriesFor(EntityManager em,
                                       String uuid)

getLogEntriesFor

public List<LogEntry> getLogEntriesFor(String uuid,
                                       Map<String,FilterMapEntry> filterMap,
                                       boolean doDefaultSort)
Specified by:
getLogEntriesFor in interface AuditReader

getLogEntriesFor

public List<LogEntry> getLogEntriesFor(EntityManager em,
                                       String uuid,
                                       Map<String,FilterMapEntry> filterMap,
                                       boolean doDefaultSort)

getLogEntryByID

public LogEntry getLogEntryByID(long id)
Description copied from interface: AuditReader
Returns a given log entry given its id.

Specified by:
getLogEntryByID in interface AuditReader
Parameters:
id - the log entry identifier
Returns:
a LogEntry instance

getLogEntryByID

public LogEntry getLogEntryByID(EntityManager em,
                                long id)

nativeQueryLogs

public List<LogEntry> nativeQueryLogs(String whereClause,
                                      int pageNb,
                                      int pageSize)
Description copied from interface: AuditReader
Returns a batched list of log entries. WhereClause is a native where clause for the backend: here EJBQL 3.0 can be used.

Specified by:
nativeQueryLogs in interface AuditReader

nativeQueryLogs

public List<LogEntry> nativeQueryLogs(EntityManager em,
                                      String whereClause,
                                      int pageNb,
                                      int pageSize)

nativeQuery

public List<?> nativeQuery(String query,
                           int pageNb,
                           int pageSize)
Description copied from interface: AuditReader
Returns a batched list of entries. query string is a native query clause for the backend : here EJBQL 3.0 can be used

Specified by:
nativeQuery in interface AuditReader

nativeQuery

public List<?> nativeQuery(EntityManager em,
                           String query,
                           int pageNb,
                           int pageSize)

nativeQuery

public List<?> nativeQuery(String query,
                           Map<String,Object> params,
                           int pageNb,
                           int pageSize)
Description copied from interface: AuditReader
Returns a batched list of entries.

Specified by:
nativeQuery in interface AuditReader
Parameters:
query - a JPA query language query
params - parameters for the query
pageNb - the page number (starts at 1)
pageSize - the number of results per page

nativeQuery

public List<?> nativeQuery(EntityManager em,
                           String query,
                           Map<String,Object> params,
                           int pageNb,
                           int pageSize)

queryLogs

public List<LogEntry> queryLogs(String[] eventIds,
                                String dateRange)
Description copied from interface: AuditReader
Returns the list of log entries.

Note we will use NXQL in the future when the search engine will index history.

Specified by:
queryLogs in interface AuditReader
Parameters:
eventIds - the event ids.
dateRange - a preset date range.
Returns:
a list of log entries.
See Also:
DateRangeQueryConstants

queryLogs

public List<LogEntry> queryLogs(EntityManager em,
                                String[] eventIds,
                                String dateRange)

queryLogsByPage

public List<LogEntry> queryLogsByPage(String[] eventIds,
                                      String dateRange,
                                      String[] category,
                                      String path,
                                      int pageNb,
                                      int pageSize)
Specified by:
queryLogsByPage in interface AuditReader

queryLogsByPage

public List<LogEntry> queryLogsByPage(EntityManager em,
                                      String[] eventIds,
                                      String dateRange,
                                      String[] category,
                                      String path,
                                      int pageNb,
                                      int pageSize)

queryLogsByPage

public List<LogEntry> queryLogsByPage(String[] eventIds,
                                      Date limit,
                                      String[] category,
                                      String path,
                                      int pageNb,
                                      int pageSize)
Specified by:
queryLogsByPage in interface AuditReader

queryLogsByPage

public List<LogEntry> queryLogsByPage(EntityManager em,
                                      String[] eventIds,
                                      Date limit,
                                      String[] category,
                                      String path,
                                      int pageNb,
                                      int pageSize)

syncLogCreationEntries

public long syncLogCreationEntries(String repoId,
                                   String path,
                                   Boolean recurs)
Description copied from interface: AuditAdmin
Forces log Synchronisation for a branch of the repository. This can be useful to add the create entries if DB was initialized from a bulk import.

Specified by:
syncLogCreationEntries in interface AuditAdmin

syncLogCreationEntries

public long syncLogCreationEntries(EntityManager em,
                                   String repoId,
                                   String path,
                                   Boolean recurs)

addLogEntry

public void addLogEntry(LogEntry entry)

addLogEntry

public void addLogEntry(EntityManager em,
                        LogEntry entry)

getEventsCount

public Long getEventsCount(String eventId)

getEventsCount

public Long getEventsCount(EntityManager em,
                           String eventId)

getLoggedEventIds

public List<String> getLoggedEventIds()

getLoggedEventIds

public List<String> getLoggedEventIds(EntityManager em)

logEvent

public void logEvent(Event event)
Description copied from interface: AuditLogger
Logs an Event.

Specified by:
logEvent in interface AuditLogger

logEvents

public void logEvents(EventBundle eventBundle)
Description copied from interface: AuditLogger
Logs a bundle of events

Specified by:
logEvents in interface AuditLogger

logEvents

public void logEvents(EntityManager em,
                      EventBundle eventBundle)

logEvent

public void logEvent(EntityManager em,
                     Event event)

queryLogsByPage

public List<LogEntry> queryLogsByPage(EntityManager em,
                                      String[] eventIds,
                                      String dateRange,
                                      String category,
                                      String path,
                                      int pageNb,
                                      int pageSize)

queryLogsByPage

public List<LogEntry> queryLogsByPage(String[] eventIds,
                                      String dateRange,
                                      String category,
                                      String path,
                                      int pageNb,
                                      int pageSize)
Description copied from interface: AuditReader
Returns the batched list of log entries.

Note we will use NXQL in the future when the search engine will index history.

Specified by:
queryLogsByPage in interface AuditReader
Parameters:
eventIds - the event ids.
dateRange - a preset date range.
category - add filter on events category
path - add filter on document path
pageNb - page number (ignore if <=1)
pageSize - number of results per page
Returns:
a list of log entries.
See Also:
DateRangeQueryConstants

queryLogsByPage

public List<LogEntry> queryLogsByPage(String[] eventIds,
                                      Date limit,
                                      String category,
                                      String path,
                                      int pageNb,
                                      int pageSize)
Description copied from interface: AuditReader
Returns the batched list of log entries.

Note we will use NXQL in the future when the search engine will index history.

Specified by:
queryLogsByPage in interface AuditReader
Parameters:
eventIds - the event ids.
limit - filter events by date from limit to now
category - add filter on events category
path - add filter on document path
pageNb - page number (ignore if <=1)
pageSize - number of results per page
Returns:
a list of log entries.
See Also:
DateRangeQueryConstants

queryLogsByPage

public List<LogEntry> queryLogsByPage(EntityManager em,
                                      String[] eventIds,
                                      Date limit,
                                      String category,
                                      String path,
                                      int pageNb,
                                      int pageSize)

newLogEntry

public LogEntry newLogEntry()
Description copied from interface: AuditLogger
Create a new LogEntry instance.

Specified by:
newLogEntry in interface AuditLogger
Returns:

newExtendedInfo

public ExtendedInfo newExtendedInfo(Serializable value)
Description copied from interface: AuditLogger
Create a new ExtendedInfo instance

Specified by:
newExtendedInfo in interface AuditLogger
Returns:

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.