com.sun.identity.log
Class LogReader

java.lang.Object
  |
  +--com.sun.identity.log.LogReader

public class LogReader
extends java.lang.Object

LogReader class provides mechanism to read a log file to the caller It does the authorization check, reads line from the file, applies query if any, collects most recent records, sorts the records and returns the result in a two dimensional String. Where columns in the the first row i.e. 0th row always hold the header info (field names) present in the ELF formatted file. Other rows hold the value present under those columns.


Method Summary
static java.util.ArrayList getLogFields()
          Gets the names of the Log Fields that are selected for logging in the Logging Service template, plus the mandatory "time" and "Data" fields.
static java.util.Set getLogNames()
          Gets the names of the Log Files or Tables.
static long getSize(java.lang.String logName)
          Gets the number of LogRecords in the specified table in the DB.
static int getSizeUnits()
          Gets the units (LogConstants.NUM_BYTES or LogConstants.NUM_RECORDS) that applies to the value returned by getSize(logName).
static java.lang.String[][] read(java.util.Set fileNames, LogQuery logQuery, java.lang.Object userCrdential)
          Retrieves specific records in a given sorted order on specific field (if user specifies valid sorting by field).
static java.lang.String[][] read(java.lang.String fileName, LogQuery logQuery, java.lang.Object userCrdential)
          Retrieves specific records in a given sorted order on specific field (if user specifies valid sorting by field).
static java.lang.String[][] read(java.lang.String fileName, java.lang.Object userCrdential)
          Reads the specified log file provided the user has the authorization.
static java.lang.String[][] read(java.lang.String logName, java.lang.String logType, LogQuery logQuery, java.lang.Object userCrdential)
          Retrieves records from log file provided it has the required authorization.
static java.lang.String[][] read(java.lang.String logName, java.lang.String logType, java.lang.Object userCrdential)
          Retrieves records from a log file provided the user has the required authorization.
static java.lang.String[][] read(java.lang.String logname, java.lang.String logtype, java.lang.String timeStamp, LogQuery logQuery, java.lang.Object userCrdential)
          Reads a log file provided it has the required authorization.
static java.lang.String[][] read(java.lang.String logName, java.lang.String logType, java.lang.String timeStamp, java.lang.Object userCrdential)
          Reads a log file provided the user has the authorization.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSizeUnits

public static int getSizeUnits()
                        throws java.lang.Exception
Gets the units (LogConstants.NUM_BYTES or LogConstants.NUM_RECORDS) that applies to the value returned by getSize(logName).
Returns:
the units applying to the return value of getSize(logName), LogConstants.NUM_BYTES (in the case of File logging), or LogConstants.NUM_RECORDS (in the case of DB logging).
Throws:
java.lang.Exception - if unrecoverable problem occurs, that is beyond its control.

getSize

public static long getSize(java.lang.String logName)
                    throws java.io.IOException,
                           java.lang.Exception
Gets the number of LogRecords in the specified table in the DB. In the case where logging is to a file, the number of bytes in the specified file is returned. Use getSizeUnits() to get which units apply.
Parameters:
logName - is the name of the Table or File
Returns:
the number of LogRecords (in the DB table), or number of bytes (in the file).
Throws:
java.io.IOException - if file does not exist.
java.lang.Exception - if unrecoverable problem occurs, that is beyond its control.

getLogNames

public static java.util.Set getLogNames()
Gets the names of the Log Files or Tables. The Set of names is what is found in the directory or DB, filtered through a default list of names. Thus, log files or tables with custom names will not be included. This does not preclude querying those log files or tables with custom names.
Returns:
the Log File/Table names in a Set.

getLogFields

public static java.util.ArrayList getLogFields()
Gets the names of the Log Fields that are selected for logging in the Logging Service template, plus the mandatory "time" and "Data" fields.
Returns:
the Field/Column names in an ArrayList.

read

