Class JSONAccessLogReader

  • All Implemented Interfaces:
    AccessLogReader, LogReader, java.io.Closeable, java.lang.AutoCloseable

    @ThreadSafety(level=NOT_THREADSAFE)
    public final class JSONAccessLogReader
    extends java.lang.Object
    implements AccessLogReader
    This class provides a mechanism for reading JSON-formatted access log messages.
    NOTE: This class, and other classes within the com.unboundid.ldap.sdk.unboundidds package structure, are only supported for use against Ping Identity, UnboundID, and Nokia/Alcatel-Lucent 8661 server products. These classes provide support for proprietary functionality or for external specifications that are not considered stable or mature enough to be guaranteed to work in an interoperable way with other types of LDAP servers.
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONAccessLogReader​(java.io.File logFile)
      Creates a new JSON access log reader that will read JSON-formatted access log messages from the specified file.
      JSONAccessLogReader​(java.io.InputStream inputStream)
      Creates a new JSON access log reader that will read JSON-formatted access log messages from the provided input stream.
      JSONAccessLogReader​(java.lang.String logFilePath)
      Creates a new JSON access log reader that will read JSON-formatted access log messages from the specified file.
    • Constructor Detail

      • JSONAccessLogReader

        public JSONAccessLogReader​(@NotNull
                                   java.lang.String logFilePath)
                            throws java.io.IOException
        Creates a new JSON access log reader that will read JSON-formatted access log messages from the specified file.
        Parameters:
        logFilePath - The path to the log file from which the access log messages will be read. It must not be null.
        Throws:
        java.io.IOException - If a problem occurs while opening the specified file for reading.
      • JSONAccessLogReader

        public JSONAccessLogReader​(@NotNull
                                   java.io.File logFile)
                            throws java.io.IOException
        Creates a new JSON access log reader that will read JSON-formatted access log messages from the specified file.
        Parameters:
        logFile - The log file from which the access log messages will be read. It must not be null.
        Throws:
        java.io.IOException - If a problem occurs while opening the specified file for reading.
      • JSONAccessLogReader

        public JSONAccessLogReader​(@NotNull
                                   java.io.InputStream inputStream)
        Creates a new JSON access log reader that will read JSON-formatted access log messages from the provided input stream.
        Parameters:
        inputStream - The input stream from which the access log messages will be read. It must not be null.
    • Method Detail

      • readMessage

        @Nullable
        public JSONAccessLogMessage readMessage()
                                         throws java.io.IOException,
                                                LogException
        Reads a log message.
        Specified by:
        readMessage in interface AccessLogReader
        Specified by:
        readMessage in interface LogReader
        Returns:
        The log message that was read, or null if the end of the log has been reached.
        Throws:
        java.io.IOException - If a problem occurs while attempting to read from the log. If this exception is thrown, then it will not be possible to continue reading from the log, and the reader will have been closed.
        LogException - If a problem occurs while attempting to parse a message that was read from the log. If this exception is thrown, then you may continue attempting to read from the log.
      • parseMessage

        @NotNull
        public static JSONAccessLogMessage parseMessage​(@NotNull
                                                        JSONObject messageObject)
                                                 throws LogException
        Parses the contents of the provided JSON object as a JSON-formatted access log message.
        Parameters:
        messageObject - The JSON object to parse as an access log message. It must not be null.
        Returns:
        The parsed access log message.
        Throws:
        LogException - If the provided JSON object cannot be parsed as a valid access log message.
      • close

        public void close()
                   throws java.io.IOException
        Closes this log reader.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface LogReader
        Throws:
        java.io.IOException - If a problem occurs while closing the reader.