org.olat.core.logging.activity
Class CoreLoggingResourceable

java.lang.Object
  extended by org.olat.core.logging.activity.CoreLoggingResourceable
All Implemented Interfaces:
ILoggingResourceable

public class CoreLoggingResourceable
extends java.lang.Object
implements ILoggingResourceable

Core implementation for LoggingResourceable - i.e. contains those LoggingResourceables that are known in the olatcore.

A LoggingResourceable is the least common denominator between an OlatResourceable, an OlatResource, a RepositoryEntry and simple Strings - all of which want to be used as (greatGrandParent,grandParent,parent,target) resources in the logging table.

The idea of this class is to have one class containing the three fields

combined.

Besides the above (container for the triple type/id/name) it serves the purpose of doing checks between the businessPath/contextEntries and the ThreadLocalUserActivityLogger's LoggingResourceables which have been collected all the way from the initial request creating a particular Controller to the actual event handling method calling into IUserActivityLogger.log() - optionally passing additional LoggingResourceables.

The above check is done as a testing means to assure the data we're logging matches what we expect it to contain.

This way we avoid difficult if not unrealistic testing of the use of this IUserActivityLogging framework.

If a comparison with the businessPath fails, a simple (technical) log.WARN is issued. This should then be noticed by the system administrator hence feeding back into a patch or a fix for the next release.

Initial Date: 20.10.2009

Author:
Stefan

Method Summary
 boolean correspondsTo(ContextEntry ce)
          Checks whether this LoggingResourceable represents the same resource as the given ContextEntry.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getId()
          Returns the id of this LoggingResourceable - the id varies depending on the type of this LoggingResourceable - but usually it is the olatresourceable id or the olatresource id.
 java.lang.String getName()
          Returns the name of this LoggingResourceable - the name varies depending on the type of this LoggingResource - e.g.
 ILoggingResourceableType getResourceableType()
          Returns the ILoggingResourceableType of this LoggingResourceable - used for businessPath checking
 java.lang.String getType()
          Returns the type of this LoggingResourceable - this is the OlatResourceable's type (in case this LoggingResource represents a OlatResourceable) - or the StringResourceableType's enum name() otherwise
 int hashCode()
           
 java.lang.String toString()
           
static CoreLoggingResourceable wrap(Identity identity)
          Wraps an Identity as type StringResourceableType.targetIdentity into a LoggingResourceable
static CoreLoggingResourceable wrap(OLATResourceable olatResourceable, ILoggingResourceableType type)
          General wrapper for an OlatResourceable - as it's not obvious of what type that OlatResourceable is (in terms of being able to later compare it against the businessPath etc) an ILoggingResourceableType needs to be passed to this method as well.
static CoreLoggingResourceable wrapBCFile(java.lang.String bcFileName)
          Wraps a filename as type StringResourceableType.bcFile into a LoggingResourceable
static CoreLoggingResourceable wrapBGRight(java.lang.String right)
          Wraps a businessgroup right as type StringResourceableType.bgRight into a LoggingResourceable
static CoreLoggingResourceable wrapCpNode(java.lang.String cpNodeName)
          Wraps a cpNodeName as type StringResourceableType.cpNode into a LoggingResourceable
static CoreLoggingResourceable wrapNonOlatResource(StringResourceableType type, java.lang.String idForDB, java.lang.String nameForDB)
          General wrapper for non OlatResourceable types - i.e.
static CoreLoggingResourceable wrapSpUri(java.lang.String spUri)
          Wraps a single page uri as type StringResourceableType.spUri into a LoggingResourceable
static CoreLoggingResourceable wrapUploadFile(java.lang.String uploadFileName)
          Wraps a filename as type StringResourceableType.uploadFile into a LoggingResourceable
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

wrapNonOlatResource

public static CoreLoggingResourceable wrapNonOlatResource(StringResourceableType type,
                                                          java.lang.String idForDB,
                                                          java.lang.String nameForDB)
General wrapper for non OlatResourceable types - i.e. for simple Strings.

The LoggingResourceable always needs to have an ILoggingResourceableType - therefore it needs to be passed to this method.

Note that the typeForDB (so to speak) is set to ILoggingResourceableType.name().

Also note that there are a few further specialized wrapXXX(String) methods for selected StringResourceableTypes.

