public final class CmsJspVfsAccessBean extends java.lang.Object
CmsJspContentAccessBean
Modifier and Type | Class and Description |
---|---|
class |
CmsJspVfsAccessBean.CmsAvailableLocaleLoaderTransformer
Transformer that loads a resource from the OpenCms VFS,
the input is used as String for the resource name to read.
|
class |
CmsJspVfsAccessBean.CmsExistsResourceTransformer
Provides Booleans that indicate if a specified resource exists in the OpenCms VFS,
the input is used as String for the resource name to read.
|
class |
CmsJspVfsAccessBean.CmsExistsXmlTransformer
Provides Booleans that indicate if a specified resource exists in the OpenCms VFS
and is of type XML content or XML page,
the input is used as String for the resource name to read.
|
class |
CmsJspVfsAccessBean.CmsPermissionsLoaderTransformer
Transformer that loads a resource permission from the OpenCms VFS,
the input is used as String for the resource name to read the permissions for.
|
class |
CmsJspVfsAccessBean.CmsPropertyLoaderSingleTransformer
Transformer that a properties of a resource from the OpenCms VFS,
the input is used as String for the property name to read.
|
class |
CmsJspVfsAccessBean.CmsResourceLoaderTransformer
Transformer that loads a resource from the OpenCms VFS,
the input is used as String for the resource name to read.
|
class |
CmsJspVfsAccessBean.CmsResourceLocalePropertyLoaderTransformer
Transformer that loads properties of a resource from the OpenCms VFS with another lazy map,
the input is used as String for the resource name to read.
|
class |
CmsJspVfsAccessBean.CmsResourcePropertyLoaderTransformer
Transformer that loads properties of a resource from the OpenCms VFS with another lazy map,
the input is used as String for the resource name to read.
|
class |
CmsJspVfsAccessBean.CmsVfsLinkTransformer
Transformer that calculates links to resources in the OpenCms VFS,
the input is used as String for the resource name to use as link target.
|
class |
CmsJspVfsAccessBean.CmsXmlContentAccessTransformer
Provides XML content access beans for VFS resources.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTRIBUTE_VFS_ACCESS_BEAN
Request context attribute for indicating the model file for a create resource operation.
|
protected CmsObject |
m_cms
The OpenCms context of the current user.
|
Modifier and Type | Method and Description |
---|---|
static CmsJspVfsAccessBean |
create(CmsObject cms)
Creates a new instance of the JSP VFS access utility bean.
|
java.util.Map<java.lang.String,java.util.List<java.util.Locale>> |
getAvailableLocales()
Returns a lazily generated map from site paths of resources to the available locales for the resource.
|
CmsObject |
getCmsObject()
Returns the OpenCms user context this bean was initialized with.
|
CmsRequestContext |
getContext()
Short form for
getRequestContext() . |
CmsProject |
getCurrentProject()
Returns the current project from the context.
|
CmsUser |
getCurrentUser()
Returns the current user from the context.
|
java.util.Map<java.lang.String,java.lang.Boolean> |
getExists()
Short form for
getExistsResource() . |
java.util.Map<java.lang.String,java.lang.Boolean> |
getExistsResource()
Returns a map that lazily checks if a resources exists in the OpenCms VFS.
|
java.util.Map<java.lang.String,java.lang.Boolean> |
getExistsXml()
Returns a map that lazily checks if a resources exists in the VFS and is of type XML content or XML page.
|
boolean |
getFlushCaches()
Flushes the internal caches of this VFS access bean.
|
java.util.Map<java.lang.String,java.lang.String> |
getLink()
Returns a map that lazily calculates links to files in the OpenCms VFS,
which have been adjusted according to the web application path and the
OpenCms static export rules.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,CmsJspResourceWrapper>> |
getLocaleResource()
Gets a lazy loading map used to access locale variants of a resource with a given path.
|
java.util.Map<java.lang.String,java.util.Locale> |
getMainLocale()
Returns a lazy loading map used to detect the main locale of a resource which is part of a locale group.
|
java.lang.String |
getParentFolder(java.lang.Object obj)
Returns the parent folder of a resource.
|
int |
getPathLevel(java.lang.Object obj)
Returns the directory level of a resource.
|
java.util.Map<java.lang.String,CmsPermissionSet> |
getPermissions()
Short form for
getReadPermissions() . |
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getProperty()
Short form for
getReadProperties() . |
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>> |
getPropertyLocale()
Short form for
getReadPropertiesLocale() . |
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getPropertySearch()
Short form for
getReadPropertiesSearch() . |
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>> |
getPropertySearchLocale()
Short form for
getReadPropertiesSearchLocale() . |
java.util.Map<java.lang.String,CmsPermissionSet> |
getReadPermissions()
Returns a map that lazily reads resource permissions from the OpenCms VFS.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getReadProperties()
Returns a map that lazily reads all resource properties from the OpenCms VFS, without search.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>> |
getReadPropertiesLocale()
Returns a map that lazily reads all resource properties from the OpenCms VFS, without search.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getReadPropertiesSearch()
Returns a map that lazily reads all resource properties from the OpenCms VFS, with search.
|
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>> |
getReadPropertiesSearchLocale()
Returns a map that lazily reads all resource properties from the OpenCms VFS, with search and provides locale specific access to them.
|
java.util.Map<java.lang.String,CmsJspResourceWrapper> |
getReadResource()
Returns a map that lazily reads resources from the OpenCms VFS.
|
java.util.Map<java.lang.String,CmsJspContentAccessBean> |
getReadXml()
Returns a map that lazily reads XML documents from the OpenCms VFS that are wrapped using a
CmsJspContentAccessBean . |
CmsRequestContext |
getRequestContext()
Returns the OpenCms request context the current user this bean was initialized with.
|
java.util.Map<java.lang.String,CmsJspResourceWrapper> |
getResource()
Short form for
getReadResource() . |
java.lang.String |
getResourceExtension(java.lang.Object obj)
Returns the resource name extension if present.
|
java.lang.String |
getResourceName(java.lang.Object obj)
Returns the name of a resource without the path information.
|
java.util.Map<java.lang.String,CmsJspContentAccessBean> |
getXml()
Short form for
getReadXml() . |
java.util.List<CmsJspResourceWrapper> |
readFilesInFolder(java.lang.String resourcePath)
Reads the resources in the given folder.
|
java.util.List<CmsJspResourceWrapper> |
readFilesInFolder(java.lang.String resourcePath,
java.lang.String filterString)
Reads the resources in the given folder using the provided filter.
|
CmsJspResourceWrapper |
readSubsiteFor(java.lang.String path)
Reads the sub site folder resource.
|
public static final java.lang.String ATTRIBUTE_VFS_ACCESS_BEAN
public static CmsJspVfsAccessBean create(CmsObject cms)
To prevent multiple creations of the bean during a request, the OpenCms request context attributes are used to cache the created VFS access utility bean.
cms
- the current OpenCms user contextpublic java.util.Map<java.lang.String,java.util.List<java.util.Locale>> getAvailableLocales()
public CmsObject getCmsObject()
public CmsRequestContext getContext()
getRequestContext()
.Usage example on a JSP with the EL:
The current URI is: ${cms:vfs(pageContext).context.uri}
getRequestContext()
public CmsProject getCurrentProject()
Usage example on a JSP with the EL:
The current project name is: ${cms:vfs(pageContext).currentProject.name}
public CmsUser getCurrentUser()
Usage example on a JSP with the EL:
The current user name is: ${cms:vfs(pageContext).currentUser.name}
public java.util.Map<java.lang.String,java.lang.Boolean> getExists()
getExistsResource()
.Usage example on a JSP with the EL / JSTL:
<c:if test="${cms:vfs(pageContext).exists['/checkme.html']}" > The resource "/checkme.html" exists. </c:if>
getExistsResource()
public java.util.Map<java.lang.String,java.lang.Boolean> getExistsResource()
Usage example on a JSP with the EL / JSTL:
<c:if test="${cms:vfs(pageContext).existsResource['/checkme.html']}" > The resource "/checkme.html" exists. </c:if>Usage example on a JSP with the
<cms:contentaccess>
tag:<cms:contentload ... > <cms:contentaccess var="content" /> <c:if test="${content.vfs.existsResource['/checkme.html']}" > The resource "/checkme.html" exists. </c:if> </cms:contentload>
for a short form of this method
public java.util.Map<java.lang.String,java.lang.Boolean> getExistsXml()
Usage example on a JSP with the EL / JSTL:
<c:if test="${cms:vfs(pageContext).existsXml['/text.xml']}" > The resource "/text.xml" exists and is an XML document. </c:if>
public boolean getFlushCaches()
The VFS access bean uses lazy initialized Maps for all access, but once a value has been read it is cached in the Map and not read again from the VFS. This means the lazy Maps act as another layer of cache to the VFS.
The VFS access bean instance itself is cached in the OpenCms request context attributes of the CmsObject
,
see create(CmsObject)
. Normally there is a new CmsObject
created for
all incoming requests, so the live-time of the VFS access bean is short.
In that case the caching of the lazy Maps should improve performance and not be an issue.
However, in rare cases an instance of a CmsObject
may be kept for a long time in
some custom code. In theses cases flushing the caches of the lazy Maps manually may be required, otherwise
the Map caches may be out of sync with the VFS.
true
public java.util.Map<java.lang.String,java.lang.String> getLink()
Please note that the target is always assumed to be in the OpenCms VFS, so you can't use this method for links external to OpenCms.
Relative links are converted to absolute links, using the current element URI as base.
Relative links are converted to absolute links, using the current OpenCms request context URI as base.
Usage example on a JSP with the EL:
Link to the "/index.html" file: ${cms:vfs(pageContext).link['/index.html']}Usage example on a JSP with the
<cms:contentaccess>
tag:<cms:contentload ... > <cms:contentaccess var="content" /> Link to the "/index.html" file: ${content.vfs.link['/index.html']} </cms:contentload>
CmsJspActionElement.link(String)
,
CmsJspTagLink.linkTagAction(String, javax.servlet.ServletRequest)
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,CmsJspResourceWrapper>> getLocaleResource()
Usage in JSP: ${myvfsaccessbeaninstance.localeResource['/foo/bar/index.html']['de']}
public java.util.Map<java.lang.String,java.util.Locale> getMainLocale()
Usage in JSPs: ${myvfsaccessbeaninstance.mainLocale['/foo/index.html']}
public java.lang.String getParentFolder(java.lang.Object obj)
This assumes the parameter is either a CmsResource, or a String representing a file name. If the parameter is a CmsResource, the result will be relative to the current site.
obj
- a CmsResource or a String representing a resource nameCmsResource.getParentFolder(String)
,
CmsJspResourceWrapper.getSitePathParentFolder()
public int getPathLevel(java.lang.Object obj)
This assumes the parameter is either a CmsResource, or a String representing a file name. If the parameter is a CmsResource, the result will be relative to the current site.
The root folder "/" has level 0, a folder "/foo/" would have level 1, a folder "/foo/bar/" level 2 etc.obj
- a CmsResource or a String representing a resource nameCmsResource.getPathLevel(String)
,
CmsJspResourceWrapper.getSitePathLevel()
public java.util.Map<java.lang.String,CmsPermissionSet> getPermissions()
getReadPermissions()
.Usage example on a JSP with the EL:
Permission string of the "/index.html" resource: ${cms:vfs(pageContext).readPermissions['/index.html'].permissionString}Usage example on a JSP with the
<cms:contentaccess>
tag:<cms:contentload ... > <cms:contentaccess var="content" /> Permission string of the "/index.html" resource: ${content.vfs.readPermissions['/index.html'].permissionString} </cms:contentload>
getReadPermissions()
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getProperty()
getReadProperties()
.Usage example on a JSP with the EL:
Title property of the "/index.html" resource: ${cms:vfs(pageContext).property['/index.html']['Title']}
getReadProperties()
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>> getPropertyLocale()
getReadPropertiesLocale()
.Usage example on a JSP with the EL:
Title property of the "/index.html" resource for locale "de": ${cms:vfs(pageContext).property['/index.html']['de']['Title']}
getReadPropertiesLocale()
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getPropertySearch()
getReadPropertiesSearch()
.Usage example on a JSP with the EL:
Title property of the "/index.html" resource (searched): ${cms:vfs(pageContext).propertySearch['/index.html']['Title']}
getReadPropertiesSearch()
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>> getPropertySearchLocale()
getReadPropertiesSearchLocale()
.Usage example on a JSP with the EL:
Title property of the "/index.html" resource (searched) for locale "de": ${cms:vfs(pageContext).propertySearch['/index.html']['de']['Title']}
getReadPropertiesSearchLocale()
public java.util.Map<java.lang.String,CmsPermissionSet> getReadPermissions()
Usage example on a JSP with the EL:
Permission string of the "/index.html" resource: ${cms:vfs(pageContext).readPermissions['/index.html'].permissionString}Usage example on a JSP with the
<cms:contentaccess>
tag:<cms:contentload ... > <cms:contentaccess var="content" /> Permission string of the "/index.html" resource: ${content.vfs.readPermissions['/index.html'].permissionString} </cms:contentload>
for a short form of this method
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getReadProperties()
Usage example on a JSP with the EL:
Title property of the "/index.html" resource: ${cms:vfs(pageContext).readProperties['/index.html']['Title']}Usage example on a JSP with the
<cms:contentaccess>
tag:<cms:contentload ... > <cms:contentaccess var="content" /> Title property of the "/index.html" resource: ${content.vfs.readProperties['/index.html']['Title']} </cms:contentload>
for a short form of this method
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>> getReadPropertiesLocale()
Usage example on a JSP with the EL:
Title property of the "/index.html" resource for locale "de": ${cms:vfs(pageContext).readProperties['/index.html']['de']['Title']}Usage example on a JSP with the
<cms:contentaccess>
tag:<cms:contentload ... > <cms:contentaccess var="content" /> Title property of the "/index.html" resource: ${content.vfs.readProperties['/index.html']['Title']} </cms:contentload>
for a short form of this method
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getReadPropertiesSearch()
Usage example on a JSP with the EL:
Title property of the "/index.html" resource (searched): ${cms:vfs(pageContext).readPropertiesSearch['/index.html']['Title']}Usage example on a JSP with the
<cms:contentaccess>
tag:<cms:contentload ... > <cms:contentaccess var="content" /> Title property of the "/index.html" resource (searched): ${content.vfs.readPropertiesSearch['/index.html']['Title']} </cms:contentload>
for a short form of this method
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>> getReadPropertiesSearchLocale()
Usage example on a JSP with the EL:
Title property of the "/index.html" resource (searched): ${cms:vfs(pageContext).readPropertiesSearch['/index.html']['Title']}Usage example on a JSP with the
<cms:contentaccess>
tag:<cms:contentload ... > <cms:contentaccess var="content" /> Title property of the "/index.html" resource (searched) for locale "de": ${content.vfs.readPropertiesSearchLocale['/index.html']['de']['Title']} </cms:contentload>
for a short form of this method
public java.util.Map<java.lang.String,CmsJspResourceWrapper> getReadResource()
Usage example on a JSP with the EL:
Root path of the "/index.html" resource: ${cms:vfs(pageContext).readResource['/index.html'].rootPath}Usage example on a JSP with the
<cms:contentaccess>
tag:<cms:contentload ... > <cms:contentaccess var="content" /> Root path of the "/index.html" resource: ${content.vfs.readResource['/index.html'].rootPath} </cms:contentload>
for a short form of this method
public java.util.Map<java.lang.String,CmsJspContentAccessBean> getReadXml()
CmsJspContentAccessBean
.Usage example on a JSP with the EL:
Title of "/text.xml": ${cms:vfs(pageContext).readXml['/text.xml'].value['Title']}
for a short form of this method
public CmsRequestContext getRequestContext()
Usage example on a JSP with the EL:
The current URI is: ${cms:vfs(pageContext).requestContext.uri}
for a short form of this method
public java.util.Map<java.lang.String,CmsJspResourceWrapper> getResource()
getReadResource()
.Usage example on a JSP with the EL:
Root path of the "/index.html" resource: ${cms:vfs(pageContext).resource['/index.html'].rootPath}
getReadResource()
public java.lang.String getResourceExtension(java.lang.Object obj)
This assumes the parameter is either a CmsResource, or a String representing a resource name.
The extension will always be lower case.obj
- a CmsResource or a String representing a resource namenull
if not availableCmsResource.getExtension(String)
,
CmsJspResourceWrapper.getResourceExtension()
public java.lang.String getResourceName(java.lang.Object obj)
This assumes the parameter is either a CmsResource, or a String representing a resource name.
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 /
.
obj
- a CmsResource or a String representing a resource nameCmsResource.getName()
,
CmsJspResourceWrapper.getResourceName()
public java.util.Map<java.lang.String,CmsJspContentAccessBean> getXml()
getReadXml()
.Usage example on a JSP with the EL:
Title of "/text.xml": ${cms:vfs(pageContext).xml['/text.xml'].value['Title']}
getReadXml()
public java.util.List<CmsJspResourceWrapper> readFilesInFolder(java.lang.String resourcePath) throws CmsException
resourcePath
- the site path to the folderCmsException
- in case reading the resources failspublic java.util.List<CmsJspResourceWrapper> readFilesInFolder(java.lang.String resourcePath, java.lang.String filterString) throws CmsException
resourcePath
- the site path to the folderfilterString
- a comma separated list of resource type namesCmsException
- in case reading the resources failspublic CmsJspResourceWrapper readSubsiteFor(java.lang.String path) throws CmsException
path
- the current site pathCmsException
- in case reading the resource fails