Class CmsJsonDocumentXmlContent
java.lang.Object
org.opencms.xml.xml2json.document.A_CmsJsonDocument
org.opencms.xml.xml2json.document.CmsJsonDocumentResource
org.opencms.xml.xml2json.document.CmsJsonDocumentXmlContent
- All Implemented Interfaces:
I_CmsJsonDocument
- Direct Known Subclasses:
CmsJsonDocumentContainerPage
,CmsJsonDocumentEmbeddedXmlContent
,CmsJsonDocumentList
Class representing a JSON document for an XML content.
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Whether to embed linked contents.protected boolean
Whether to throw exceptions.protected CmsXmlContent
The XML content.Fields inherited from class org.opencms.xml.xml2json.document.CmsJsonDocumentResource
m_helper, m_resource
Fields inherited from class org.opencms.xml.xml2json.document.A_CmsJsonDocument
FIELD_LINKED_CONTENTS, m_context, m_json, m_jsonRequest
-
Constructor Summary
ConstructorDescriptionCmsJsonDocumentXmlContent
(CmsJsonRequest jsonRequest, CmsXmlContent xmlContent) Creates a new JSON document.CmsJsonDocumentXmlContent
(CmsJsonRequest jsonRequest, CmsXmlContent xmlContent, boolean embedLinkedModelgroup) Creates a new JSON document. -
Method Summary
Modifier and TypeMethodDescriptiongetJson()
Returns the JSON document.protected void
insertJsonLinkedContent
(CmsResource resource) Inserts a JSON representation of a linked content into this JSON document.protected void
For each linked content, inserts a JSON representation of the linked content into this JSON document.protected void
Inserts a wrapper with resource information into this JSON document.protected boolean
Whether all locales of this XML content are requested.protected boolean
Whether one locale of this XML content is requested.protected boolean
Whether a part of a locale of this XML content is requested.protected boolean
Whether the default locale content shall be shown in the case the requested locale is not available.protected boolean
Whether all linked contents shall be embedded into this document.protected boolean
Whether to show the wrapper with resource information.Methods inherited from class org.opencms.xml.xml2json.document.CmsJsonDocumentResource
insertJsonResource, insertJsonResourceAttributes, insertJsonResourceFile, insertJsonResourceParams, insertJsonResourcePathAndLink, insertJsonResourceProperties
-
Field Details
-
m_xmlContent
The XML content. -
m_throwException
Whether to throw exceptions. -
m_embedLinkedModelgroup
Whether to embed linked contents.
-
-
Constructor Details
-
CmsJsonDocumentXmlContent
public CmsJsonDocumentXmlContent(CmsJsonRequest jsonRequest, CmsXmlContent xmlContent) throws Exception Creates a new JSON document.- Parameters:
jsonRequest
- the JSON requestxmlContent
- the XML content- Throws:
Exception
- if something goes wrong
-
CmsJsonDocumentXmlContent
public CmsJsonDocumentXmlContent(CmsJsonRequest jsonRequest, CmsXmlContent xmlContent, boolean embedLinkedModelgroup) throws Exception Creates a new JSON document.- Parameters:
jsonRequest
- the JSON requestxmlContent
- the XML contentembedLinkedModelgroup
- whether to embed linked model groups- Throws:
Exception
- if something goes wrong
-
-
Method Details
-
getJson
public Object getJson() throws JSONException, CmsException, CmsJsonHandlerException, CmsJsonHandlerXmlContent.PathNotFoundException, ExceptionDescription copied from interface:I_CmsJsonDocument
Returns the JSON document.- Specified by:
getJson
in interfaceI_CmsJsonDocument
- Overrides:
getJson
in classCmsJsonDocumentResource
- Returns:
- the JSON document
- Throws:
JSONException
- if rendering the JSON document failsCmsException
- if reading a resource or evaluating a SOLR search failsCmsJsonHandlerException
- if the request is not valid according to the specificationCmsJsonHandlerXmlContent.PathNotFoundException
- if the selected path does not existException
- if something else goes wrong- See Also:
-
insertJsonLinkedContent
Inserts a JSON representation of a linked content into this JSON document.- Parameters:
resource
- the resource- Throws:
Exception
- if something goes wrong
-
insertJsonLinkedContents
For each linked content, inserts a JSON representation of the linked content into this JSON document.- Throws:
Exception
- if something goes wrong
-
insertJsonWrapper
Inserts a wrapper with resource information into this JSON document.- Throws:
JSONException
- if JSON rendering failsCmsException
- if reading resource properties fails
-
isLocaleAllRequest
Whether all locales of this XML content are requested.- Returns:
- whether all or not
-
isLocalePathRequest
Whether one locale of this XML content is requested.- Returns:
- whether one locale or not
-
isLocaleRequest
Whether a part of a locale of this XML content is requested.- Returns:
- whether a part of a locale or not
-
isShowFallbackLocaleRequest
Whether the default locale content shall be shown in the case the requested locale is not available.- Returns:
- whether to show the default locale or not
-
isShowLinkedContentsRequest
Whether all linked contents shall be embedded into this document.- Returns:
- whether to embed the linked contents or not
-
isShowWrapperRequest
Whether to show the wrapper with resource information. For backward compatibility the wrapper is shown for the all locale request but not for the locale and locale path request as a default. This default behavior can be changed by means of the "wrapper" request parameter. For locale path requests, wrapper information is not available.- Returns:
- whether to show the wrapper or not
-