org.opencms.scheduler.jobs
Class CmsRemoveOldDbLogEntriesJob

java.lang.Object
  extended by org.opencms.scheduler.jobs.CmsRemoveOldDbLogEntriesJob
All Implemented Interfaces:
I_CmsScheduledJob

public class CmsRemoveOldDbLogEntriesJob
extends java.lang.Object
implements I_CmsScheduledJob

A scheduled job which removes entries older than a given amount of time from the CMS_LOG table, to improve database performance.

This job has a single parameter named 'max-age', whose value consists of a number, followed by one or more spaces and finall a unit which is either 'hours', 'days', or 'weeks', which controls how old values have to be before they are deleted by the job.

To delete the CMS_LOG entries, this scheduled job needs to be executed as a user who has the role WORKPLACE_MANAGER.


Field Summary
static int MAX_AGE_DEFAULT
          The default max age.
static java.lang.String PARAM_MAX_AGE
          The key for the max-age parameter.
 
Constructor Summary
CmsRemoveOldDbLogEntriesJob()
           
 
Method Summary
 java.lang.String launch(CmsObject cms, java.util.Map<java.lang.String,java.lang.String> parameters)
          This method will be called when this scheduled job is executed.
 int parseMaxAge(java.lang.String maxAgeStr)
          Parses the 'max-age' parameter and returns a value in hours.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_AGE_DEFAULT

public static final int MAX_AGE_DEFAULT
The default max age.

See Also:
Constant Field Values

PARAM_MAX_AGE

public static final java.lang.String PARAM_MAX_AGE
The key for the max-age parameter.

See Also:
Constant Field Values
Constructor Detail

CmsRemoveOldDbLogEntriesJob

public CmsRemoveOldDbLogEntriesJob()
Method Detail

launch

public java.lang.String launch(CmsObject cms,
                               java.util.Map<java.lang.String,java.lang.String> parameters)
                        throws java.lang.Exception
Description copied from interface: I_CmsScheduledJob
This method will be called when this scheduled job is executed.

Depending on the configuration of this job, a new instance of the configured class will be instantiated every time the job is launched, or a new instance will be generated only the first time the job is launched, and re-used afterwards.

The result String will be written to the OpenCms logfile in the org.opencms.scheduler.CmsScheduleManager channel, on INFO log level.

Specified by:
launch in interface I_CmsScheduledJob
Parameters:
cms - will be initialized with the configured users cms context
parameters - the configured parameters
Returns:
a String that will be written to the OpenCms logfile
Throws:
java.lang.Exception - if something goes wrong
See Also:
I_CmsScheduledJob.launch(org.opencms.file.CmsObject, java.util.Map)

parseMaxAge

public int parseMaxAge(java.lang.String maxAgeStr)
Parses the 'max-age' parameter and returns a value in hours.

Parameters:
maxAgeStr - the value of the 'max-age' parameter
Returns:
the maximum age in hours