org.opencms.loader
Class CmsPointerLoader

java.lang.Object
  extended by org.opencms.loader.CmsDumpLoader
      extended by org.opencms.loader.CmsPointerLoader
All Implemented Interfaces:
I_CmsConfigurationParameterHandler, I_CmsResourceLoader

public class CmsPointerLoader
extends CmsDumpLoader

Loader for "pointers" to resources in the VFS or to external resources.

Since:
6.0.0
Version:
$Revision: 1.57 $
Author:
Alexander Kandzior

Field Summary
static java.lang.String CONFIGURATION_REQUEST_PARAM_SUPPORT_ENABLED
          The configuration parameter for the OpenCms XML configuration to enable that the parameters in requests to pointer resources are appended to the pointer target link.
protected static boolean m_requestParamSupportEnabled
          Flag that controls if parameters in requests to pointer resources are appended to the target link when redirecting.
static int RESOURCE_LOADER_ID
          The id of this loader.
 
Fields inherited from interface org.opencms.loader.I_CmsResourceLoader
PARAMETER_ELEMENT
 
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
 
Constructor Summary
CmsPointerLoader()
          The constructor of the class is empty and does nothing.
 
Method Summary
 void addConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)
          Adds a configuration parameter to this parameter configurable class instance.
 void destroy()
          Destroy this ResourceLoder, this is a NOOP so far.
 byte[] dump(CmsObject cms, CmsResource resource, java.lang.String element, java.util.Locale locale, 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.
 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.
 java.util.Map<java.lang.String,java.lang.String> getConfiguration()
          Will always return null since this loader does not need to be configured.
 int getLoaderId()
          Returns the id of the ResourceLoader.
 java.lang.String getResourceLoaderInfo()
          Return a String describing the ResourceLoader, which is (localized to the system default locale) "The OpenCms default resource loader for pointers".
 void initConfiguration()
          Initializes a configuration after all parameters have been added.
static boolean isRequestParamSupportEnabled()
          Returns true if parameters in requests to pointer resources are appended to the target link when redirecting.
 boolean isStaticExportEnabled()
          Returns true if request parameter support is disabled.
 boolean isStaticExportProcessable()
          Signals if the loader implementation requires processing during static export of resources.
 boolean isUsableForTemplates()
          Signals if the loader implementation is usable for creating templates.
 boolean isUsingUriWhenLoadingTemplate()
          Signals if a loader that supports templates must be invoked on the template URI or the resource URI.
 void load(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.
 void service(CmsObject cms, CmsResource file, 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.
 
Methods inherited from class org.opencms.loader.CmsDumpLoader
canSendLastModifiedHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_LOADER_ID

public static final int RESOURCE_LOADER_ID
The id of this loader.

See Also:
Constant Field Values

m_requestParamSupportEnabled

protected static boolean m_requestParamSupportEnabled
Flag that controls if parameters in requests to pointer resources are appended to the target link when redirecting.


CONFIGURATION_REQUEST_PARAM_SUPPORT_ENABLED

public static final java.lang.String CONFIGURATION_REQUEST_PARAM_SUPPORT_ENABLED
The configuration parameter for the OpenCms XML configuration to enable that the parameters in requests to pointer resources are appended to the pointer target link.

See Also:
Constant Field Values
Constructor Detail

CmsPointerLoader

public CmsPointerLoader()
The constructor of the class is empty and does nothing.

Method Detail

addConfigurationParameter

public void addConfigurationParameter(java.lang.String paramName,
                                      java.lang.String paramValue)
Description copied from interface: I_CmsConfigurationParameterHandler
Adds a configuration parameter to this parameter configurable class instance.

Specified by:
addConfigurationParameter in interface I_CmsConfigurationParameterHandler
Overrides:
addConfigurationParameter in class CmsDumpLoader
Parameters:
paramName - the name of the parameter
paramValue - the value for the parameter
See Also:
I_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)

destroy

public void destroy()
Destroy this ResourceLoder, this is a NOOP so far.

Specified by:
destroy in interface I_CmsResourceLoader
Overrides:
destroy in class CmsDumpLoader

dump

public byte[] dump(CmsObject cms,
                   CmsResource resource,
                   java.lang.String element,
                   java.util.Locale locale,
                   javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
            throws CmsException
Description copied from interface: I_CmsResourceLoader
Dumps 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:
dump in interface I_CmsResourceLoader
Overrides:
dump in class CmsDumpLoader
Parameters:
cms - used to access the OpenCms VFS
resource - the requested resource in the VFS
element - the element in the file to display
locale - the locale to display
req - the servlet request
res - the servlet response
Returns:
the content of the processed file
Throws:
CmsException - in case of errors accessing OpenCms functions
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)

export

public byte[] export(CmsObject cms,
                     CmsResource resource,
                     javax.servlet.http.HttpServletRequest req,
                     javax.servlet.http.HttpServletResponse res)
              throws java.io.IOException,
                     CmsException
Description copied from interface: I_CmsResourceLoader
Static 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:
export in interface I_CmsResourceLoader
Overrides:
export in class CmsDumpLoader
Parameters:
cms - the initialized CmsObject which provides user permissions
resource - the requested OpenCms VFS resource
req - the servlet request
res - the servlet response
Returns:
the contents to export, or null if no export is required
Throws:
java.io.IOException - might be thrown in the process of including the sub element
CmsException - 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 java.util.Map<java.lang.String,java.lang.String> getConfiguration()
Description copied from class: CmsDumpLoader
Will always return null since this loader does not need to be configured.

Specified by:
getConfiguration in interface I_CmsConfigurationParameterHandler
Overrides:
getConfiguration in class CmsDumpLoader
Returns:
the configuration of this resource loader, or null
See Also:
I_CmsConfigurationParameterHandler.getConfiguration()

getLoaderId

public int getLoaderId()
Description copied from interface: I_CmsResourceLoader
Returns the id of the ResourceLoader.

Specified by:
getLoaderId in interface I_CmsResourceLoader
Overrides:
getLoaderId in class CmsDumpLoader
Returns:
the id of the ResourceLoader
See Also:
I_CmsResourceLoader.getLoaderId()

getResourceLoaderInfo

public java.lang.String getResourceLoaderInfo()
Return a String describing the ResourceLoader, which is (localized to the system default locale) "The OpenCms default resource loader for pointers".

Specified by:
getResourceLoaderInfo in interface I_CmsResourceLoader
Overrides:
getResourceLoaderInfo in class CmsDumpLoader
Returns:
a describing String for the ResourceLoader

initConfiguration

public void initConfiguration()
Description copied from interface: I_CmsConfigurationParameterHandler
Initializes a configuration after all parameters have been added.

Specified by:
initConfiguration in interface I_CmsConfigurationParameterHandler
Overrides:
initConfiguration in class CmsDumpLoader
See Also:
I_CmsConfigurationParameterHandler.initConfiguration()

isStaticExportEnabled

public boolean isStaticExportEnabled()
Returns true if request parameter support is disabled.

Specified by:
isStaticExportEnabled in interface I_CmsResourceLoader
Overrides:
isStaticExportEnabled in class CmsDumpLoader
Returns:
true if request parameter support is disabled
See Also:
I_CmsResourceLoader.isStaticExportEnabled()

isUsableForTemplates

public boolean isUsableForTemplates()
Description copied from interface: I_CmsResourceLoader
Signals if the loader implementation is usable for creating templates.

Specified by:
isUsableForTemplates in interface I_CmsResourceLoader
Overrides:
isUsableForTemplates in class CmsDumpLoader
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_CmsResourceLoader
Signals if a loader that supports templates must be invoked on the template URI or the resource URI.

Specified by:
isUsingUriWhenLoadingTemplate in interface I_CmsResourceLoader
Overrides:
isUsingUriWhenLoadingTemplate in class CmsDumpLoader
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 java.io.IOException,
                 CmsException
Description copied from interface: I_CmsResourceLoader
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.

Specified by:
load in interface I_CmsResourceLoader
Overrides:
load in class CmsDumpLoader
Parameters:
cms - the initialized CmsObject which provides user permissions
resource - the requested OpenCms VFS resource
req - the servlet request
res - the servlet response
Throws:
java.io.IOException - might be thrown by the servlet environment
CmsException - 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 file,
                    javax.servlet.ServletRequest req,
                    javax.servlet.ServletResponse res)
Description copied from interface: I_CmsResourceLoader
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.

Specified by:
service in interface I_CmsResourceLoader
Overrides:
service in class CmsDumpLoader
Parameters:
cms - used to access the OpenCms VFS
file - the requested resource in the VFS
req - the servlet request
res - the servlet response
See Also:
I_CmsResourceLoader.service(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.ServletRequest, javax.servlet.ServletResponse)

isRequestParamSupportEnabled

public static boolean isRequestParamSupportEnabled()
Returns true if parameters in requests to pointer resources are appended to the target link when redirecting.

This is controlled by the configuration of this loader in opencms-system.xml.

Returns:
true if parameters in requests to pointer resources are appended to the target link when redirecting.

isStaticExportProcessable

public boolean isStaticExportProcessable()
Description copied from interface: I_CmsResourceLoader
Signals if the loader implementation requires processing during static export of resources.

Specified by:
isStaticExportProcessable in interface I_CmsResourceLoader
Overrides:
isStaticExportProcessable in class CmsDumpLoader
Returns:
true if static export processing is required, false otherwise
See Also:
I_CmsResourceLoader.isStaticExportProcessable()