Package org.opencms.file.history
Class CmsHistoryResourceHandler
java.lang.Object
org.opencms.file.history.CmsHistoryResourceHandler
- All Implemented Interfaces:
I_CmsResourceInit
Resource init handler that loads historical versions of resources.
- Since:
- 6.9.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstant for the historical version request attribute name.static final StringThe historical version handler path.static final StringRequest parameter name for the version number.static final intConstant for the offline project version.Fields inherited from interface org.opencms.main.I_CmsResourceInit
ATTR_ALTERNATIVE_CMS_OBJECT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic I_CmsHistoryResourcegetHistoryResource(javax.servlet.ServletRequest req) Returns the historical version of a resource, if the given request is displaying a history version.static StringgetHistoryResourceURI(String uri, javax.servlet.ServletRequest req) Appends theversionparameter to the URI if needed.static CmsResourcegetResourceWithHistory(CmsObject cms, String resourceUri) Returns the correct resource for the given URI, taken into account historical versions marked by theversionparameter.initResource(CmsResource resource, CmsObject cms, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Possibility to modify or change the CmsFile with the CmsObject.static booleanisHistoryRequest(javax.servlet.ServletRequest req) Returnstrueif the given request is displaying an historical version.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opencms.main.I_CmsResourceInit
getConfiguration, initParameters
-
Field Details
-
ATTRIBUTE_NAME
Constant for the historical version request attribute name.- See Also:
-
HISTORY_HANDLER
The historical version handler path.- See Also:
-
PARAM_VERSION
Request parameter name for the version number.- See Also:
-
PROJECT_OFFLINE_VERSION
Constant for the offline project version.- See Also:
-
-
Constructor Details
-
CmsHistoryResourceHandler
public CmsHistoryResourceHandler()
-
-
Method Details
-
getHistoryResource
Returns the historical version of a resource, if the given request is displaying a history version.- Parameters:
req- the request to check- Returns:
- the historical resource if the given request is displaying an historical version
-
getHistoryResourceURI
Appends theversionparameter to the URI if needed.- Parameters:
uri- the resource URIreq- the current request- Returns:
- the same URI, with additional parameters in case of a historical request
-
getResourceWithHistory
public static CmsResource getResourceWithHistory(CmsObject cms, String resourceUri) throws CmsException Returns the correct resource for the given URI, taken into account historical versions marked by theversionparameter.- Parameters:
cms- the current CMS contextresourceUri- the resource URI- Returns:
- the resource, which can be an instance of
I_CmsHistoryResource - Throws:
CmsException- if something goes wrong
-
isHistoryRequest
Returnstrueif the given request is displaying an historical version.- Parameters:
req- the request to check- Returns:
trueif the given request is displaying a historical version
-
initResource
public CmsResource initResource(CmsResource resource, CmsObject cms, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws CmsResourceInitException Description copied from interface:I_CmsResourceInitPossibility to modify or change the CmsFile with the CmsObject.Caution: reading parameters from the request, destroys special characters in all parameters, because the encoding for the request was not set yet.
- Specified by:
initResourcein interfaceI_CmsResourceInit- Parameters:
resource- the requested filecms- the current CmsObjectreq- the current requestres- the current response- Returns:
- a resource in the OpenCms VFS
- Throws:
CmsResourceInitException- if other implementations of the interface should not be executed- See Also:
-