Class CmsJspResourceWrapper

java.lang.Object
org.opencms.file.CmsResource
org.opencms.jsp.CmsJspResourceWrapper
All Implemented Interfaces:
Serializable, Cloneable, Comparable<I_CmsResource>, I_CmsResource

public class CmsJspResourceWrapper extends CmsResource
Wrapper subclass of CmsResource with some convenience methods.

See Also:
  • Field Details

  • Method Details

    • wrap

      public static CmsJspResourceWrapper wrap(CmsObject cms, CmsResource res)
      Factory method to create a new CmsJspResourceWrapper instance from a CmsResource.

      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 context
      res - the resource to wrap
      Returns:
      a new instance of a CmsJspResourceWrapper
    • equals

      public boolean equals(Object obj)
      Two resources are considered equal in case their structure id is equal.

      Overrides:
      equals in class CmsResource
      See Also:
    • getCategories

      Returns the categories assigned to this resource.

      Returns:
      the categories assigned to this resource
    • getCmsObject

      Returns the OpenCms user context this resource was initialized with.

      Returns:
      the OpenCms user context this resource was initialized with
    • getContent

      public String getContent()
      Returns the content of the file as a String.

      Returns:
      the content of the file as a String
    • getExtension

      public 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:
    • getFile

      public CmsFile getFile()
      Returns the full file object for this resource.

      Returns:
      the full file object for this resource
    • getFolder

      Returns the folder of this resource.

      In case this resource already is a CmsFolder, it is returned without modification. In case it is a CmsFile, the parent folder of the file is returned.

      Returns:
      the folder of this resource
      See Also:
    • getIncomingRelations

      Gets a list of resource wrappers for resources with relations pointing to this resource.
      Returns:
      the list of resource wrappers
    • getIncomingRelations

      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()
      Returns true 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()
      Returns true in case this resource is an XML content.

      Returns:
      true in case this resource is an XML content
    • getLink

      public String getLink()
      Returns a substituted link to this resource.

      Returns:
      the link
    • 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

      Returns the main locale for this resource.

      Returns:
      the main locale for this resource
    • getMimeType

      public 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

      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

      Returns the navigation info element for this resource.

      Returns:
      the navigation info element for this resource
    • 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:

      1. the CmsPropertyDefinition.PROPERTY_DEFAULT_FILE is checked, and
      2. 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
      3. if still no file could be found, null is returned
      Returns:
      the default file for the given folder
      See Also:
    • 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

      Returns the substituted online link to this resource.

      Returns:
      the link
    • getOutgoingRelations

      Gets a list of resources with relations pointing to them from this resources, as resource wrappers.
      Returns:
      the list of resource wrappers
    • getOutgoingRelations

      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

      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:
    • 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

      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
    • getPropertyDescription

      Returns the locale specific evaluated "Description" property for the resource. In case the resource is a default file, also the parent folders "Description" property is read as fallback.
      Returns:
      the locale specific description property for the resource.
    • getPropertyKeywords

      Returns the locale specific evaluated "Keywords" property for the resource. In case the resource is a default file, also the parent folders "Keywords" property is read as fallback.
      Returns:
      the locale specific description property for the resource.
    • 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

      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

      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

      Returns the OpenCms user request context this resource was initialized with.

      Returns:
      the OpenCms user request context this resource was initialized with
    • 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:
    • 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:
    • 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 a CmsFile, 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:
    • 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:
    • getSitePath

      public String getSitePath()
      Returns the current site path to this resource.

      Returns:
      the current site path to this resource
      See Also:
    • 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 a CmsFile, 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:
    • 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:
    • 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

      Returns this resource wrapper.

      This is included because in case CmsJspStandardContextBean.getWrap() is used, the result may be either a CmsJspObjectValueWrapper or a CmsJspResourceWrapper. Using getToResource() on the result will always return a resource wrapper this way.

      Returns:
      this resource wrapper
      See Also:
    • 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:
    • getTypeName

      public String getTypeName()
      Returns the resource type name.

      Returns:
      the resource type name
    • 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:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class CmsResource
      See Also:
    • isChildResourceOf

      public boolean isChildResourceOf(CmsResource resource)
      Returns true 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(String sitePath)
      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.

      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
    • isNavigationDefaultFile

      public boolean isNavigationDefaultFile()
    • isParentFolderOf

      public boolean isParentFolderOf(CmsResource resource)
      Returns true 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(String sitePath)
      Returns true 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