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