org.opencms.file
Class CmsResourceFilter

java.lang.Object
  extended by org.opencms.file.CmsResourceFilter

public final class CmsResourceFilter
extends java.lang.Object

Provides filters for resource result sets obtained from requests to the OpenCms VFS.

Using the constant filters provided by this class you can control "special" behaviour of access to the VFS. For example, in the "Offline" project there can be deleted files, by using this filter you can control if deleted files should be included in a result set or not.

Since:
6.0.0
Version:
$Revision: 1.32 $
Author:
Michael Emmerich, Alexander Kandzior, Carsten Weinholz, Jan Baudisch

Field Summary
static CmsResourceFilter ALL
          Filter to display all resources.
static CmsResourceFilter ALL_MODIFIED
          Filter to display all modified (new/changed/deleted) resources.
static CmsResourceFilter DEFAULT
          Default filter to display resources for the online project.
static CmsResourceFilter DEFAULT_FILES
          Default filter to display files for the online project.
static CmsResourceFilter DEFAULT_FOLDERS
          Default filter to display folders for the online project.
static CmsResourceFilter IGNORE_EXPIRATION
          Filter to display resources ignoring the release and expiration dates.
static CmsResourceFilter ONLY_VISIBLE
          Filter to display only visible resources.
static CmsResourceFilter ONLY_VISIBLE_NO_DELETED
          Filter to display only visible and not deleted resources.
 
Method Summary
 CmsResourceFilter addExcludeFlags(int flags)
          Returns an extended filter in order to avoid the given flags in the filtered resources.
 CmsResourceFilter addExcludeState(CmsResourceState state)
          Returns an extended filter in order to avoid the given type in the filtered resources.
 CmsResourceFilter addExcludeTimerange()
          Returns an extended filter to guarantee all filtered resources ignoring the time range (released and not expired) window.
 CmsResourceFilter addExcludeType(int type)
          Returns an extended filter in order to avoid the given type in the filtered resources.
 CmsResourceFilter addRequireExpireAfter(long time)
          Returns an extended filter to restrict the results to resources that expire in the given timerange.
 CmsResourceFilter addRequireExpireBefore(long time)
          Returns an extended filter to restrict the results to resources that expire in the given timerange.
 CmsResourceFilter addRequireFile()
          Returns an extended filter that requires all returned resources to be files.
 CmsResourceFilter addRequireFlags(int flags)
          Returns an extended filter to guarantee a distinct resource flags of the filtered resources.
 CmsResourceFilter addRequireFolder()
          Returns an extended filter that requires all returned resources to be folders.
 CmsResourceFilter addRequireLastModifiedAfter(long time)
          Returns an extended filter to restrict the results to resources modified in the given timerange.
 CmsResourceFilter addRequireLastModifiedBefore(long time)
          Returns an extended filter to restrict the results to resources modified in the given timerange.
 CmsResourceFilter addRequireReleaseAfter(long time)
          Returns an extended filter to restrict the results to resources that are released in the given timerange.
 CmsResourceFilter addRequireReleaseBefore(long time)
          Returns an extended filter to restrict the results to resources that are released in the given timerange.
 CmsResourceFilter addRequireState(CmsResourceState state)
          Returns an extended filter to guarantee a distinct resource state of the filtered resources.
 CmsResourceFilter addRequireTimerange()
          Returns an extended filter to guarantee all filtered resources are valid (released and not expired).
 CmsResourceFilter addRequireType(int type)
          Returns an extended filter to guarantee a distinct resource type of the filtered resources.
 CmsResourceFilter addRequireVisible()
          Returns an extended filter to guarantee all filtered resources are visible.
 java.lang.Object clone()
           
 boolean excludeFlags()
          return if the stored flags should be excluded while filtering resources.
 boolean excludeState()
          return if the stored state should be excluded while filtering resources.
 boolean excludeType()
          Returns if the stored type should be excluded while filtering resources.
 java.lang.String getCacheId()
          Returns the unique cache id for this filter.
 long getExpireAfter()
          Returns the start of the expire time range for this filter.
 long getExpireBefore()
          Returns the end of the expire time range for this filter.
 int getFlags()
          Returns the flags for this filter.
 long getModifiedAfter()
          Returns the start of the modification time range for this filter.
 long getModifiedBefore()
          Returns the end of the modification time range for this filter.
 java.lang.Boolean getOnlyFolders()
          Returns the state of the "only folders" flag.
 long getReleaseAfter()
          Returns the start of the release time range for this filter.
 long getReleaseBefore()
          Returns the end of the release time range for this filter.
 CmsResourceState getState()
          Returns the state for this filter.
 int getType()
          Returns the type for this filter.
 boolean includeDeleted()
          Check if deleted resources should be filtered.
 boolean isValid(CmsRequestContext context, CmsResource resource)
          Validates if a CmsResource fits to all filer settings.
 boolean requireFlags()
          Returns if the stored flags is required while filtering resources.
 boolean requireState()
          Returns if the stored state is required while filtering resources.
 boolean requireTimerange()
          Returns if the release timerange of the resource should be required.
 boolean requireType()
          Returns if the stored type is required while filtering resources.
