org.olat.core.logging.activity
Class UserActivityLoggerImpl

java.lang.Object
  extended by org.olat.core.logging.activity.UserActivityLoggerImpl
All Implemented Interfaces:
IUserActivityLogger

public class UserActivityLoggerImpl
extends java.lang.Object
implements IUserActivityLogger

Default implementation of the IUserActivityLogger which logs into the o_loggingtable.

This class would usually not be subclassed or changed as it closely works together with the ThreadLocalUserActivityLogger.

Also, this class should not have to be accessed directly or cast to in any way.

There is an instance of UserActivityLoggerImpl for every Controller and for every ThreadLocalUserActivityLogger during its run methods.

The UserActivityLoggerImpl gathers all information during the course of time to be ready for the log() call later - i.e. to have all mandatory information at that time. This includes such things as session/identity, the businessPath and the list of LoggingResourceables.

Also, this class implements the simpleDuration calculation - which is a simple time difference between log calls within a session. Note that this is really simple, as it does not distinguish between having multiple log calls per click and having no log calls for a number of clicks - hence the simpleDuration can only be useful to some extend. The plan is to introduce a semanticDuration or some other concept later. Anyway, for the simpleDuration the UserActivityLoggerImpl stores the last LoggingObject (the actual hibernate object) into the session for comparison later.

Initial Date: 21.10.2009

Author:
Stefan

Field Summary
static java.lang.String USESS_KEY_USER_ACTIVITY_LOGGING_LAST_LOG
          the key with which the last LoggingObject is stored in the session - used for simpleDuration calculation only
 
Method Summary
 void addLoggingResourceInfo(ILoggingResourceable loggingResourceable)
          Adds the given LoggingResourceable - which can be thought of as a simple wrapper around say an ICourse, a Node or in other cases just a String - to this IUserActivityLogger permanently.
 void frameworkSetBCContextEntries(java.util.List<ContextEntry> bcEntries)
          INTERNAL FRAMEWORK METHOD!
 void frameworkSetBusinessPath(java.lang.String businessPath)
          INTERNAL FRAMEWORK METHOD!
 void frameworkSetBusinessPathFromWindowControl(WindowControl wControl)
          INTERNAL FRAMEWORK METHOD!
 void frameworkSetSession(UserSession session)
          INTERNAL FRAMEWORK METHOD!
 ActionType getStickyActionType()
          Gets 'sticky' ActionType of this IUserActivityLogger - or null if none is set
 void log(ILoggingAction loggingAction, java.lang.Class<?> callingClass, ILoggingResourceable... lriOrNull)
          Stores a new log entry with the available information to the logging table.
static UserActivityLoggerImpl newLoggerForEventBus(Controller controller)
          The special thing about this 'logger for EventBus' is, that it doesn't propagate resourceInfos/businessPath etc to the parent nor the ThreadLocalUserActivityLogger.
static IUserActivityLogger newLoggerForValueUnbound(UserSession session)
          Webcontainer thread for expired sessions triggers value unbound which in turn disposes the whole gui session.
 void setStickyActionType(ActionType actionType)
          Sets the given ActionType 'sticky' to this IUserActivityLogger - i.e.
static UserActivityLoggerImpl setupLoggerForController(WindowControl wControl)
          This method is used by the DefaultController to setup a new logger based on what's currently set in the ThreadLocalUserActivityLogger.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USESS_KEY_USER_ACTIVITY_LOGGING_LAST_LOG

public static final java.lang.String USESS_KEY_USER_ACTIVITY_LOGGING_LAST_LOG
the key with which the last LoggingObject is stored in the session - used for simpleDuration calculation only

See Also:
Constant Field Values
Method Detail

setupLoggerForController

public static UserActivityLoggerImpl setupLoggerForController(WindowControl wControl)
This method is used by the DefaultController to setup a new logger based on what's currently set in the ThreadLocalUserActivityLogger.

Parameters:
wControl - the WindowControl from which the businessPath and contextEntries are extracted
Returns:
a new UserActivityLoggerImpl purpose built for the DefaultController - never returns null

newLoggerForValueUnbound

public static IUserActivityLogger newLoggerForValueUnbound(UserSession session)
Webcontainer thread for expired sessions triggers value unbound which in turn disposes the whole gui session. This UserTrackingLogger must be specially rooted.

Returns:

newLoggerForEventBus

