Class CmsXmlPageLoader
- java.lang.Object
-
- org.opencms.loader.CmsXmlPageLoader
-
- All Implemented Interfaces:
I_CmsConfigurationParameterHandler,I_CmsResourceLoader,I_CmsResourceStringDumpLoader
public class CmsXmlPageLoader extends java.lang.Object
OpenCms loader for resources of type.CmsResourceTypeXmlPage- Since:
- 6.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static intRESOURCE_LOADER_IDThe id of this loader.-
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
-
Fields inherited from interface org.opencms.loader.I_CmsResourceLoader
PARAMETER_ELEMENT
-
-
Constructor Summary
Constructors Constructor Description CmsXmlPageLoader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)Adds a configuration parameter to this parameter configurable class instance.voiddestroy()Destroys this ResourceLoder.byte[]dump(CmsObject cms, CmsResource resource, java.lang.String element, java.util.Locale selectedLocale, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Dumps the processed content of the the requested file (and it's sub-elements) to a byte array.java.lang.StringdumpAsString(CmsObject cms, CmsResource resource, java.lang.String element, java.util.Locale selectedLocale, javax.servlet.ServletRequest req, javax.servlet.ServletResponse res)Dumps the processed content of the the requested file (and it's sub-elements) to a String.byte[]export(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Static exports the contents of the requested file and it's sub-elements.CmsParameterConfigurationgetConfiguration()Returnsnullsince XML document loaders does usually not need to be configured.intgetLoaderId()Returns the id of the ResourceLoader.java.lang.StringgetResourceLoaderInfo()Returns a String describing this resource loader, which is (localized to the system default locale)"The OpenCms default resource loader for xml pages".protected CmsTemplateLoaderFacadegetTemplateLoaderFacade(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req)Returns the template loader facade for the given resource.protected java.lang.StringgetTemplatePropertyDefinition()Returns the property definition name used to selecte the template for this XML document resource loader.voidinitConfiguration()Initializes a configuration after all parameters have been added.booleanisStaticExportEnabled()Signals if the loader implementation supports static export of resources.booleanisStaticExportProcessable()Signals if the loader implementation requires processing during static export of resources.booleanisUsableForTemplates()Signals if the loader implementation is usable for creating templates.booleanisUsingUriWhenLoadingTemplate()Signals if a loader that supports templates must be invoked on the template URI or the resource URI.voidload(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)Basic top-page processing method for a I_CmsResourceLoader, this method is called if the page is called as a sub-element on a page not already loaded with a I_CmsResourceLoader.voidservice(CmsObject cms, CmsResource resource, javax.servlet.ServletRequest req, javax.servlet.ServletResponse res)Does the job of including the requested resource, this method is called directly if the element is called as a sub-element from another I_CmsResourceLoader.protected voidsetTemplateRequestAttributes(CmsTemplateLoaderFacade loaderFacade, javax.servlet.http.HttpServletRequest req)Sets request attributes that provide access to the template configuration.protected I_CmsXmlDocumentunmarshalXmlDocument(CmsObject cms, CmsResource resource, javax.servlet.ServletRequest req)Returns the unmarshalled XML document.
-
-
-
Field Detail
-
RESOURCE_LOADER_ID
public static final int RESOURCE_LOADER_ID
The id of this loader.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsXmlPageLoader
public CmsXmlPageLoader()
-
-
Method Detail
-
getLoaderId
public int getLoaderId()
Description copied from interface:I_CmsResourceLoaderReturns the id of the ResourceLoader.- Returns:
- the id of the ResourceLoader
- See Also:
I_CmsResourceLoader.getLoaderId()
-
getResourceLoaderInfo
public java.lang.String getResourceLoaderInfo()
Returns a String describing this resource loader, which is (localized to the system default locale)"The OpenCms default resource loader for xml pages".- Returns:
- a describing String for the ResourceLoader
-
unmarshalXmlDocument
protected I_CmsXmlDocument unmarshalXmlDocument(CmsObject cms, CmsResource resource, javax.servlet.ServletRequest req) throws CmsException
Returns the unmarshalled XML document.- Parameters:
cms- the current users OpenCms contextresource- the requested resourcereq- the current Servlet request- Returns:
- the unmarshalled XML document
- Throws:
CmsException- in case the unmarshalling fails- See Also:
A_CmsXmlDocumentLoader.unmarshalXmlDocument(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.ServletRequest)
-
getTemplatePropertyDefinition
protected java.lang.String getTemplatePropertyDefinition()
Returns the property definition name used to selecte the template for this XML document resource loader.- Returns:
- the property definition name used to selecte the template for this XML document resource loader
- See Also:
A_CmsXmlDocumentLoader.getTemplatePropertyDefinition()
-
addConfigurationParameter
public void addConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)Description copied from interface:I_CmsConfigurationParameterHandlerAdds a configuration parameter to this parameter configurable class instance.- Specified by:
addConfigurationParameterin interfaceI_CmsConfigurationParameterHandler- Parameters:
paramName- the name of the parameterparamValue- the value for the parameter- See Also:
I_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)
-
destroy
public void destroy()
Description copied from interface:I_CmsResourceLoaderDestroys this ResourceLoder.- Specified by:
destroyin interfaceI_CmsResourceLoader- See Also:
I_CmsResourceLoader.destroy()
-
dump
public byte[] dump(CmsObject cms, CmsResource resource, java.lang.String element, java.util.Locale selectedLocale, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws CmsException, java.io.IOException
Description copied from interface:I_CmsResourceLoaderDumps the processed content of the the requested file (and it's sub-elements) to a byte array.Dumping the content is like calling "load" where the result is not written to the response stream, but to the returned byte array. Dumping is different from an export because the export might actually require that the content is handled or modified in a special way, or set special http headers.
Moreover, if the page type is template based, calling "dump" will not trigger the template but directly deliver the contents from the selected element.
- Specified by:
dumpin interfaceI_CmsResourceLoader- Parameters:
cms- used to access the OpenCms VFSresource- the requested resource in the VFSelement- the element in the file to displayselectedLocale- the locale to displayreq- the servlet requestres- the servlet response- Returns:
- the content of the processed file
- Throws:
CmsException- in case of errors accessing OpenCms functionsjava.io.IOException- might be thrown by the servlet environment- See Also:
I_CmsResourceLoader.dump(org.opencms.file.CmsObject, org.opencms.file.CmsResource, java.lang.String, java.util.Locale, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-
dumpAsString
public java.lang.String dumpAsString(CmsObject cms, CmsResource resource, java.lang.String element, java.util.Locale selectedLocale, javax.servlet.ServletRequest req, javax.servlet.ServletResponse res) throws CmsException
Description copied from interface:I_CmsResourceStringDumpLoaderDumps the processed content of the the requested file (and it's sub-elements) to a String.This is a special form of
where the result is required in a String, for example for printing it to a writer.I_CmsResourceLoader.dump(CmsObject, CmsResource, String, Locale, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)- Specified by:
dumpAsStringin interfaceI_CmsResourceStringDumpLoader- Parameters:
cms- used to access the OpenCms VFSresource- the requested resource in the VFSelement- the element in the file to displayselectedLocale- the locale to displayreq- the servlet requestres- the servlet response- Returns:
- the content of the processed file as a String
- Throws:
CmsException- in case of errors acessing OpenCms functions- See Also:
I_CmsResourceStringDumpLoader.dumpAsString(org.opencms.file.CmsObject, org.opencms.file.CmsResource, java.lang.String, java.util.Locale, javax.servlet.ServletRequest, javax.servlet.ServletResponse)
-
export
public byte[] export(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException, CmsException
Description copied from interface:I_CmsResourceLoaderStatic exports the contents of the requested file and it's sub-elements.During static export, the resource content may be written to 2 streams: The export stream, and the http response output stream. Which stream is actually used depends whether the export is in "on demand" or "after publish" mode. In "on demand" mode, the resource needs to be written both to the response stream and to the file stream. In "after publish" mode, it's usually only written to the file stream, but sometimes it's required to write to the response stream as well.
- Specified by:
exportin interfaceI_CmsResourceLoader- Parameters:
cms- the initialized CmsObject which provides user permissionsresource- the requested OpenCms VFS resourcereq- the servlet requestres- the servlet response- Returns:
- the contents to export, or
nullif no export is required - Throws:
javax.servlet.ServletException- might be thrown in the process of including the sub elementjava.io.IOException- might be thrown in the process of including the sub elementCmsException- in case something goes wrong- See Also:
I_CmsResourceLoader.export(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-
getConfiguration
public CmsParameterConfiguration getConfiguration()
Returnsnullsince XML document loaders does usually not need to be configured.- Specified by:
getConfigurationin interfaceI_CmsConfigurationParameterHandler- Returns:
- the parameters of this configurable class instance,
or
nullif the class does not need any parameters - See Also:
I_CmsConfigurationParameterHandler.getConfiguration()
-
initConfiguration
public void initConfiguration()
Description copied from interface:I_CmsConfigurationParameterHandlerInitializes a configuration after all parameters have been added.- Specified by:
initConfigurationin interfaceI_CmsConfigurationParameterHandler- See Also:
I_CmsConfigurationParameterHandler.initConfiguration()
-
isStaticExportEnabled
public boolean isStaticExportEnabled()
Description copied from interface:I_CmsResourceLoaderSignals if the loader implementation supports static export of resources.- Specified by:
isStaticExportEnabledin interfaceI_CmsResourceLoader- Returns:
- true if static export is supported, false otherwise
- See Also:
I_CmsResourceLoader.isStaticExportEnabled()
-
isStaticExportProcessable
public boolean isStaticExportProcessable()
Description copied from interface:I_CmsResourceLoaderSignals if the loader implementation requires processing during static export of resources.- Specified by:
isStaticExportProcessablein interfaceI_CmsResourceLoader- Returns:
- true if static export processing is required, false otherwise
- See Also:
I_CmsResourceLoader.isStaticExportProcessable()
-
isUsableForTemplates
public boolean isUsableForTemplates()
Description copied from interface:I_CmsResourceLoaderSignals if the loader implementation is usable for creating templates.- Specified by:
isUsableForTemplatesin interfaceI_CmsResourceLoader- Returns:
- true if the loader implementation is usable for creating templates, false otherwise
- See Also:
I_CmsResourceLoader.isUsableForTemplates()
-
isUsingUriWhenLoadingTemplate
public boolean isUsingUriWhenLoadingTemplate()
Description copied from interface:I_CmsResourceLoaderSignals if a loader that supports templates must be invoked on the template URI or the resource URI.- Specified by:
isUsingUriWhenLoadingTemplatein interfaceI_CmsResourceLoader- Returns:
- true if the resource URI is to be used, false if the template URI is to be used
- See Also:
I_CmsResourceLoader.isUsingUriWhenLoadingTemplate()
-
load
public void load(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException, CmsException
Description copied from interface:I_CmsResourceLoaderBasic top-page processing method for a I_CmsResourceLoader, this method is called if the page is called as a sub-element on a page not already loaded with a I_CmsResourceLoader.- Specified by:
loadin interfaceI_CmsResourceLoader- Parameters:
cms- the initialized CmsObject which provides user permissionsresource- the requested OpenCms VFS resourcereq- the servlet requestres- the servlet response- Throws:
javax.servlet.ServletException- might be thrown by the servlet environmentjava.io.IOException- might be thrown by the servlet environmentCmsException- in case of errors accessing OpenCms functions- See Also:
I_CmsResourceLoader.load(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-
service
public void service(CmsObject cms, CmsResource resource, javax.servlet.ServletRequest req, javax.servlet.ServletResponse res) throws java.io.IOException, CmsException
Description copied from interface:I_CmsResourceLoaderDoes the job of including the requested resource, this method is called directly if the element is called as a sub-element from another I_CmsResourceLoader.- Specified by:
servicein interfaceI_CmsResourceLoader- Parameters:
cms- used to access the OpenCms VFSresource- the requested resource in the VFSreq- the servlet requestres- the servlet response- Throws:
java.io.IOException- might be thrown by the servlet environmentCmsException- in case of errors accessing OpenCms functions- See Also:
I_CmsResourceLoader.service(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.ServletRequest, javax.servlet.ServletResponse)
-
getTemplateLoaderFacade
protected CmsTemplateLoaderFacade getTemplateLoaderFacade(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req) throws CmsException
Returns the template loader facade for the given resource.- Parameters:
cms- the cms contextresource- the resourcereq- the current request- Returns:
- the loader facade
- Throws:
CmsException- in case reading the template property fails
-
setTemplateRequestAttributes
protected void setTemplateRequestAttributes(CmsTemplateLoaderFacade loaderFacade, javax.servlet.http.HttpServletRequest req)
Sets request attributes that provide access to the template configuration.- Parameters:
loaderFacade- the template loader facadereq- the servlet request
-
-