public static java.lang.String[][] read(java.lang.String fileName,
                                        java.lang.Object userCrdential)
                                 throws java.io.IOException,
                                        java.lang.NoSuchFieldException,
                                        java.lang.IllegalArgumentException,
                                        java.lang.RuntimeException,
                                        java.lang.Exception
Reads the specified log file provided the user has the authorization. It reads all records and returns them without any modification. This query ignores the max record parameter set through configuration. This API is present to support log verifier requirement.
Parameters:
fileName - is the filename without path that will be read
userCrdential - user credential to check authorization.
Returns:
results in a two dimensional String, where columns in the the first row always hold the field names present in the file. Other rows hold the values present under those column.
Throws:
java.io.IOException - if interrupted or failed to do I/O.
java.lang.NoSuchFieldException - if invalid field has been specified.
java.lang.IllegalArgumentException - when inappropriate argument specified.
java.lang.RuntimeException - when it has been caught in any phase.
java.lang.Exception - if unrecoverable problem occurs, that is beyond its control.

read

public static java.lang.String[][] read(java.lang.String logName,
                                        java.lang.String logType,
                                        java.lang.Object userCrdential)
                                 throws java.io.IOException,
                                        java.lang.NoSuchFieldException,
                                        java.lang.IllegalArgumentException,
                                        java.lang.RuntimeException,
                                        java.lang.Exception
Retrieves records from a log file provided the user has the required authorization. It identifies the filename using logname and type. It reads all records from the file but returns the maximum number of most recent records set through configuration.
Parameters:
logName - is an identifier and is a part of file name to be read
logType - is the components of file name that will be read it could be either of "access", "error" or "system"
userCrdential - user credential to check authorization.
Returns:
results in a two dimensional String, where columns in the the first row always hold the field names present in the file. Other rows hold the values present under those column.
Throws:
java.io.IOException - if interrupted or failed to do I/O.
java.lang.NoSuchFieldException - if invalid field has been specified.
java.lang.IllegalArgumentException - when inappropriate argument specified.
java.lang.RuntimeException - when it has been caught in any phase.
java.lang.Exception - if unrecoverable problem occurs, that is beyond its control.

read

public static java.lang.String[][] read(java.lang.String logName,
                                        java.lang.String logType,
                                        java.lang.String timeStamp,
                                        java.lang.Object userCrdential)
                                 throws java.io.IOException,
                                        java.lang.NoSuchFieldException,
                                        java.lang.IllegalArgumentException,
                                        java.lang.RuntimeException,
                                        java.lang.Exception
Reads a log file provided the user has the authorization. It reads all records but returns the maximum number of most recent records set through configuration.
Parameters:
logName - is an identifier and is a part of file name to be read
logType - is the components of filename to be read, not null
timeStamp - is last component of filename to be read and not null
userCrdential - user credential for authorization check.
Returns:
results in a two dimensional String, where columns in the the first row always hold the field names present in the file. Other rows hold the values present under those column.
Throws:
java.io.IOException - if interrupted or failed to do I/O.
java.lang.NoSuchFieldException - if invalid field has been specified.
java.lang.IllegalArgumentException - when inappropriate argument specified.
java.lang.RuntimeException - when it has been caught in any phase.
java.lang.Exception - if unrecoverable problem occurs, that is beyond its control.

read

public static java.lang.String[][] read(java.lang.String logName,
                                        java.lang.String logType,
                                        LogQuery logQuery,
                                        java.lang.Object userCrdential)
                                 throws java.io.IOException,
                                        java.lang.NoSuchFieldException,
                                        java.lang.IllegalArgumentException,
                                        java.lang.RuntimeException,
                                        java.lang.Exception
