Class CmsResourceFilter
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CmsResourceFilter
Filter to display all resources.static final CmsResourceFilter
Filter to display all modified (new/changed/deleted) resources.static final CmsResourceFilter
Default filter to display resources for the online project.static final CmsResourceFilter
Default filter to display files for the online project.static final CmsResourceFilter
Default filter to display folders for the online project.static final CmsResourceFilter
Default filter to display resources for the online project.static final CmsResourceFilter
Filter to display resources ignoring the release and expiration dates.static final CmsResourceFilter
Filter to display only visible resources.static final CmsResourceFilter
Filter to display only visible and not deleted resources. -
Method Summary
Modifier and TypeMethodDescriptionaddExcludeFlags
(int flags) Returns an extended filter in order to avoid the given flags in the filtered resources.addExcludeState
(CmsResourceState state) Returns an extended filter in order to avoid the given type in the filtered resources.Returns an extended filter to guarantee all filtered resources ignoring the time range (released and not expired) window.addExcludeType
(int type) Deprecated.Returns an extended filter in order to avoid the given type in the filtered resources.addRequireExpireAfter
(long time) Returns an extended filter to restrict the results to resources that expire in the given timerange.addRequireExpireBefore
(long time) Returns an extended filter to restrict the results to resources that expire in the given timerange.Returns an extended filter that requires all returned resources to be files.addRequireFlags
(int flags) Returns an extended filter to guarantee a distinct resource flags of the filtered resources.Returns an extended filter that requires all returned resources to be folders.addRequireLastModifiedAfter
(long time) Returns an extended filter to restrict the results to resources modified in the given timerange.addRequireLastModifiedBefore
(long time) Returns an extended filter to restrict the results to resources modified in the given timerange.addRequireReleaseAfter
(long time) Returns an extended filter to restrict the results to resources that are released in the given timerange.addRequireReleaseBefore
(long time) Returns an extended filter to restrict the results to resources that are released in the given timerange.addRequireState
(CmsResourceState state) Returns an extended filter to guarantee a distinct resource state of the filtered resources.Returns an extended filter to guarantee all filtered resources are valid (released and not expired).addRequireType
(int type) Deprecated.UseaddRequireType(I_CmsResourceType)
instead.Returns an extended filter to guarantee a distinct resource type of the filtered resources.Returns an extended filter to guarantee all filtered resources are visible.clone()
boolean
return if the stored flags should be excluded while filtering resources.boolean
return if the stored state should be excluded while filtering resources.boolean
Returns if the stored type should be excluded while filtering resources.Returns the unique cache id for this filter.long
Returns the start of the expire time range for this filter.long
Returns the end of the expire time range for this filter.int
getFlags()
Returns the flags for this filter.long
Returns the start of the modification time range for this filter.long
Returns the end of the modification time range for this filter.Returns the state of the "only folders" flag.long
Returns the start of the release time range for this filter.long
Returns the end of the release time range for this filter.getState()
Returns the state for this filter.int
getType()
Returns the type for this filter.static CmsResourceFilter
Returns the DEFAULT filter in the Online project, and IGNORE_EXPIRATION otherwise.boolean
Check if deleted resources should be filtered.boolean
isValid
(CmsRequestContext context, CmsResource resource) Validates if a CmsResource fits to all filer settings.boolean
Returns if the stored flags is required while filtering resources.boolean
Returns if the stored state is required while filtering resources.boolean
Returns if the release timerange of the resource should be required.boolean
Returns if the stored type is required while filtering resources.static CmsResourceFilter
requireType
(int type) Deprecated.UserequireType(I_CmsResourceType)
instead.static CmsResourceFilter
requireType
(I_CmsResourceType type) Returns a new CmsResourceFilter requiring the given type.boolean
Returns if the visible permission should be required for resources.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.
-
Field Details
-
ALL
Filter to display all resources.This filter uses the following rules:
- Includes: Resources marked as deleted.
- Includes: Resources outside the 'time window' set with release and expiration date.
- Includes: Resources marked as 'invisible' using permissions.
-
ALL_MODIFIED
Filter to display all modified (new/changed/deleted) resources. -
DEFAULT
Default filter to display resources for the online project.This filter uses the following rules:
- Excludes: Resources marked as deleted.
- Excludes: Resources outside the 'time window' set with release and expiration date.
- Includes: Resources marked as 'invisible' using permissions.
-
DEFAULT_FILES
Default filter to display files for the online project. -
DEFAULT_FOLDERS
Default filter to display folders for the online project. -
DEFAULT_ONLY_VISIBLE
Default filter to display resources for the online project.This filter uses the following rules:
- Excludes: Resources marked as deleted.
- Excludes: Resources outside the 'time window' set with release and expiration date.
- Excludes: Resources marked as 'invisible' using permissions.
-
IGNORE_EXPIRATION
Filter to display resources ignoring the release and expiration dates.This filter uses the following rules:
- Excludes: Resources marked as deleted.
- Includes: Resources outside the 'time window' set with release and expiration date.
- Includes: Resources marked as 'invisible' using permissions.
-
ONLY_VISIBLE
Filter to display only visible resources.This filter used the following rules:
- Includes: Resources marked as deleted.
- Includes: Resources outside the 'time window' set with release and expiration date.
- Excludes: Resources marked as 'invisible' using permissions.
-
ONLY_VISIBLE_NO_DELETED
Filter to display only visible and not deleted resources.This filter used the following rules:
- Excludes: Resources marked as deleted.
- Includes: Resources outside the 'time window' set with release and expiration date.
- Excludes: Resources marked as 'invisible' using permissions.
-
-
Method Details
-
ignoreExpirationOffline
Returns the DEFAULT filter in the Online project, and IGNORE_EXPIRATION otherwise.- Parameters:
cms
- the CMS context whose project to check- Returns:
- the resource filter based on the given CmsObject
-
requireType
Returns a new CmsResourceFilter requiring the given type.- Parameters:
type
- the required resource type- Returns:
- a filter requiring the given type
-
requireType
Deprecated.UserequireType(I_CmsResourceType)
instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.Returns a new CmsResourceFilter requiring the given type.- Parameters:
type
- the required resource type- Returns:
- a filter requiring the given type
-
addExcludeFlags
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
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
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
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
-
addExcludeType
Deprecated.UseaddExcludeType(I_CmsResourceType)
instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.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
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
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
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
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
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
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
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
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
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
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
Returns an extended filter to guarantee all filtered resources are valid (released and not expired).- Returns:
- a filter excluding invalid resources
-
addRequireType
Returns an extended filter to guarantee a distinct resource type of the filtered resources.If
-1
is given as type, the filter will not be extended to require a resource type- Parameters:
type
- the required resource type- Returns:
- a filter requiring the given resource type
-
addRequireType
Deprecated.UseaddRequireType(I_CmsResourceType)
instead. Resource types should always be referenced either by its type class (preferred) or by type name. Use of int based resource type references will be discontinued in a future OpenCms release.Returns an extended filter to guarantee a distinct resource type of the filtered resources.If
-1
is given as type, the filter will not be extended to require a resource type- Parameters:
type
- the required resource type- Returns:
- a filter requiring the given resource type
-
addRequireVisible
Returns an extended filter to guarantee all filtered resources are visible.- Returns:
- a filter excluding invisible resources
-
clone
-
excludeFlags
return if the stored flags should be excluded while filtering resources.- Returns:
- if the flags should be excluded
-
excludeState
return if the stored state should be excluded while filtering resources.- Returns:
- if the state should be excluded
-
excludeType
Returns if the stored type should be excluded while filtering resources.- Returns:
- if the type should be excluded
-
getCacheId
Returns the unique cache id for this filter.- Returns:
- the unique cache id for this filter
-
getExpireAfter
Returns the start of the expire time range for this filter.- Returns:
- start of the expire time range for this filter
-
getExpireBefore
Returns the end of the expire time range for this filter.- Returns:
- the end of the expire time range for this filter
-
getFlags
Returns the flags for this filter.- Returns:
- the flags for this filter
-
getModifiedAfter
Returns the start of the modification time range for this filter.- Returns:
- start of the modification time range for this filter
-
getModifiedBefore
Returns the end of the modification time range for this filter.- Returns:
- the end of the modification time range for this filter
-
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
Returns the start of the release time range for this filter.- Returns:
- start of the release time range for this filter
-
getReleaseBefore
Returns the end of the release time range for this filter.- Returns:
- the end of the release time range for this filter
-
getState
Returns the state for this filter.- Returns:
- the state for this filter
-
getType
Returns the type for this filter.- Returns:
- the type for this filter
-
includeDeleted
Check if deleted resources should be filtered.- Returns:
- true if deleted resources should be included, false otherwise
-
isValid
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 contextresource
- the resource to be validated- Returns:
- true if the resource passes all validations, false otherwise
-
requireFlags
Returns if the stored flags is required while filtering resources.- Returns:
- if the flags is required
-
requireState
Returns if the stored state is required while filtering resources.- Returns:
- if the state is required
-
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
Returns if the stored type is required while filtering resources.- Returns:
- true if the type is required
-
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
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.
-
addExcludeType(I_CmsResourceType)
instead.