public static UserActivityLoggerImpl newLoggerForEventBus(Controller controller)
The special thing about this 'logger for EventBus' is, that it doesn't propagate resourceInfos/businessPath etc to the parent nor the ThreadLocalUserActivityLogger.

Parameters:
controller - the Controller from which the IUserActivityLogger and the WindowControl (businessPath) should be extracted
Returns:
a new UserActivityLoggerImpl purpose built for use by the EventBus during fireEvent

frameworkSetSession

public void frameworkSetSession(UserSession session)
Description copied from interface: IUserActivityLogger
INTERNAL FRAMEWORK METHOD!

Sets the session on this IUserActivityLogger directly.

Note that there are two ways the session is set on an IUserActivityLogger:

Specified by:
frameworkSetSession in interface IUserActivityLogger
Parameters:
session - the session which should be set on this IUserActivityLogger

addLoggingResourceInfo

public void addLoggingResourceInfo(ILoggingResourceable loggingResourceable)
Description copied from interface: IUserActivityLogger
Adds the given LoggingResourceable - which can be thought of as a simple wrapper around say an ICourse, a Node or in other cases just a String - to this IUserActivityLogger permanently.

This should be used by Controller constructors while setting up the IUserActivityLogger.

Anything set on the Controller's IUserActivityLogger will later be available for logging during event/doDispose calls.

Specified by:
addLoggingResourceInfo in interface IUserActivityLogger
Parameters:
loggingResourceable - the LoggingResourceable which should be added to this IUserActivityLogger

frameworkSetBusinessPath

public void frameworkSetBusinessPath(java.lang.String businessPath)
Description copied from interface: IUserActivityLogger
INTERNAL FRAMEWORK METHOD!

Sets the businesspath - as String - on this IUserActivityLogger.

This method is called in a few carefully selected places only.

You should usually not call this otherwise - if you have to consider checking with the other places to verify why you have to set it

Specified by:
frameworkSetBusinessPath in interface IUserActivityLogger

frameworkSetBCContextEntries

public void frameworkSetBCContextEntries(java.util.List<ContextEntry> bcEntries)
Description copied from interface: IUserActivityLogger
INTERNAL FRAMEWORK METHOD!

Sets the business context entries on this IUserActivityLogger.

This method is called in a few carefully selected places only.

PS: The context entries are used to make safety checks to ensure the business path matches the ResourceableInfos. It is likely that this will become redundant (i.e. overkill) at some point and that we'll get rid of this

Specified by:
frameworkSetBCContextEntries in interface IUserActivityLogger

frameworkSetBusinessPathFromWindowControl

public void frameworkSetBusinessPathFromWindowControl(WindowControl wControl)
Description copied from interface: IUserActivityLogger
INTERNAL FRAMEWORK METHOD!

Sets the businesspath - by retrieving it from the WindowControl - on this IUserActivityLogger.

This method is called in a few carefully selected places only.

You should usually not call this otherwise - if you have to consider checking with the other places to verify why you have to set it

Specified by:
frameworkSetBusinessPathFromWindowControl in interface IUserActivityLogger

setStickyActionType

public void setStickyActionType(ActionType actionType)
Description copied from interface: IUserActivityLogger
Sets the given ActionType 'sticky' to this IUserActivityLogger - i.e. when you set the sticky ActionType any ActionType passed along to the log() method in the ILoggingAction is overwritten.

Specified by:
setStickyActionType in interface IUserActivityLogger
Parameters:
actionType - the sticky ActionType which should overwrite whatever comes in the ILoggingAction in log()

getStickyActionType

public ActionType getStickyActionType()
Description copied from interface: IUserActivityLogger
Gets 'sticky' ActionType of this IUserActivityLogger - or null if none is set

Specified by:
getStickyActionType in interface IUserActivityLogger

log

public void log(ILoggingAction loggingAction,
                java.lang.Class<?> callingClass,
                ILoggingResourceable... lriOrNull)
Description copied from interface: IUserActivityLogger
Stores a new log entry with the available information to the logging table.

Note that the logged information is composed from the following:

Specified by:
log in interface IUserActivityLogger
Parameters:
loggingAction - the logging action which contains the log message to log
callingClass - the class which calls this log method - stored to the databae
lriOrNull - zero or many LoggingResourceable objects - they will be stored to the database (four of them - the outermost and the three innermost ones)
See Also:
for details on the database table