Retrieves records from log file provided it has the required authorization. It reads all records applies query and returns the result as asked by the caller.
Parameters:
logName - is an identifier and is a part of file name to be read
logType - is the components of filename to be read
logQuery - that contains search criteria details
userCrdential - user credential for authorization check.
Returns:
results in a two dimensional String, where columns in the the first row always hold the field names present in the file. Other rows hold the values present under those column.
Throws:
java.io.IOException - if interrupted or failed to do I/O.
java.lang.NoSuchFieldException - if invalid field has been specified.
java.lang.IllegalArgumentException - when inappropriate argument specified.
java.lang.RuntimeException - when it has been caught in any phase.
java.lang.Exception - if unrecoverable problem occurs, that is beyond its control.

read

public static java.lang.String[][] read(java.lang.String logname,
                                        java.lang.String logtype,
                                        java.lang.String timeStamp,
                                        LogQuery logQuery,
                                        java.lang.Object userCrdential)
                                 throws java.io.IOException,
                                        java.lang.NoSuchFieldException,
                                        java.lang.IllegalArgumentException,
                                        java.lang.RuntimeException,
                                        java.lang.Exception
Reads a log file provided it has the required authorization. It reads all records but returns the maximum number of most recent records (if asked) those meet the caller's requirement as specified through query.
Parameters:
logname - is an identifier and is a part of file name to be read
logtype - is the components of filename to be read
timeStamp - is the last component of filename to be read and not null.
logQuery - that contains search criteria details
userCrdential - user credential for authorization check.
Returns:
results in a two dimensional String, where columns in the the first row always hold the field names present in the file. Other rows hold the values present under those column.
Throws:
java.io.IOException - if interrupted or failed to do I/O.
java.lang.NoSuchFieldException - if invalid field has been specified.
java.lang.IllegalArgumentException - when inappropriate argument specified.
java.lang.RuntimeException - when it has been caught in any phase.
java.lang.Exception - if unrecoverable problem occurs, that is beyond its control.

read

public static java.lang.String[][] read(java.lang.String fileName,
                                        LogQuery logQuery,
                                        java.lang.Object userCrdential)
                                 throws java.io.IOException,
                                        java.lang.NoSuchFieldException,
                                        java.lang.IllegalArgumentException,
                                        java.lang.RuntimeException,
                                        java.lang.Exception
Retrieves specific records in a given sorted order on specific field (if user specifies valid sorting by field). The API also needs the user has a successful authorization.
Parameters:
fileName - is the filename without path that will be read
logQuery - that contains search criteria details
userCrdential - user credential for authorization check.
Returns:
results in a two dimensional String, where columns in the the first row always hold the field names present in the file. Other rows hold the values present under those column.
Throws:
java.io.IOException - if interrupted or failed to do I/O.
java.lang.NoSuchFieldException - if invalid field has been specified.
java.lang.IllegalArgumentException - when inappropriate argument specified.
java.lang.RuntimeException - when it has been caught in any phase.
java.lang.Exception - if unrecoverable problem occurs, that is beyond its control.

read

public static java.lang.String[][] read(java.util.Set fileNames,
                                        LogQuery logQuery,
                                        java.lang.Object userCrdential)
                                 throws java.io.IOException,
                                        java.lang.NoSuchFieldException,
                                        java.lang.IllegalArgumentException,
                                        java.lang.RuntimeException,
                                        java.lang.Exception
Retrieves specific records in a given sorted order on specific field (if user specifies valid sorting by field). The API also needs the user has a successful authorization.
Parameters:
fileNames - is the set of filenames without path that will be read
logQuery - that contains search criteria details
userCrdential - user credential for authorization check.
Returns:
results in a two dimensional String, where columns in the the first row always hold the field names present in the file. Other rows hold the values present under those column.
Throws:
java.io.IOException - if interrupted or failed to do I/O.
java.lang.NoSuchFieldException - if invalid field has been specified.
java.lang.IllegalArgumentException - when inappropriate argument specified.
java.lang.RuntimeException - when it has been caught in any phase.
java.lang.Exception - if unrecoverable problem occurs, that is beyond its control.


Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.