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.StringPARAM_CONTENTThe content request parameter.static java.lang.StringPARAM_FALLBACK_LOCALEThe fallback locale request parameter.static java.lang.StringPARAM_LEVELSThe levels request parameter.static java.lang.StringPARAM_LOCALEThe locale request parameter.static java.lang.StringPARAM_PATHThe path request parameter.static java.lang.StringPARAM_ROWSThe rows request parameter.static java.lang.StringPARAM_SORTThe sort request parameter.static java.lang.StringPARAM_STARTThe start request parameter.static java.lang.StringPARAM_WRAPPERThe 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 CmsJsonHandlerContextgetContext()Returns the JSON handler context.JSONObjectgetErrorsAsJson()Returns the errors of this request as JSON.java.lang.BooleangetParamBoolean(java.lang.String bool)Returns the boolean parameter value for a given string.java.lang.BooleangetParamContent()Returns the content parameter as boolean.java.lang.BooleangetParamFallbackLocale()Returns the fallback locale parameter as boolean.java.lang.IntegergetParamLevels()Returns the levels parameter as integer.java.lang.IntegergetParamLevels(int defaultLevels)Returns the levels parameter as integer.java.lang.StringgetParamLocale()Returns the locale parameter as string.java.lang.StringgetParamPath()Returns the path parameter as string.java.lang.IntegergetParamRows()Returns the rows parameter as integer.java.lang.IntegergetParamRows(int defaultRows)Returns the rows parameter as integer.java.lang.StringgetParamSort()Returns the sort parameter as string.java.lang.StringgetParamSort(java.lang.String defaultSort)Returns the sort parameter as string.java.lang.IntegergetParamStart()Returns the start parameter as integer.java.lang.IntegergetParamStart(int defaultStart)Returns the rows parameter as integer.java.lang.BooleangetParamWrapper()Returns the wrapper parameter as string.java.lang.BooleangetParamWrapper(boolean defaultWrapper)Returns the wrapper parameter as string.booleanhasErrors()Whether this JSON request has validation errors.voidvalidate()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.
-
-