Class CmsJspResourceWrapper
- java.lang.Object
-
- org.opencms.file.CmsResource
-
- org.opencms.jsp.CmsJspResourceWrapper
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<I_CmsResource>
,I_CmsResource
public class CmsJspResourceWrapper extends CmsResource
Wrapper subclass of CmsResource with some convenience methods.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opencms.file.CmsResource
CmsResource.CmsResourceCopyMode, CmsResource.CmsResourceDeleteMode, CmsResource.CmsResourceUndoMode
-
Nested classes/interfaces inherited from interface org.opencms.file.I_CmsResource
I_CmsResource.CmsResourceAttribute
-
-
Field Summary
Fields Modifier and Type Field Description java.util.List<CmsJspResourceWrapper>
m_incomingRelations
All resources that are sources of incoming relations.java.util.List<CmsJspResourceWrapper>
m_outgoingRelations
All resources that are targets of outgoing relations.java.util.List<CmsJspResourceWrapper>
m_parentFolders
All parent folder of this resource in the current site as a list.static boolean
RELATIONS_IN
Parameter value used to select incoming relations.static boolean
RELATIONS_OUT
Parameter value used to select outgoing relations.-
Fields inherited from class org.opencms.file.CmsResource
COPY_AS_NEW, COPY_AS_SIBLING, COPY_PRESERVE_SIBLING, DATE_EXPIRED_DEFAULT, DATE_RELEASED_DEFAULT, DATE_RELEASED_EXPIRED_IGNORE, DELETE_PRESERVE_SIBLINGS, DELETE_REMOVE_SIBLINGS, FLAG_INTERNAL, FLAG_LABELED, FLAG_TEMPFILE, m_dateContent, m_length, NAME_CONSTRAINTS, STATE_CHANGED, STATE_DELETED, STATE_KEEP, STATE_NEW, STATE_UNCHANGED, TEMP_FILE_PREFIX, TOUCH_DATE_UNCHANGED, UNDO_CONTENT, UNDO_CONTENT_RECURSIVE, UNDO_MOVE_CONTENT, UNDO_MOVE_CONTENT_RECURSIVE, VFS_FOLDER_SITES, VFS_FOLDER_SYSTEM
-
Fields inherited from interface org.opencms.file.I_CmsResource
COMPARE_DATE_LAST_MODIFIED, COMPARE_DATE_RELEASED, COMPARE_ROOT_PATH, COMPARE_ROOT_PATH_IGNORE_CASE, COMPARE_ROOT_PATH_IGNORE_CASE_FOLDERS_FIRST
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Two resources are considered equal in case their structure id is equal.CmsJspCategoryAccessBean
getCategories()
Returns the categories assigned to this resource.CmsObject
getCmsObject()
Returns the OpenCms user context this resource was initialized with.java.lang.String
getContent()
Returns the content of the file as a String.java.lang.String
getExtension()
Returns this resources name extension (if present).CmsFile
getFile()
Returns the full file object for this resource.CmsJspResourceWrapper
getFolder()
Returns the folder of this resource.java.util.List<CmsJspResourceWrapper>
getIncomingRelations()
Gets a list of resource wrappers for resources with relations pointing to this resource.java.util.List<CmsJspResourceWrapper>
getIncomingRelations(java.lang.String typeName)
Gets a list of resource wrappers for resources with relations pointing to this resource, for a specific type.boolean
getIsImage()
Returnstrue
in case this resource is an image in the VFS.boolean
getIsXml()
Returnstrue
in case this resource is an XML content.java.lang.String
getLink()
Returns a substituted link to this resource.java.util.Map<java.lang.String,CmsJspResourceWrapper>
getLocaleResource()
Returns a map of the locale group for the current resource, with locale strings as keys.java.util.Locale
getMainLocale()
Returns the main locale for this resource.java.lang.String
getMimeType()
Returns the mime type for this resource.CmsJspNavBuilder
getNavBuilder()
Returns the navigation builder for this resource.CmsJspNavElement
getNavigation()
Returns the navigation info element for this resource.CmsJspResourceWrapper
getNavigationDefaultFile()
Returns the default resource for this resource.java.util.List<CmsJspNavElement>
getNavigationForFolder()
Returns the navigation info elements in this resource, assuming that this resource is a folder.java.lang.String
getOnlineLink()
Returns the substituted online link to this resource.java.util.List<CmsJspResourceWrapper>
getOutgoingRelations()
Gets a list of resources with relations pointing to them from this resources, as resource wrappers.java.util.List<CmsJspResourceWrapper>
getOutgoingRelations(java.lang.String typeName)
Gets a list of resources with relations pointing to them from this resources, as resource wrappers.CmsJspResourceWrapper
getParentFolder()
Returns the parent folder of this resource in the current site.java.util.List<CmsJspResourceWrapper>
getParentFolders()
Returns all parent folder of this resource in the current site as a list.java.util.Map<java.lang.String,java.lang.String>
getProperty()
Returns the direct properties of this resource in a map.java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
getPropertyLocale()
Returns the direct properties of this resource in a map for a given locale.java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
getPropertyLocaleSearch()
Returns the searched properties of this resource in a map for a given locale.java.util.Map<java.lang.String,java.lang.String>
getPropertySearch()
Returns the searched properties of this resource in a map.CmsRequestContext
getRequestContext()
Returns the OpenCms user request context this resource was initialized with.java.lang.String
getResourceExtension()
Returns this resources name extension (if present).java.lang.String
getResourceName()
Returns the name of this resource without the path information.java.lang.String
getRootPathFolder()
Returns the folder name of this resource from the root site.int
getRootPathLevel()
Returns the directory level of a resource from the root site.java.lang.String
getRootPathParentFolder()
Returns the parent folder of this resource from the root site.java.lang.String
getSitePath()
Returns the current site path to this resource.java.lang.String
getSitePathFolder()
Returns the folder name of this resource in the current site.int
getSitePathLevel()
Returns the directory level of a resource in the current site.java.lang.String
getSitePathParentFolder()
Returns the parent folder of this resource in the current site.CmsJspImageBean
getToImage()
Returns a scaled image bean from the wrapped value.CmsJspResourceWrapper
getToResource()
Returns this resource wrapper.CmsJspContentAccessBean
getToXml()
Returns an XML content access bean created for this resource.java.lang.String
getTypeName()
Returns the resource type name.CmsJspContentAccessBean
getXml()
Returns an XML content access bean created for this resource.int
hashCode()
boolean
isChildResourceOf(java.lang.String sitePath)
Returnstrue
in case this resource is child resource of the provided resource path which is assumed to be a folder in the current site.boolean
isChildResourceOf(CmsResource resource)
Returnstrue
in case this resource is child resource of the provided resource which is assumed to be a folder.boolean
isParentFolderOf(java.lang.String sitePath)
Returnstrue
in case this resource is a parent folder of the provided resource path in the current site.boolean
isParentFolderOf(CmsResource resource)
Returnstrue
in case this resource is a parent folder of the provided resource.static CmsJspResourceWrapper
wrap(CmsObject cms, CmsResource res)
Factory method to create a newCmsJspResourceWrapper
instance from aCmsResource
.-
Methods inherited from class org.opencms.file.CmsResource
checkResourceName, clone, compareTo, getCopy, getDateContent, getDateCreated, getDateExpired, getDateLastModified, getDateReleased, getExtension, getFlags, getFolderPath, getLength, getName, getName, getParentFolder, getPathLevel, getPathPart, getProjectLastModified, getResourceId, getRootPath, getSiblingCount, getState, getStructureId, getTypeId, getUserCreated, getUserLastModified, getVersion, isExpired, isFile, isFolder, isFolder, isInternal, isInternalOrInInternalFolder, isLabeled, isReleased, isReleasedAndNotExpired, isTemporaryFile, isTemporaryFileName, isTouched, setDateExpired, setDateLastModified, setDateReleased, setFlags, setInternal, setState, setType, setUserLastModified, toString
-
-
-
-
Field Detail
-
RELATIONS_OUT
public static final boolean RELATIONS_OUT
Parameter value used to select outgoing relations.- See Also:
- Constant Field Values
-
RELATIONS_IN
public static final boolean RELATIONS_IN
Parameter value used to select incoming relations.- See Also:
- Constant Field Values
-
m_incomingRelations
public java.util.List<CmsJspResourceWrapper> m_incomingRelations
All resources that are sources of incoming relations.
-
m_outgoingRelations
public java.util.List<CmsJspResourceWrapper> m_outgoingRelations
All resources that are targets of outgoing relations.
-
m_parentFolders
public java.util.List<CmsJspResourceWrapper> m_parentFolders
All parent folder of this resource in the current site as a list.
-
-
Method Detail
-
wrap
public static CmsJspResourceWrapper wrap(CmsObject cms, CmsResource res)
Factory method to create a newCmsJspResourceWrapper
instance from aCmsResource
.In case the parameter resource already is a wrapped resource AND the OpenCms request context is the same as the provided context, the parameter object is returned.
- Parameters:
cms
- the current CMS contextres
- the resource to wrap- Returns:
- a new instance of a
CmsJspResourceWrapper
-
equals
public boolean equals(java.lang.Object obj)
Two resources are considered equal in case their structure id is equal.- Overrides:
equals
in classCmsResource
- See Also:
CmsResource.equals(java.lang.Object)
-
getCategories
public CmsJspCategoryAccessBean getCategories()
Returns the categories assigned to this resource.- Returns:
- the categories assigned to this resource
-
getCmsObject
public CmsObject getCmsObject()
Returns the OpenCms user context this resource was initialized with.- Returns:
- the OpenCms user context this resource was initialized with
-
getContent
public java.lang.String getContent()
Returns the content of the file as a String.- Returns:
- the content of the file as a String
-
getExtension
public java.lang.String getExtension()
Returns this resources name extension (if present).The extension will always be lower case.
- Returns:
- the extension or
null
if not available - See Also:
CmsResource.getExtension(String)
,CmsJspVfsAccessBean.getResourceExtension(Object)
-
getFile
public CmsFile getFile()
Returns the full file object for this resource.- Returns:
- the full file object for this resource
-
getFolder
public CmsJspResourceWrapper getFolder()
Returns the folder of this resource.In case this resource already is a
CmsFolder
, it is returned without modification. In case it is aCmsFile
, the parent folder of the file is returned.- Returns:
- the folder of this resource
- See Also:
getSitePathFolder()
-
getIncomingRelations
public java.util.List<CmsJspResourceWrapper> getIncomingRelations()
Gets a list of resource wrappers for resources with relations pointing to this resource.- Returns:
- the list of resource wrappers
-
getIncomingRelations
public java.util.List<CmsJspResourceWrapper> getIncomingRelations(java.lang.String typeName)
Gets a list of resource wrappers for resources with relations pointing to this resource, for a specific type.- Parameters:
typeName
- name of the type to filter- Returns:
- the list of resource wrappers
-
getIsImage
public boolean getIsImage()
Returnstrue
in case this resource is an image in the VFS.- Returns:
true
in case this resource is an image in the VFS
-
getIsXml
public boolean getIsXml()
Returnstrue
in case this resource is an XML content.- Returns:
true
in case this resource is an XML content
-
getLink
public java.lang.String getLink()
Returns a substituted link to this resource.- Returns:
- the link
-
getLocaleResource
public java.util.Map<java.lang.String,CmsJspResourceWrapper> getLocaleResource()
Returns a map of the locale group for the current resource, with locale strings as keys.- Returns:
- a map with locale strings as keys and resource wrappers for the corresponding locale variants
-
getMainLocale
public java.util.Locale getMainLocale()
Returns the main locale for this resource.- Returns:
- the main locale for this resource
-
getMimeType
public java.lang.String getMimeType()
Returns the mime type for this resource.In case no valid mime type can be determined from the file extension,
text/plain
is returned.- Returns:
- the mime type for this resource
-
getNavBuilder
public CmsJspNavBuilder getNavBuilder()
Returns the navigation builder for this resource.This will be initialized with this resource as default URI.
- Returns:
- the navigation builder for this resource
-
getNavigation
public CmsJspNavElement getNavigation()
Returns the navigation info element for this resource.- Returns:
- the navigation info element for this resource
-
getNavigationDefaultFile
public CmsJspResourceWrapper getNavigationDefaultFile()
Returns the default resource for this resource.If this resource is a file, then this file is returned.
Otherwise, in case this resource is a folder:
- the
CmsPropertyDefinition.PROPERTY_DEFAULT_FILE
is checked, and - if still no file could be found, the configured default files in the
opencms-vfs.xml
configuration are iterated until a match is found, and - if still no file could be found,
null
is returned
- Returns:
- the default file for the given folder
- See Also:
CmsObject.readDefaultFile(CmsResource, CmsResourceFilter)
- the
-
getNavigationForFolder
public java.util.List<CmsJspNavElement> getNavigationForFolder()
Returns the navigation info elements in this resource, assuming that this resource is a folder.- Returns:
- the navigation info elements in this resource, assuming that this resource is a folder
-
getOnlineLink
public java.lang.String getOnlineLink()
Returns the substituted online link to this resource.- Returns:
- the link
-
getOutgoingRelations
public java.util.List<CmsJspResourceWrapper> getOutgoingRelations()
Gets a list of resources with relations pointing to them from this resources, as resource wrappers.- Returns:
- the list of resource wrappers
-
getOutgoingRelations
public java.util.List<CmsJspResourceWrapper> getOutgoingRelations(java.lang.String typeName)
Gets a list of resources with relations pointing to them from this resources, as resource wrappers. Only gets resources with the given type.- Parameters:
typeName
- the name of the type to filter- Returns:
- the list of resource wrappers
-
getParentFolder
public CmsJspResourceWrapper getParentFolder()
Returns the parent folder of this resource in the current site.The parent folder of a file is the folder of the file. The parent folder of a folder is the parent folder of the folder. The parent folder of the root folder is
null
.- Returns:
- the parent folder of this resource in the current site
- See Also:
getSitePathParentFolder()
,CmsResource.getParentFolder(String)
,CmsJspVfsAccessBean.getParentFolder(Object)
-
getParentFolders
public java.util.List<CmsJspResourceWrapper> getParentFolders()
Returns all parent folder of this resource in the current site as a list.First resource in the list will be the direct parent folder of this resource, the last element will be the site root folder.
- Returns:
- all parent folder of this resource in the current site as a list
-
getProperty
public java.util.Map<java.lang.String,java.lang.String> getProperty()
Returns the direct properties of this resource in a map.This is without "search", so it will not include inherited properties from the parent folders.
- Returns:
- the direct properties of this resource in a map
-
getPropertyLocale
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getPropertyLocale()
Returns the direct properties of this resource in a map for a given locale.This is without "search", so it will not include inherited properties from the parent folders.
- Returns:
- the direct properties of this resource in a map for a given locale
-
getPropertyLocaleSearch
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getPropertyLocaleSearch()
Returns the searched properties of this resource in a map for a given locale.This is with "search", so it will include inherited properties from the parent folders.
- Returns:
- the direct properties of this resource in a map for a given locale
-
getPropertySearch
public java.util.Map<java.lang.String,java.lang.String> getPropertySearch()
Returns the searched properties of this resource in a map.This is with "search", so it will include inherited properties from the parent folders.
- Returns:
- the direct properties of this resource in a map
-
getRequestContext
public CmsRequestContext getRequestContext()
Returns the OpenCms user request context this resource was initialized with.- Returns:
- the OpenCms user request context this resource was initialized with
-
getResourceExtension
public java.lang.String getResourceExtension()
Returns this resources name extension (if present).The extension will always be lower case.
- Returns:
- the extension or
null
if not available - See Also:
CmsResource.getExtension(String)
,CmsJspVfsAccessBean.getResourceExtension(Object)
-
getResourceName
public java.lang.String getResourceName()
Returns the name of this resource without the path information.The resource name of a file is the name of the file. The resource name of a folder is the folder name with trailing "/". The resource name of the root folder is
/
.- Returns:
- the name of this resource without the path information
- See Also:
CmsResource.getName()
,CmsJspVfsAccessBean.getResourceName(Object)
-
getRootPathFolder
public java.lang.String getRootPathFolder()
Returns the folder name of this resource from the root site.In case this resource already is a
CmsFolder
, the folder path is returned without modification. In case it is aCmsFile
, the parent folder name of the file is returned.- Returns:
- the folder name of this resource from the root site
-
getRootPathLevel
public int getRootPathLevel()
Returns the directory level of a resource from the root site.The root folder "/" has level 0, a folder "/foo/" would have level 1, a folder "/foo/bar/" level 2 etc.
- Returns:
- the directory level of a resource from the root site
- See Also:
CmsResource.getPathLevel(String)
-
getRootPathParentFolder
public java.lang.String getRootPathParentFolder()
Returns the parent folder of this resource from the root site.- Returns:
- the parent folder of this resource from the root site
- See Also:
CmsResource.getParentFolder(String)
-
getSitePath
public java.lang.String getSitePath()
Returns the current site path to this resource.- Returns:
- the current site path to this resource
- See Also:
CmsRequestContext.getSitePath(CmsResource)
-
getSitePathFolder
public java.lang.String getSitePathFolder()
Returns the folder name of this resource in the current site.In case this resource already is a
CmsFolder
, the folder path is returned without modification. In case it is aCmsFile
, the parent folder name of the file is returned.- Returns:
- the folder name of this resource in the current site
-
getSitePathLevel
public int getSitePathLevel()
Returns the directory level of a resource in the current site.The root folder "/" has level 0, a folder "/foo/" would have level 1, a folder "/foo/bar/" level 2 etc.
- Returns:
- the directory level of a resource in the current site
- See Also:
CmsResource.getPathLevel(String)
,CmsJspVfsAccessBean.getPathLevel(Object)
-
getSitePathParentFolder
public java.lang.String getSitePathParentFolder()
Returns the parent folder of this resource in the current site.The parent folder of a file is the folder of the file. The parent folder of a folder is the parent folder of the folder. The parent folder of the root folder is
null
.- Returns:
- the parent folder of this resource in the current site
- See Also:
CmsResource.getParentFolder(String)
,CmsJspVfsAccessBean.getParentFolder(Object)
-
getToImage
public CmsJspImageBean getToImage()
Returns a scaled image bean from the wrapped value.In case the value does not point to an image resource,
null
is returned.- Returns:
- the scaled image bean
-
getToResource
public CmsJspResourceWrapper getToResource()
Returns this resource wrapper.This is included because in case
CmsJspStandardContextBean.getWrap()
is used, the result may be either aCmsJspObjectValueWrapper
or aCmsJspResourceWrapper
. UsinggetToResource()
on the result will always return a resource wrapper this way.- Returns:
- this resource wrapper
- See Also:
CmsJspStandardContextBean.getWrap()
,CmsJspObjectValueWrapper.getToResource()
-
getToXml
public CmsJspContentAccessBean getToXml()
Returns an XML content access bean created for this resource.In case this resource is not an XML content,
null
is returned.- Returns:
- an XML content access bean created for this resource
- See Also:
getIsXml()
-
getTypeName
public java.lang.String getTypeName()
Returns the resource type name.- Returns:
- the resource type name
-
getXml
public CmsJspContentAccessBean getXml()
Returns an XML content access bean created for this resource.In case this resource is not an XML content,
null
is returned.- Returns:
- an XML content access bean created for this resource
- See Also:
getToXml()
,getIsXml()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classCmsResource
- See Also:
CmsResource.hashCode()
,Object.hashCode()
-
isChildResourceOf
public boolean isChildResourceOf(CmsResource resource)
Returnstrue
in case this resource is child resource of the provided resource which is assumed to be a folder.- Parameters:
resource
- the resource to check- Returns:
true
in case this resource is child resource of the provided resource which is assumed to be a folder
-
isChildResourceOf
public boolean isChildResourceOf(java.lang.String sitePath)
Returnstrue
in case this resource is child resource of the provided resource path which is assumed to be a folder in the current site.No check is performed to see if the provided site path resource actually exists.
- Parameters:
sitePath
- the resource to check- Returns:
true
in case this resource is child resource of the provided resource path which is assumed to be a folder in the current site
-
isParentFolderOf
public boolean isParentFolderOf(CmsResource resource)
Returnstrue
in case this resource is a parent folder of the provided resource.- Parameters:
resource
- the resource to check- Returns:
true
in case this resource is a parent folder of the provided resource
-
isParentFolderOf
public boolean isParentFolderOf(java.lang.String sitePath)
Returnstrue
in case this resource is a parent folder of the provided resource path in the current site.No check is performed to see if the provided site path resource actually exists.
- Parameters:
sitePath
- the path to check- Returns:
true
in case this resource is a parent folder of the provided resource path in the current site
-
-