static CmsResourceFilter requireType(int type)
          Returns a new CmsResourceFilter requiring the given type.
 boolean requireVisible()
          Returns if the visible permission should be required for resources.
 java.lang.String toString()
          Returns the name of the filter, if it is one of the filters used as a constant of this class and a default message otherwise.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL

public static final CmsResourceFilter ALL
Filter to display all resources.

This filter uses the following rules:


ALL_MODIFIED

public static final CmsResourceFilter ALL_MODIFIED
Filter to display all modified (new/changed/deleted) resources.


DEFAULT

public static final CmsResourceFilter DEFAULT
Default filter to display resources for the online project.

This filter uses the following rules:


DEFAULT_FILES

public static final CmsResourceFilter DEFAULT_FILES
Default filter to display files for the online project.


DEFAULT_FOLDERS

public static final CmsResourceFilter DEFAULT_FOLDERS
Default filter to display folders for the online project.


IGNORE_EXPIRATION

public static final CmsResourceFilter IGNORE_EXPIRATION
Filter to display resources ignoring the release and expiration dates.

This filter uses the following rules:


ONLY_VISIBLE

public static final CmsResourceFilter ONLY_VISIBLE
Filter to display only visible resources.

This filter used the following rules:


ONLY_VISIBLE_NO_DELETED

public static final CmsResourceFilter ONLY_VISIBLE_NO_DELETED
Filter to display only visible and not deleted resources.

This filter used the following rules:

Method Detail

requireType

public static CmsResourceFilter requireType(int type)
Returns a new CmsResourceFilter requiring the given type.

Parameters:
type - the required resource type
Returns:
a filter requiring the given type

addExcludeFlags

public CmsResourceFilter addExcludeFlags(int flags)
Returns an extended filter in order to avoid the given flags in the filtered resources.

Parameters:
flags - the resource flags to exclude
Returns:
a filter excluding the given resource flags

addExcludeState

public CmsResourceFilter addExcludeState(CmsResourceState state)
Returns an extended filter in order to avoid the given type in the filtered resources.

Parameters:
state - the resource state to exclude
Returns:
a filter excluding the given resource state

addExcludeTimerange

public CmsResourceFilter addExcludeTimerange()
Returns an extended filter to guarantee all filtered resources ignoring the time range (released and not expired) window.

This is the reverse of addRequireTimerange().

Returns:
a filter excluding invalid resources

addExcludeType

public CmsResourceFilter addExcludeType(int type)
Returns an extended filter in order to avoid the given type in the filtered resources.

Parameters:
type - the resource type to exclude
Returns:
a filter excluding the given resource type

addRequireExpireAfter

public CmsResourceFilter addRequireExpireAfter(long time)
Returns an extended filter to restrict the results to resources that expire in the given timerange.

Parameters:
time - the required time
Returns:
a filter to restrict the results to resources that expire in the given timerange

addRequireExpireBefore

public CmsResourceFilter addRequireExpireBefore(long time)
Returns an extended filter to restrict the results to resources that expire in the given timerange.

Parameters:
time - the required time
Returns:
a filter to restrict the results to resources that expire in the given timerange

addRequireFile

public CmsResourceFilter addRequireFile()
Returns an extended filter that requires all returned resources to be files.

Returns:
an extended filter that requires all returned resources to be files

addRequireFlags

public CmsResourceFilter addRequireFlags(int flags)
Returns an extended filter to guarantee a distinct resource flags of the filtered resources.

Parameters:
flags - the required resource flags
Returns:
a filter requiring the given resource flags

addRequireFolder

public CmsResourceFilter addRequireFolder()
Returns an extended filter that requires all returned resources to be folders.

Returns:
an extended filter that requires all returned resources to be folders

addRequireLastModifiedAfter

public CmsResourceFilter addRequireLastModifiedAfter(long time)
Returns an extended filter to restrict the results to resources modified in the given timerange.

Parameters:
time - the required time
Returns:
a filter to restrict the results to resources modified in the given timerange

addRequireLastModifiedBefore

public CmsResourceFilter addRequireLastModifiedBefore(long time)
Returns an extended filter to restrict the results to resources modified in the given timerange.