Parameters:
type - the ILoggingResourceableType which corresponds the given id/name information
idForDB - the id - to be stored to the database
nameForDB - the name - to be stored to the database
Returns:
a LoggingResourceable wrapping the given type/id/name triple

wrapUploadFile

public static CoreLoggingResourceable wrapUploadFile(java.lang.String uploadFileName)
Wraps a filename as type StringResourceableType.uploadFile into a LoggingResourceable

Parameters:
uploadFileName - the filename - to be stored to the database in the name field
Returns:
a LoggingResourceable wrapping the given filename as type StringResourceableType.uploadFile

wrapBCFile

public static CoreLoggingResourceable wrapBCFile(java.lang.String bcFileName)
Wraps a filename as type StringResourceableType.bcFile into a LoggingResourceable

Parameters:
bcFileName - the filename - to be stored to the database in the name field
Returns:
a LoggingResourceable wrapping the given filename as type StringResourceableType.bcFile

wrapCpNode

public static CoreLoggingResourceable wrapCpNode(java.lang.String cpNodeName)
Wraps a cpNodeName as type StringResourceableType.cpNode into a LoggingResourceable

Parameters:
cpNodeName - the node name - to be stored to the database in the name field
Returns:
a LoggingResourceable wrapping the given node name as type StringResourceableType.cpNode

wrapSpUri

public static CoreLoggingResourceable wrapSpUri(java.lang.String spUri)
Wraps a single page uri as type StringResourceableType.spUri into a LoggingResourceable

Parameters:
spUri - the single page uri - to be stored to the database in the name field
Returns:
a LoggingResourceable wrapping the given uri as type StringResourceableType.spUri

wrapBGRight

public static CoreLoggingResourceable wrapBGRight(java.lang.String right)
Wraps a businessgroup right as type StringResourceableType.bgRight into a LoggingResourceable

Parameters:
right - the name of the businessgroup right - to be stored to the database in the name field
Returns:
a LoggingResourceable wrapping the given right name as type StringResourceableType.bgRight

wrap

public static CoreLoggingResourceable wrap(Identity identity)
Wraps an Identity as type StringResourceableType.targetIdentity into a LoggingResourceable

Parameters:
identity - the identity - to be stored to the database in the name field
Returns:
a LoggingResourceable wrapping the given identity as type StringResourceableType.targetIdentity

wrap

public static CoreLoggingResourceable wrap(OLATResourceable olatResourceable,
                                           ILoggingResourceableType type)
General wrapper for an OlatResourceable - as it's not obvious of what type that OlatResourceable is (in terms of being able to later compare it against the businessPath etc) an ILoggingResourceableType needs to be passed to this method as well.

Parameters:
olatResourceable - a general OlatResourceable
type - the type of the olatResourceable
Returns:
a LoggingResourceable wrapping the given olatResourceable type pair

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getType

public java.lang.String getType()
Returns the type of this LoggingResourceable - this is the OlatResourceable's type (in case this LoggingResource represents a OlatResourceable) - or the StringResourceableType's enum name() otherwise

Specified by:
getType in interface ILoggingResourceable
Returns:
the type of this LoggingResourceable

getId

public java.lang.String getId()
Returns the id of this LoggingResourceable - the id varies depending on the type of this LoggingResourceable - but usually it is the olatresourceable id or the olatresource id.

Specified by:
getId in interface ILoggingResourceable
Returns:
the id of this LoggingResourceable

getName

public java.lang.String getName()
Returns the name of this LoggingResourceable - the name varies depending on the type of this LoggingResource - e.g. in the course case it is the name of the course, in the CP case it is the html filename incl path

Specified by:
getName in interface ILoggingResourceable
Returns:

getResourceableType

public ILoggingResourceableType getResourceableType()
Returns the ILoggingResourceableType of this LoggingResourceable - used for businessPath checking

Specified by:
getResourceableType in interface ILoggingResourceable
Returns:
the ILoggingResourceableType of this LoggingResourceable

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

correspondsTo

public boolean correspondsTo(ContextEntry ce)
Checks whether this LoggingResourceable represents the same resource as the given ContextEntry.

This is used during the businessPath check.

Specified by:
correspondsTo in interface ILoggingResourceable
Parameters:
ce -
Returns: