Class CmsResourceUtil
CmsResource
utility functions.This class provides in java all resource information used by the explorer view, mostly generated in javascript (see explorer.js)
- Since:
- 6.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Enumeration class for defining the resource project state. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Layout style for resources after expire date.static final int
Layout style for resources before release date.static final int
Layout style for resources after release date and before expire date.static final org.opencms.workplace.explorer.CmsResourceUtil.CmsResourceUtilSiteMode
Constant that signalizes that all path operations will be based on the current site.static final org.opencms.workplace.explorer.CmsResourceUtil.CmsResourceUtilSiteMode
Constant that signalizes that all path operations will be based on the best matching site.static final org.opencms.workplace.explorer.CmsResourceUtil.CmsResourceUtilSiteMode
Constant that signalizes that all path operations will be based on the root path.static final CmsResourceUtil.CmsResourceProjectState
Constant for the project state locked for publishing.static final CmsResourceUtil.CmsResourceProjectState
Constant for the project state locked in current project.static final CmsResourceUtil.CmsResourceProjectState
Constant for the project state locked in other project. -
Constructor Summary
ConstructorDescriptionCmsResourceUtil
(CmsObject cms) Creates a newCmsResourceUtil
object.CmsResourceUtil
(CmsObject cms, CmsResource resource) Creates a newCmsResourceUtil
object.CmsResourceUtil
(CmsResource resource) Creates a newCmsResourceUtil
object. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the path abbreviation length.com.vaadin.server.Resource
Returns the big icon resource of the current resource.static com.vaadin.server.Resource
getBigIconResource
(CmsExplorerTypeSettings explorerType, String resourceName) Returns the big icon resource for the given resource.getCms()
Returns the cms context.Returns the formatted date of expiration.Returns the formatted date of release.Returns the path of the current resource, taking into account just the site mode.getGalleryDescription
(Locale locale) Returns the gallery description of the current resource.getGalleryTitle
(Locale locale) Returns the gallery title of the current resource.Returns the resource icon path displayed in the explorer view for the given resource.Returns the lock icon path for the given resource.Returns the project state icon path for the given resource.Returns the resource type icon path for the given resource.int
Returns an integer representation for the link type.getLock()
Returns the the lock for the given resource.Returns the user name who owns the lock for the given resource.Returns the id of the project in which the given resource is locked.Returns the project name that locked the current resource's.int
Returns the lock state of the current resource.Returns the navtext of a resource.getNoEditReason
(Locale locale) Checks is the current resource can be edited by the current user.getNoEditReason
(Locale locale, boolean ignoreExpiration) Checks is the current resource can be edited by the current user.getPath()
Returns the path of the current resource.Returns the permission set for the given resource.Returns the permissions string for the given resource.Returns the id of the project which the resource belongs to.Returns the project state of the given resource.Returns the project to use to check project state.Returns the 'relative to' path.Returns the resource.Returns the resource type for the given resource.int
Returns the resource type id for the given resource.Returns the resource type name for the given resource.getSearchResult
(Locale locale) Returns the SOLR search result for the current resource.getSite()
Returns the site of the current resources, taking into account the set site mode.org.opencms.workplace.explorer.CmsResourceUtil.CmsResourceUtilSiteMode
Returns the site mode.Returns the title of the site.Returns the size of the given resource as a String.com.vaadin.server.Resource
Returns the small icon resource of the current resource.static com.vaadin.server.Resource
getSmallIconResource
(CmsExplorerTypeSettings explorerType, String resourceName) Returns the small icon resource for the given resource.char
Returns resource state abbreviation.Returns the state name for a resource.Returns the style class to use for the given resource.Returns additional style sheets for the resource type icon depending on siblings.getSystemLockInfo
(boolean forExplorer) Returns the system lock information tooltip for the explorer view.Returns additional style sheets depending on publication constraints.int
Returns the layout style for the current time window state.getTitle()
Returns the title of a resource.Returns the name of the user who created the given resource.Returns the name of the user who last modified the given resource.boolean
Returnstrue
if the given resource is editable by the current user.boolean
Returnstrue
if the given resource is in the reference project.boolean
Returnstrue
if the stored resource has been released and has not expired.void
setAbbrevLength
(int abbrevLength) Sets the path abbreviation length.void
Sets the cms context.void
setReferenceProject
(CmsProject project) Sets the project to use to check project state.void
setRelativeTo
(String relativeTo) Sets the 'relative to' path.void
setResource
(CmsResource resource) Sets the resource.void
setSiteMode
(org.opencms.workplace.explorer.CmsResourceUtil.CmsResourceUtilSiteMode siteMode) Sets the site mode.
-
Field Details
-
LAYOUTSTYLE_AFTEREXPIRE
Layout style for resources after expire date.- See Also:
-
LAYOUTSTYLE_BEFORERELEASE
Layout style for resources before release date.- See Also:
-
LAYOUTSTYLE_INRANGE
Layout style for resources after release date and before expire date.- See Also:
-
SITE_MODE_CURRENT
public static final org.opencms.workplace.explorer.CmsResourceUtil.CmsResourceUtilSiteMode SITE_MODE_CURRENTConstant that signalizes that all path operations will be based on the current site. -
SITE_MODE_MATCHING
public static final org.opencms.workplace.explorer.CmsResourceUtil.CmsResourceUtilSiteMode SITE_MODE_MATCHINGConstant that signalizes that all path operations will be based on the best matching site. -
SITE_MODE_ROOT
public static final org.opencms.workplace.explorer.CmsResourceUtil.CmsResourceUtilSiteMode SITE_MODE_ROOTConstant that signalizes that all path operations will be based on the root path. -
STATE_LOCKED_FOR_PUBLISHING
Constant for the project state locked for publishing. -
STATE_MODIFIED_IN_CURRENT_PROJECT
Constant for the project state locked in current project. -
STATE_MODIFIED_IN_OTHER_PROJECT
Constant for the project state locked in other project.
-
-
Constructor Details
-
CmsResourceUtil
Creates a newCmsResourceUtil
object.- Parameters:
cms
- the cms context
-
CmsResourceUtil
Creates a newCmsResourceUtil
object.- Parameters:
cms
- the cms contextresource
- the resource
-
CmsResourceUtil
Creates a newCmsResourceUtil
object.- Parameters:
resource
- the resource
-
-
Method Details
-
getBigIconResource
public static com.vaadin.server.Resource getBigIconResource(CmsExplorerTypeSettings explorerType, String resourceName) Returns the big icon resource for the given resource.- Parameters:
explorerType
- the resource explorer type settingsresourceName
- the resource name- Returns:
- the icon resource
-
getSmallIconResource
public static com.vaadin.server.Resource getSmallIconResource(CmsExplorerTypeSettings explorerType, String resourceName) Returns the small icon resource for the given resource.- Parameters:
explorerType
- the resource explorer type settingsresourceName
- the resource name- Returns:
- the icon resource
-
getAbbrevLength
Returns the path abbreviation length.If greater than zero, the path will be formatted to this number of chars.
This only affects the generation of the path for the current resource.
- Returns:
- the path abbreviation Length
-
getBigIconResource
Returns the big icon resource of the current resource.- Returns:
- the icon resource
-
getCms
Returns the cms context.- Returns:
- the cms context
-
getDateExpired
Returns the formatted date of expiration.- Returns:
- the formatted date of expiration
-
getDateReleased
Returns the formatted date of release.- Returns:
- the formatted date of release
-
getFullPath
Returns the path of the current resource, taking into account just the site mode.- Returns:
- the full path
-
getGalleryDescription
Returns the gallery description of the current resource.- Parameters:
locale
- the content locale- Returns:
- the gallery description
-
getGalleryTitle
Returns the gallery title of the current resource.- Parameters:
locale
- the content locale- Returns:
- the gallery title
-
getIconPathExplorer
Returns the resource icon path displayed in the explorer view for the given resource.Relative to
/system/workplace/resources/
.If the resource has no sibling it is the same as
getIconPathResourceType()
.- Returns:
- the resource icon path displayed in the explorer view for the given resource
- See Also:
-
getIconPathLock
Returns the lock icon path for the given resource.Relative to
/system/workplace/resources/
.Returns
explorer/project_none.gif
if request context isnull
.- Returns:
- the lock icon path for the given resource
-
getIconPathProjectState
Returns the project state icon path for the given resource.Relative to
/system/workplace/resources/
.- Returns:
- the project state icon path for the given resource
-
getIconPathResourceType
Returns the resource type icon path for the given resource.Relative to
/system/workplace/resources/
.- Returns:
- the resource type icon path for the given resource
-
getLinkType
Returns an integer representation for the link type.0
: No sibling1
: Sibling2
: Labeled sibling
- Returns:
- an integer representation for the link type
-
getLock
Returns the the lock for the given resource.- Returns:
- the lock the given resource
-
getLockedByName
Returns the user name who owns the lock for the given resource.- Returns:
- the user name who owns the lock for the given resource
-
getLockedInProjectId
Returns the id of the project in which the given resource is locked.- Returns:
- the id of the project in which the given resource is locked
-
getLockedInProjectName
Returns the project name that locked the current resource's.- Returns:
- the the project name that locked the current resource's
-
getLockState
Returns the lock state of the current resource.- Returns:
- the lock state of the current resource
-
getNoEditReason
Checks is the current resource can be edited by the current user.- Parameters:
locale
- the locale to use for the messages- Returns:
- an empty string if editable, or a localized string with the reason
- Throws:
CmsException
- if something goes wrong
-
getNoEditReason
Checks is the current resource can be edited by the current user.- Parameters:
locale
- the locale to use for the messagesignoreExpiration
-true
to ignore resource release and expiration date- Returns:
- an empty string if editable, or a localized string with the reason
- Throws:
CmsException
- if something goes wrong
-
getPath
Returns the path of the current resource.Taking into account following settings:
- site mode
- abbreviation length
- relative to
- Returns:
- the path
-
getPermissionSet
Returns the permission set for the given resource.- Returns:
- the permission set for the given resource
-
getPermissionString
Returns the permissions string for the given resource.- Returns:
- the permissions string for the given resource
-
getProjectId
Returns the id of the project which the resource belongs to.- Returns:
- the id of the project which the resource belongs to
-
getProjectState
Returns the project state of the given resource.- null: unchanged.
- true: locked in current project.
- false: not locked in current project.
- Returns:
- the project state of the given resource
-
getReferenceProject
Returns the project to use to check project state.- Returns:
- the project to use to check project state
-
getRelativeTo
Returns the 'relative to' path.This only affects the generation of the path for the current resource.
- Returns:
- the 'relative to' path
-
getResource
Returns the resource.- Returns:
- the resource
-
getResourceType
Returns the resource type for the given resource.- Returns:
- the resource type for the given resource
-
getResourceTypeId
Returns the resource type id for the given resource.- Returns:
- the resource type id for the given resource
-
getResourceTypeName
Returns the resource type name for the given resource.- Returns:
- the resource type name for the given resource
-
getSearchResult
Returns the SOLR search result for the current resource.- Parameters:
locale
- the content locale- Returns:
- the search result
-
getSite
Returns the site of the current resources, taking into account the set site mode.- Returns:
- the site path
-
getSiteMode
Returns the site mode.This only affects the generation of the path for the current resource.
- Returns:
- the site mode
-
getSiteTitle
Returns the title of the site.- Returns:
- the title of the site
-
getSizeString
Returns the size of the given resource as a String.For directories it returns
SIZE_DIR
.- Returns:
- the size of the given resource as a String
-
getSmallIconResource
Returns the small icon resource of the current resource.- Returns:
- the icon resource
-
getStateAbbreviation
Returns resource state abbreviation.- Returns:
- resource state abbreviation
-
getStateName
Returns the state name for a resource.Uses default locale if request context is
null
.- Returns:
- the state name for that resource
-
getStyleClassName
Returns the style class to use for the given resource.- Returns:
- style class name
- See Also:
-
CmsListExplorerColumn.getExplorerStyleDef()
-
getStyleSiblings
Returns additional style sheets for the resource type icon depending on siblings.That is, depending on
CmsResource.getSiblingCount()
Use it with thegetIconPathExplorer()
method.- Returns:
- additional style sheets depending on siblings
-
getSystemLockInfo
Returns the system lock information tooltip for the explorer view.- Parameters:
forExplorer
- if the tool tip should be generated for the explorer view- Returns:
- the system lock information tooltip
-
getTimeWindowLayoutStyle
Returns additional style sheets depending on publication constraints.That is, depending on
CmsResource.getDateReleased()
andCmsResource.getDateExpired()
.- Returns:
- additional style sheets depending on publication constraints
- See Also:
-
getTimeWindowLayoutType
Returns the layout style for the current time window state.
: The time window is in rangeLAYOUTSTYLE_INRANGE
: The resource is not yet releasedLAYOUTSTYLE_BEFORERELEASE
: The resource has already expiredLAYOUTSTYLE_AFTEREXPIRE
- Returns:
- the layout style for the current time window state
- See Also:
-
getTitle
Returns the title of a resource.- Returns:
- the title for that resource
-
getUserCreated
Returns the name of the user who created the given resource.- Returns:
- the name of the user who created the given resource
-
getUserLastModified
Returns the name of the user who last modified the given resource.- Returns:
- the name of the user who last modified the given resource
-
isEditable
Returnstrue
if the given resource is editable by the current user.Returns
false
if no request context is set.- Returns:
true
if the given resource is editable by the current user
-
isInsideProject
Returnstrue
if the given resource is in the reference project.Returns
false
if the request context isnull
.- Returns:
true
if the given resource is in the reference project- See Also:
-
isReleasedAndNotExpired
Returnstrue
if the stored resource has been released and has not expired.If no request context is available, the current time is used for the validation check.
- Returns:
true
if the stored resource has been released and has not expired- See Also:
-
setAbbrevLength
Sets the path abbreviation length.If greater than zero, the path will be formatted to this number of chars.
This only affects the generation of the path for the current resource.
- Parameters:
abbrevLength
- the path abbreviation length to set
-
setCms
Sets the cms context.- Parameters:
cms
- the cms context to set
-
setReferenceProject
Sets the project to use to check project state.- Parameters:
project
- the project to set
-
setRelativeTo
Sets the 'relative to' path.This only affects the generation of the path for the current resource.
- Parameters:
relativeTo
- the 'relative to' path to set
-
setResource
Sets the resource.- Parameters:
resource
- the resource to set
-
setSiteMode
public void setSiteMode(org.opencms.workplace.explorer.CmsResourceUtil.CmsResourceUtilSiteMode siteMode) Sets the site mode.This only affects the generation of the path for the current resource.
- Parameters:
siteMode
- the site mode to set
-