org.olat.core.logging.activity
Class ResourceableTypeList

java.lang.Object
  extended by org.olat.core.logging.activity.ResourceableTypeList

public class ResourceableTypeList
extends java.lang.Object

A ResourceableTypeList is a structured collection of ILoggingResourceableTypes specifying which of them are mandatory with a LoggingAction and which are optional.

The idea of ResouceableTypeList is to be able to make checks between the businessPath and all the LoggingResourceables collected during the Controller lifetime, the event handling and information passed with the log() call.

Check with the LoggingAction class to see most common use cases of ResourceableTypeList - here's an excerpt though:

 new ResourceableTypeList().
         addMandatory(OlatResourceableType.wiki).
    or().addMandatory(OlatResourceableType.businessGroup).addOptional(OlatResourceableType.wiki);
 
So the idea is to chain addMandatory and addOptional calls for as long as types need to be added to the same list - then OR that by calling or() and add a second/third variant which also is allowed etc etc. As soon as one of the lists validates to true it will return true for the whole list.

Initial Date: 21.10.2009

Author:
Stefan

Constructor Summary
ResourceableTypeList()
          Create an empty ResourceableTypeList.
 
Method Summary
 ResourceableTypeList addMandatory(ILoggingResourceableType... resourceableTypes)
          Add any number of ILoggingResourceableTypes as mandatory to this list.
 ResourceableTypeList addOptional(ILoggingResourceableType... resourceableTypes)
          Add any number of ILoggingResourceableTypes as optional to this list.
 void allowAnything()
          A magic-stick kind of 'allow everything' used to create a ResourceableTypeList which doesn't do any checks such as mandatory/optional/or etc at all but simply allows anything and everything.
 java.lang.String executeCheckAndGetErrorMessage(java.util.List<ILoggingResourceable> resourceInfos)
          Executes the businessPath check on this list - this includes taking into account any or()-ed sublists.
 ResourceableTypeList or()
          Starts a new ResourceableTypeList which is ORed with the callee list
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceableTypeList

public ResourceableTypeList()
Create an empty ResourceableTypeList.

Call this to later add ILoggingResourceableTypes using addMandatory() and addOptional().

When a new ORed sublist needs to be created, this can be done via the convenient or() method.

Method Detail

or

public ResourceableTypeList or()
Starts a new ResourceableTypeList which is ORed with the callee list

Returns:
a new ReosurceableTypeList which is ORed with the callee list

addMandatory

public ResourceableTypeList addMandatory(ILoggingResourceableType... resourceableTypes)
Add any number of ILoggingResourceableTypes as mandatory to this list.

Note that addMandatory() and addOptional() methods can be chained/repeated for as often as required

Parameters:
resourceableTypes - the list of ILoggingResourceableTypes to be added as mandatory to this list
Returns:
this

addOptional

public ResourceableTypeList addOptional(ILoggingResourceableType... resourceableTypes)
Add any number of ILoggingResourceableTypes as optional to this list.

Note that addMandatory() and addOptional() methods can be chained/repeated for as often as required

Parameters:
resourceableTypes - the list of ILoggingResourceableTypes to be added as optional to this list
Returns:
this

allowAnything

public void allowAnything()
A magic-stick kind of 'allow everything' used to create a ResourceableTypeList which doesn't do any checks such as mandatory/optional/or etc at all but simply allows anything and everything.


toString

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

executeCheckAndGetErrorMessage

public java.lang.String executeCheckAndGetErrorMessage(java.util.List<ILoggingResourceable> resourceInfos)
Executes the businessPath check on this list - this includes taking into account any or()-ed sublists.

Parameters:
resourceInfos - the list to be checked against
Returns:
null if we have a match, the error message otherwise