Package org.opencms.xml.xml2json
Class CmsJsonRequest
java.lang.Object
org.opencms.xml.xml2json.CmsJsonRequest
Class representing a JSON request. Provides utility functions for parameter validation.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The content request parameter.static final String
The fallback locale request parameter.static final String
The levels request parameter.static final String
The locale request parameter.static final String
The path request parameter.static final String
The rows request parameter.static final String
The sort request parameter.static final String
The start request parameter.static final String
The wrapper request parameter. -
Constructor Summary
ConstructorDescriptionCmsJsonRequest
(CmsJsonHandlerContext context, I_CmsJsonHandler handler) Creates a new JSON request. -
Method Summary
Modifier and TypeMethodDescriptionReturns the JSON handler context.Returns the errors of this request as JSON.getParamBoolean
(String bool) Returns the boolean parameter value for a given string.Returns the content parameter as boolean.Returns the fallback locale parameter as boolean.Returns the levels parameter as integer.getParamLevels
(int defaultLevels) Returns the levels parameter as integer.Returns the locale parameter as string.Returns the path parameter as string.Returns the rows parameter as integer.getParamRows
(int defaultRows) Returns the rows parameter as integer.Returns the sort parameter as string.getParamSort
(String defaultSort) Returns the sort parameter as string.Returns the start parameter as integer.getParamStart
(int defaultStart) Returns the rows parameter as integer.Returns the wrapper parameter as string.getParamWrapper
(boolean defaultWrapper) Returns the wrapper parameter as string.boolean
Whether this JSON request has validation errors.void
validate()
Validates this request.
-
Field Details
-
PARAM_CONTENT
The content request parameter.- See Also:
-
PARAM_FALLBACK_LOCALE
The fallback locale request parameter.- See Also:
-
PARAM_LEVELS
The levels request parameter.- See Also:
-
PARAM_LOCALE
The locale request parameter.- See Also:
-
PARAM_PATH
The path request parameter.- See Also:
-
PARAM_ROWS
The rows request parameter.- See Also:
-
PARAM_SORT
The sort request parameter.- See Also:
-
PARAM_START
The start request parameter.- See Also:
-
PARAM_WRAPPER
The wrapper request parameter.- See Also:
-
-
Constructor Details
-
CmsJsonRequest
Creates a new JSON request.- Parameters:
context
- the JSON handler contexthandler
- the JSON handler initiating this request
-
-
Method Details
-
getContext
Returns the JSON handler context.- Returns:
- the JSON handler context
-
getErrorsAsJson
Returns the errors of this request as JSON.- Returns:
- the errors as JSON
- Throws:
JSONException
- if JSON rendering fails
-
getParamBoolean
Returns the boolean parameter value for a given string.- Parameters:
bool
- the string- Returns:
- the boolean
-
getParamContent
Returns the content parameter as boolean.- Returns:
- the content parameter as boolean
-
getParamFallbackLocale
Returns the fallback locale parameter as boolean.- Returns:
- the fallback locale parameter as boolean
-
getParamLevels
Returns the levels parameter as integer.- Returns:
- the levels parameter as integer
-
getParamLevels
Returns the levels parameter as integer.- Parameters:
defaultLevels
- if parameter is not set return this default value- Returns:
- the levels parameter as integer
-
getParamLocale
Returns the locale parameter as string.- Returns:
- the levels parameter as integer
-
getParamPath
Returns the path parameter as string.- Returns:
- the path parameter as string
-
getParamRows
Returns the rows parameter as integer.- Returns:
- the rows parameter as integer
-
getParamRows
Returns the rows parameter as integer.- Parameters:
defaultRows
- if parameter is not set return this default value- Returns:
- the rows parameter as integer
-
getParamSort
Returns the sort parameter as string.- Returns:
- the sort parameter as string
-
getParamSort
Returns the sort parameter as string.- Parameters:
defaultSort
- if parameter is not set return this default value- Returns:
- the sort parameter as string
-
getParamStart
Returns the start parameter as integer.- Returns:
- the start parameter as integer
-
getParamStart
Returns the rows parameter as integer.- Parameters:
defaultStart
- if parameter is not set return this default value- Returns:
- the rows parameter as integer
-
getParamWrapper
Returns the wrapper parameter as string.- Returns:
- the wrapper parameter as string
-
getParamWrapper
Returns the wrapper parameter as string.- Parameters:
defaultWrapper
- if parameter is not set return this default value- Returns:
- the wrapper parameter as string
-
hasErrors
Whether this JSON request has validation errors.- Returns:
- whether has validation errors or not
-
validate
Validates this request.
-