edu.ucsb.nceas.metacat

## Class EventLog

- java.lang.Object
- - edu.ucsb.nceas.metacat.EventLog

-     public class EventLog
      extends java.lang.Object

  EventLog is used to intialize and store a log of events that occur in an application. The events are registered with the logger as they occur, but EventLog writes them to permenant storage when it is most convenient or efficient. EventLog is a Singleton as there should always be only one object for these logging events. TODO: Logging to the database needn't be synchronous with the event. Instead, a separate thread can be launched that periodically sleeps and only wakes periodically to see if metacat is idle. The log event can be cached and inserted later when the thread wakes and finds metacat idle. TODO: Write a function that archives a part of the log table to an external text file so that the log table doesn't get to big. This function should be able to be called manually or on a schedule. TODO: Write an access function that returns an XML report for a specific subset of events. Users should be able to query on principal, docid/rev, date, event, and possibly other fields.
  Author:
    jones

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DELETE`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.dataone.service.types.v2.Log` | `getD1Report(java.lang.String[] ipAddress, java.lang.String[] principal, java.lang.String[] docid, java.lang.String event, java.sql.Timestamp startDate, java.sql.Timestamp endDate, boolean anonymous, java.lang.Integer start, java.lang.Integer count)`
    `java.util.Map<java.lang.String,java.util.List<java.lang.Object>>` | `getIndexFields(org.dataone.service.types.v1.Identifier pid, java.lang.String event)`
    `static EventLog` | `getInstance()` Return the single instance of the event log after initializing it if it wasn't previously initialized.
    `java.lang.String` | `getReport(java.lang.String[] ipAddress, java.lang.String[] principal, java.lang.String[] docid, java.lang.String[] event, java.sql.Timestamp startDate, java.sql.Timestamp endDate, boolean anonymous)` Get a report of the log events that match a set of filters.
    `boolean` | `isDeleted(java.lang.String docid)` A utility method to determine if the given docid was deleted.
    `void` | `log(java.lang.String ipAddress, java.lang.String userAgent, java.lang.String principal, java.lang.String docid, java.lang.String event)` Log an event of interest to the application.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DELETE

          public static final java.lang.String DELETE

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getInstance

          public static EventLog getInstance()

      Return the single instance of the event log after initializing it if it wasn't previously initialized.
      Returns:
        the single EventLog instance

    - #### log

          public void log(java.lang.String ipAddress,
                          java.lang.String userAgent,
                          java.lang.String principal,
                          java.lang.String docid,
                          java.lang.String event)

      Log an event of interest to the application. The information logged can include basic identification information about the principal or computer that initiated the event.
      Parameters:
        `ipAddress` - the internet protocol address for the event
        `userAgent` - the agent making the request
        `principal` - the principal for the event (a username, etc)
        `docid` - the identifier of the document to which the event applies
        `event` - the string code for the event

    - #### getIndexFields

          public java.util.Map<java.lang.String,java.util.List<java.lang.Object>> getIndexFields(org.dataone.service.types.v1.Identifier pid,
                                                                                                 java.lang.String event)

    - #### getReport

          public java.lang.String getReport(java.lang.String[] ipAddress,
                                            java.lang.String[] principal,
                                            java.lang.String[] docid,
                                            java.lang.String[] event,
                                            java.sql.Timestamp startDate,
                                            java.sql.Timestamp endDate,
                                            boolean anonymous)

      Get a report of the log events that match a set of filters. The filter parameters can be null; log records are subset based on non-null filter parameters.
      Parameters:
        `ipAddress` - the internet protocol address for the event
        `principal` - the principal for the event (a username, etc)
        `docid` - the identifier of the document to which the event applies
        `event` - the string code for the event
        `startDate` - beginning of date range for query
        `endDate` - end of date range for query
      Returns:
        an XML-formatted report of the access log entries

    - #### isDeleted

          public boolean isDeleted(java.lang.String docid)

      A utility method to determine if the given docid was deleted.
      Parameters:
        `docid` - the specified docid
      Returns:
        true if there is a delete event for the id; false otherwise.

    - #### getD1Report

          public org.dataone.service.types.v2.Log getD1Report(java.lang.String[] ipAddress,
                                                              java.lang.String[] principal,
                                                              java.lang.String[] docid,
                                                              java.lang.String event,
                                                              java.sql.Timestamp startDate,
                                                              java.sql.Timestamp endDate,
                                                              boolean anonymous,
                                                              java.lang.Integer start,
                                                              java.lang.Integer count)

Copyright © 2023 Regents of the University of California. All Rights Reserved.