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 java.lang.Object implements I_CmsResourceInit, I_CmsNeedsAdminCmsObject
Handles /json requests.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ATTR_CONTEXT
Request attribute for storing the JSON handler context.static java.lang.String
PARAM_AUTHORIZATION
Configuration parameter that determines which authorization method to use.static java.lang.Object
PARAM_LINKREWRITE_REFID
Parameter to reference the link rewriting strategy defined elsewhere.static java.lang.String
PREFIX
URL prefix.-
Fields inherited from interface org.opencms.main.I_CmsResourceInit
ATTR_ALTERNATIVE_CMS_OBJECT
-
-
Constructor Summary
Constructors Constructor Description CmsJsonResourceHandler()
Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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.java.util.List<I_CmsJsonHandler>
getSubHandlers()
Gets the list of sub-handlers, sorted by ascending order.void
initParameters(CmsParameterConfiguration params)
Initializes parameters.CmsResource
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 java.lang.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 Detail
-
ATTR_CONTEXT
public static final java.lang.String ATTR_CONTEXT
Request attribute for storing the JSON handler context.- See Also:
- Constant Field Values
-
PARAM_AUTHORIZATION
public static final java.lang.String PARAM_AUTHORIZATION
Configuration parameter that determines which authorization method to use.- See Also:
- Constant Field Values
-
PREFIX
public static final java.lang.String PREFIX
URL prefix.- See Also:
- Constant Field Values
-
PARAM_LINKREWRITE_REFID
public static final java.lang.Object PARAM_LINKREWRITE_REFID
Parameter to reference the link rewriting strategy defined elsewhere.
-
-
Constructor Detail
-
CmsJsonResourceHandler
public CmsJsonResourceHandler()
Creates a new instance.
-
-
Method Detail
-
getLinkRenderer
public static I_CmsCustomLinkRenderer getLinkRenderer(CmsObject cms)
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
public static java.lang.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.- Parameters:
cms
- the CMS contextres
- the resource to link to- Returns:
- the link to the resource
-
getSubHandlers
public java.util.List<I_CmsJsonHandler> getSubHandlers()
Gets the list of sub-handlers, sorted by ascending order.- Returns:
- the sorted list of sub-handlers
-
initParameters
public void initParameters(CmsParameterConfiguration params)
Description copied from interface:I_CmsResourceInit
Initializes parameters.- Specified by:
initParameters
in interfaceI_CmsResourceInit
- Parameters:
params
- the configuration parameters- See Also:
I_CmsResourceInit.initParameters(org.opencms.configuration.CmsParameterConfiguration)
-
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:
I_CmsResourceInit.initResource(org.opencms.file.CmsResource, org.opencms.file.CmsObject, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-
setAdminCmsObject
public void setAdminCmsObject(CmsObject adminCms)
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:
I_CmsNeedsAdminCmsObject.setAdminCmsObject(org.opencms.file.CmsObject)
-
getAccessPolicy
protected CmsJsonAccessPolicy getAccessPolicy(CmsObject cms)
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
-
-