Parameters:
time - the required time
Returns:
a filter to restrict the results to resources modified in the given timerange

addRequireReleaseAfter

public CmsResourceFilter addRequireReleaseAfter(long time)
Returns an extended filter to restrict the results to resources that are released in the given timerange.

Parameters:
time - the required time
Returns:
a filter to restrict the results to resources that are released in the given timerange

addRequireReleaseBefore

public CmsResourceFilter addRequireReleaseBefore(long time)
Returns an extended filter to restrict the results to resources that are released in the given timerange.

Parameters:
time - the required time
Returns:
a filter to restrict the results to resources that are released in the given timerange

addRequireState

public CmsResourceFilter addRequireState(CmsResourceState state)
Returns an extended filter to guarantee a distinct resource state of the filtered resources.

Parameters:
state - the required resource state
Returns:
a filter requiring the given resource state

addRequireTimerange

public CmsResourceFilter addRequireTimerange()
Returns an extended filter to guarantee all filtered resources are valid (released and not expired).

Returns:
a filter excluding invalid resources

addRequireType

public CmsResourceFilter addRequireType(int type)
Returns an extended filter to guarantee a distinct resource type of the filtered resources.

Parameters:
type - the required resource type
Returns:
a filter requiring the given resource type

addRequireVisible

public CmsResourceFilter addRequireVisible()
Returns an extended filter to guarantee all filtered resources are visible.

Returns:
a filter excluding invisible resources

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

excludeFlags

public boolean excludeFlags()
return if the stored flags should be excluded while filtering resources.

Returns:
if the flags should be excluded

excludeState

public boolean excludeState()
return if the stored state should be excluded while filtering resources.

Returns:
if the state should be excluded

excludeType

public boolean excludeType()
Returns if the stored type should be excluded while filtering resources.

Returns:
if the type should be excluded

getCacheId

public java.lang.String getCacheId()
Returns the unique cache id for this filter.

Returns:
the unique cache id for this filter

getExpireAfter

public long getExpireAfter()
Returns the start of the expire time range for this filter.

Returns:
start of the expire time range for this filter

getExpireBefore

public long getExpireBefore()
Returns the end of the expire time range for this filter.

Returns:
the end of the expire time range for this filter

getFlags

public int getFlags()
Returns the flags for this filter.

Returns:
the flags for this filter

getModifiedAfter

public long getModifiedAfter()
Returns the start of the modification time range for this filter.

Returns:
start of the modification time range for this filter

getModifiedBefore

public long getModifiedBefore()
Returns the end of the modification time range for this filter.

Returns:
the end of the modification time range for this filter

getOnlyFolders

public java.lang.Boolean getOnlyFolders()
Returns the state of the "only folders" flag.

If the result is null, then this flag is not set.

Returns:
the state of the "only folders" flag

getReleaseAfter

public long getReleaseAfter()
Returns the start of the release time range for this filter.

Returns:
start of the release time range for this filter

getReleaseBefore

public long getReleaseBefore()
Returns the end of the release time range for this filter.

Returns:
the end of the release time range for this filter

getState

public CmsResourceState getState()
Returns the state for this filter.

Returns:
the state for this filter

getType

public int getType()
Returns the type for this filter.

Returns:
the type for this filter

includeDeleted

public boolean includeDeleted()
Check if deleted resources should be filtered.

Returns:
true if deleted resources should be included, false otherwise

isValid

public boolean isValid(CmsRequestContext context,
                       CmsResource resource)
Validates if a CmsResource fits to all filer settings.

Please note that the "visible permission" setting of the filter is NOT checked in this method since the permission information is not part of the resource. The visible permission information in the filter will be used in the permission checks

Parameters:
context - the current request context
resource - the resource to be validated
Returns:
true if the resource passes all validations, false otherwise

requireFlags

public boolean requireFlags()
Returns if the stored flags is required while filtering resources.

Returns:
if the flags is required

requireState

public boolean requireState()
Returns if the stored state is required while filtering resources.

Returns:
if the state is required

requireTimerange

public boolean requireTimerange()
Returns if the release timerange of the resource should be required.

Returns:
true if the release timerange of the resource should be required

requireType

public boolean requireType()
Returns if the stored type is required while filtering resources.

Returns:
true if the type is required

requireVisible

public boolean requireVisible()
Returns if the visible permission should be required for resources.

Returns:
true if the visible permission is required, false if the visible permission is ignored

toString

public java.lang.String toString()
Returns the name of the filter, if it is one of the filters used as a constant of this class and a default message otherwise.

Overrides:
toString in class java.lang.Object
Returns:
the name of the filter