Package org.opencms.xml.xml2json
Class CmsJsonResourceHandler
java.lang.Object
org.opencms.xml.xml2json.CmsJsonResourceHandler
- All Implemented Interfaces:
I_CmsNeedsAdminCmsObject
,I_CmsResourceInit
public class CmsJsonResourceHandler
extends Object
implements I_CmsResourceInit, I_CmsNeedsAdminCmsObject
Handles /json requests.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Request attribute for storing the JSON handler context.static final String
Configuration parameter that determines which authorization method to use.static final Object
Parameter to reference the link rewriting strategy defined elsewhere.static final String
URL prefix.Fields inherited from interface org.opencms.main.I_CmsResourceInit
ATTR_ALTERNATIVE_CMS_OBJECT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected CmsJsonAccessPolicy
getAccessPolicy
(CmsObject cms) Reads JSON access policy from cache or loads it if necessary.static I_CmsCustomLinkRenderer
getLinkRenderer
(CmsObject cms) Gets the link renderer for the current CMS context.Gets the list of sub-handlers, sorted by ascending order.void
Initializes parameters.initResource
(CmsResource origRes, CmsObject cms, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Possibility to modify or change the CmsFile with the CmsObject.static String
link
(CmsObject cms, CmsResource res) Produces a link to the given resource, using the link renderer from the current CMS context if it is set.void
setAdminCmsObject
(CmsObject adminCms) Sets the admin CmsObject.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opencms.main.I_CmsResourceInit
getConfiguration
-
Field Details
-
ATTR_CONTEXT
Request attribute for storing the JSON handler context.- See Also:
-
PARAM_AUTHORIZATION
Configuration parameter that determines which authorization method to use.- See Also:
-
PREFIX
URL prefix.- See Also:
-
PARAM_LINKREWRITE_REFID
Parameter to reference the link rewriting strategy defined elsewhere.
-
-
Constructor Details
-
CmsJsonResourceHandler
public CmsJsonResourceHandler()Creates a new instance.
-
-
Method Details
-
getLinkRenderer
Gets the link renderer for the current CMS context.- Parameters:
cms
- the current CMS context- Returns:
- the link renderer for the context, or null if there is none
-
link
Produces a link to the given resource, using the link renderer from the current CMS context if it is set.- Parameters:
cms
- the CMS contextres
- the resource to link to- Returns:
- the link to the resource
-
getSubHandlers
Gets the list of sub-handlers, sorted by ascending order.- Returns:
- the sorted list of sub-handlers
-
initParameters
Description copied from interface:I_CmsResourceInit
Initializes parameters.- Specified by:
initParameters
in interfaceI_CmsResourceInit
- Parameters:
params
- the configuration parameters- See Also:
-
initResource
public CmsResource initResource(CmsResource origRes, CmsObject cms, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws CmsResourceInitException Description copied from interface:I_CmsResourceInit
Possibility 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:
initResource
in interfaceI_CmsResourceInit
- Parameters:
origRes
- 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:
-
setAdminCmsObject
Description copied from interface:I_CmsNeedsAdminCmsObject
Sets the admin CmsObject.- Specified by:
setAdminCmsObject
in interfaceI_CmsNeedsAdminCmsObject
- Parameters:
adminCms
- a CmsObject with admin privileges- See Also:
-
getAccessPolicy
Reads JSON access policy from cache or loads it if necessary.- Parameters:
cms
- the CMS context used to load the access policy- Returns:
- the access policy
-