Class 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.

    • 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 context
        rootCms - the CMS context initialized for the root site
        path - the path below the JSON handler
        resource - the resource (may be null)
        params - the request parameters
        handlerConfig - the handler parameters from opencms-system.xml
        policy - the access policy
    • Method Detail

      • getCms

        public CmsObject getCms()
        Gets the CMS context.
        Returns:
        the CMS context
      • 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
      • 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