Package org.opencms.xml.xml2json.handler
Class CmsJsonHandlerContext
- java.lang.Object
-
- org.opencms.xml.xml2json.handler.CmsJsonHandlerContext
-
public class CmsJsonHandlerContext extends java.lang.Object
Provides context information to JSON handlers.Also lazily loads the resource or content to be rendered as JSON.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmsJsonHandlerContext.Key
Cache key for JSON handler contexts.
-
Constructor Summary
Constructors Constructor Description CmsJsonHandlerContext(CmsObject cms, CmsObject rootCms, java.lang.String path, CmsResource resource, java.util.Map<java.lang.String,java.lang.String> params, CmsParameterConfiguration handlerConfig, CmsJsonAccessPolicy policy)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CmsJsonAccessPolicy
getAccessPolicy()
Gets the access policy.CmsObject
getCms()
Gets the CMS context.CmsXmlContent
getContent()
Loads the XML content.CmsFile
getFile()
Gets the file for the path.CmsParameterConfiguration
getHandlerConfig()
Gets the configured handler parameters.CmsJsonHandlerContext.Key
getKey()
Creates a cache key for this context.java.util.Map<java.lang.String,java.lang.String>
getParameters()
Gets the request parameters.java.lang.String
getPath()
Returns the path.CmsResource
getResource()
Gets the resource (may be null if there is no resource).CmsObject
getRootCms()
Gets the CMS context initialized to the root site.java.util.Map<java.lang.String,java.lang.Object>
getTempStorage()
Gets the temporary storage to be used by individual handlers.
-
-
-
Constructor Detail
-
CmsJsonHandlerContext
public CmsJsonHandlerContext(CmsObject cms, CmsObject rootCms, java.lang.String path, CmsResource resource, java.util.Map<java.lang.String,java.lang.String> params, CmsParameterConfiguration handlerConfig, CmsJsonAccessPolicy policy)
Creates a new instance.- Parameters:
cms
- the CMS contextrootCms
- the CMS context initialized for the root sitepath
- the path below the JSON handlerresource
- the resource (may be null)params
- the request parametershandlerConfig
- the handler parameters from opencms-system.xmlpolicy
- the access policy
-
-
Method Detail
-
getAccessPolicy
public CmsJsonAccessPolicy getAccessPolicy()
Gets the access policy.- Returns:
- the access policy
-
getContent
public CmsXmlContent getContent() throws CmsException
Loads the XML content.This only works if the resource for the given path is actually an XML content.
- Returns:
- the XML content for the path
- Throws:
CmsException
- if something goes wrong
-
getFile
public CmsFile getFile() throws CmsException
Gets the file for the path. This will only work if the resource for the path is actually a file.- Returns:
- the file for the path
- Throws:
CmsException
- if something goes wrong
-
getHandlerConfig
public CmsParameterConfiguration getHandlerConfig()
Gets the configured handler parameters.- Returns:
- the configured handler parameters
-
getKey
public CmsJsonHandlerContext.Key getKey()
Creates a cache key for this context.- Returns:
- the cache key
-
getParameters
public java.util.Map<java.lang.String,java.lang.String> getParameters()
Gets the request parameters.- Returns:
- the request parameters
-
getPath
public java.lang.String getPath()
Returns the path.- Returns:
- the path
-
getResource
public CmsResource getResource()
Gets the resource (may be null if there is no resource).- Returns:
- the resource
-
getRootCms
public CmsObject getRootCms()
Gets the CMS context initialized to the root site.- Returns:
- the CMS context initialized to the root site
-
getTempStorage
public java.util.Map<java.lang.String,java.lang.Object> getTempStorage()
Gets the temporary storage to be used by individual handlers.- Returns:
- the temporary storage
-
-