public class RequestContext
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
RequestContext.Pagination
Names of pagination elements (and their corresponding attributes).
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACTIVATION_KEY |
static java.lang.String |
CID |
static java.lang.String |
COBBLER_ID |
static java.lang.String |
CONFIG_FILE_ID |
static java.lang.String |
CONFIRM |
static java.lang.String |
DISPATCH |
static java.lang.String |
ERRATA_ID |
static java.lang.String |
FILE_LIST_ID |
static java.lang.String |
FILTER_KEY |
static java.lang.String |
FILTER_STRING |
static java.lang.String |
KEY_ID |
static java.lang.String |
KICKSTART |
static java.lang.String |
KICKSTART_ID |
static java.lang.String |
KICKSTART_SCRIPT_ID |
static java.lang.String |
KICKSTART_SESSION |
static java.lang.String |
KICKSTART_STATE_DESC |
static java.lang.String |
KSTREE |
static java.lang.String |
KSTREE_ID |
static java.lang.String |
LABEL |
static java.lang.String |
LIST_DISPLAY_EXPORT |
static java.lang.String |
LIST_SORT |
static java.lang.String |
METHOD_ID |
static java.lang.String |
MODE |
static java.lang.String |
NAME |
static java.lang.String |
NO_SCRIPT |
static java.lang.String |
ORG |
static java.lang.String |
ORG_ID |
static java.lang.String |
PAGE_LIST |
static java.lang.String |
POST |
static java.lang.String |
PREVIOUS_FILTER_STRING |
static java.lang.String |
PRID |
static java.lang.String |
REQUESTED_URI |
static java.lang.String |
SERVER_GROUP |
static java.lang.String |
SERVER_GROUP_ID |
static java.lang.String |
SID |
static java.lang.String |
SID1 |
static java.lang.String |
SORT_ASC |
static java.lang.String |
SORT_DESC |
static java.lang.String |
SORT_ORDER |
static java.lang.String |
SYSTEM |
static java.lang.String |
TOKEN_ID |
static java.lang.String |
USER_ID |
Constructor and Description |
---|
RequestContext(javax.servlet.http.HttpServletRequest req0)
Create a new context object that looks up objects
from the request
req0 |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
buildPageLink(java.lang.String name,
java.lang.String value)
Take a HttpServletRequest and build a self-link to the requested page and
include a name/value parameter.
|
void |
copyParamToAttributes(java.lang.String paramId)
Copies an attached parameter to the attributes list
This is useful when we want to propagate a parameter
that was passed to us, like sid
|
User |
getCurrentUser()
Return the currently LOGged in user that is making the
request.
|
java.lang.String |
getParam(java.lang.String paramName,
boolean required)
Get the parameter
paramName from the request. |
java.lang.Long |
getParamAsLong(java.lang.String param)
Returns the value of the parameter named param of the request as a Long.
|
javax.servlet.http.HttpServletRequest |
getRequest()
Return the request that is used by the context for
object lookup
|
java.lang.Long |
getRequiredParam(java.lang.String paramName)
Get the parameter
paramName from the request and convert
it to a Long . |
java.lang.Long |
getRequiredParamAsLong(java.lang.String paramName)
Get the parameter
paramName from the request
A BadParameterException is thrown if the
parameter is not present in the request or is empty |
java.lang.String |
getRequiredParamAsString(java.lang.String paramName)
Get the parameter
paramName from the request
A BadParameterException is thrown if the
parameter is not present in the request or is empty |
User |
getUserFromUIDParameter()
Get the user on the request based on the "uid" paramter.
|
WebSession |
getWebSession()
Retrieves the currently Logged in user's pxt session.
|
boolean |
hasParam(java.lang.String name)
Get whether a parameter is present in the request.
|
boolean |
isJavaScriptEnabled()
Returns if javascript is enabled/not in this page.
|
boolean |
isRequestedExport()
If this current Request includes a parameter to indicate the User is attempting
to produce an export of viewable data then return true.
|
boolean |
isSubmitted()
Simple util to check if the Form on a page was submitted
This needs to be used in conjuction with rhn submitted
taglib..
|
ActivationKey |
lookupAndBindActivationKey()
Return the Activation Key with the ID given by the request's
TOKEN_ID
parameter. |
KickstartData |
lookupAndBindKickstartData()
Return the KickstartData with the ID given by the request's
KICKSTART_ID
parameter. |
Org |
lookupAndBindOrg()
Return the Org with the ID given by the request's
TOKEN_ID
parameter. |
Server |
lookupAndBindServer()
Return the server with the ID given by the request's
SID
parameter. |
ManagedServerGroup |
lookupAndBindServerGroup()
Return the ServerGroup with the ID given by the request's
SERVER_GROUP_ID
parameter. |
Errata |
lookupErratum()
Return the erratum with the ID given by the request's
ERRATA_ID parameter |
Server |
lookupServer()
Return the server with the ID given by the request's
SID
parameter |
java.util.Map<java.lang.String,java.lang.Object> |
makeParamMapWithPagination()
Creates a hashmap with pagination vars added.
|
java.lang.String |
processPagination()
Get the value for the lowest part of the list to display.
|
void |
requirePost()
verify that the request is a POST and throw an exception otherwise.
|
boolean |
wasDispatched(java.lang.String messageKey)
Examines a submit action of the name "dispatch"
with the i18n'ed value of the key passed in.
|
public static final java.lang.String LABEL
public static final java.lang.String USER_ID
public static final java.lang.String ORG_ID
public static final java.lang.String ERRATA_ID
public static final java.lang.String SID
public static final java.lang.String SID1
public static final java.lang.String CID
public static final java.lang.String PRID
public static final java.lang.String COBBLER_ID
public static final java.lang.String FILTER_STRING
public static final java.lang.String PREVIOUS_FILTER_STRING
public static final java.lang.String LIST_DISPLAY_EXPORT
public static final java.lang.String TOKEN_ID
public static final java.lang.String LIST_SORT
public static final java.lang.String SORT_ORDER
public static final java.lang.String SORT_ASC
public static final java.lang.String SORT_DESC
public static final java.lang.String METHOD_ID
public static final java.lang.String KICKSTART_ID
public static final java.lang.String KSTREE_ID
public static final java.lang.String KEY_ID
public static final java.lang.String FILE_LIST_ID
public static final java.lang.String KICKSTART_SCRIPT_ID
public static final java.lang.String CONFIG_FILE_ID
public static final java.lang.String SERVER_GROUP_ID
public static final java.lang.String NAME
public static final java.lang.String ACTIVATION_KEY
public static final java.lang.String KICKSTART
public static final java.lang.String ORG
public static final java.lang.String SYSTEM
public static final java.lang.String SERVER_GROUP
public static final java.lang.String KICKSTART_SESSION
public static final java.lang.String REQUESTED_URI
public static final java.lang.String KSTREE
public static final java.lang.String KICKSTART_STATE_DESC
public static final java.lang.String PAGE_LIST
public static final java.lang.String DISPATCH
public static final java.lang.String CONFIRM
public static final java.lang.String FILTER_KEY
public static final java.lang.String NO_SCRIPT
public static final java.lang.String MODE
public static final java.lang.String POST
public RequestContext(javax.servlet.http.HttpServletRequest req0)
req0
req0
- the request from which to look up objectspublic javax.servlet.http.HttpServletRequest getRequest()
public User getCurrentUser()
public User getUserFromUIDParameter()
public Errata lookupErratum() throws java.lang.IllegalArgumentException
ERRATA_ID
parameterERRATA_ID
parameterBadParameterException
- if the request
does not contain the required parameter, or if the parameter can not be converted
to a Long
java.lang.IllegalArgumentException
- if no erratum with the ID given in
the request can be foundpublic Server lookupServer() throws java.lang.IllegalArgumentException
SID
parameterSID
parameterBadParameterException
- if the request
does not contain the required parameter, or if the parameter can not be converted
to a Long
java.lang.IllegalArgumentException
- if no server with the ID given in the
request can be foundpublic Server lookupAndBindServer() throws java.lang.IllegalArgumentException
SID
parameter. Puts the server in the request attributes.SID
parameterBadParameterException
- if the request
does not contain the required parameter, or if the parameter can not be converted
to a Long
java.lang.IllegalArgumentException
- if no server with the ID given in the
request can be foundpublic ActivationKey lookupAndBindActivationKey()
TOKEN_ID
parameter. Puts the activation key in the request attributes.TOKEN_ID
parameterBadParameterException
- if the request
does not contain the required parameter, or if the parameter can not be converted
to a Long
java.lang.IllegalArgumentException
- if no Activation Key with the ID given in the
request can be foundpublic Org lookupAndBindOrg()
TOKEN_ID
parameter. Puts the Orgin the request attributes.TOKEN_ID
parameterBadParameterException
- if the request
does not contain the required parameter, or if the parameter can not be converted
to a Long
java.lang.IllegalArgumentException
- if no Org with the ID given in the
request can be foundpublic KickstartData lookupAndBindKickstartData()
KICKSTART_ID
parameter. Puts the activation key in the request attributes.KICKSTART_ID
parameterBadParameterException
- if the request
does not contain the required parameter, or if the parameter can not be converted
to a Long
java.lang.IllegalArgumentException
- if no Kickstart Data with the ID given in the
request can be foundpublic ManagedServerGroup lookupAndBindServerGroup()
SERVER_GROUP_ID
parameter. Puts the ServerGroupin the request attributes.SERVER_GROUP_ID
java.lang.IllegalArgumentException
- if no ServerGroup with the ID given in the
request can be foundpublic java.lang.String getParam(java.lang.String paramName, boolean required)
paramName
from the request. If
required
is true
, this method will never
return null
; instead, it will throw a
BadParameterException
if the parameter is not in the
request. If required
is false
, the return
value can be null
.paramName
- the name of the parameterrequired
- whether this parameter must be presentpublic boolean hasParam(java.lang.String name)
name
- The parameter name.public java.lang.Long getParamAsLong(java.lang.String param)
param
- Name of request parameter to be converted.null
if the parameter is blank.BadParameterException
- if the parameter param
can
not be converted to a Longpublic java.lang.Long getRequiredParam(java.lang.String paramName)
paramName
from the request and convert
it to a Long
. A BadParameterException is thrown if the
parameter is not present in the request or can not be converted.paramName
- the name of the parameterLong
public java.lang.String getRequiredParamAsString(java.lang.String paramName)
paramName
from the request
A BadParameterException is thrown if the
parameter is not present in the request or is emptyparamName
- the name of the parameterLong
public java.lang.Long getRequiredParamAsLong(java.lang.String paramName)
paramName
from the request
A BadParameterException is thrown if the
parameter is not present in the request or is emptyparamName
- the name of the parameterLong
public boolean isRequestedExport()
public WebSession getWebSession()
public java.lang.String processPagination()
public java.util.Map<java.lang.String,java.lang.Object> makeParamMapWithPagination()
public java.lang.String buildPageLink(java.lang.String name, java.lang.String value)
name
- of parameter to addvalue
- value of paramterpublic void copyParamToAttributes(java.lang.String paramId)
paramId
- the param to copypublic boolean wasDispatched(java.lang.String messageKey)
messageKey
- the message key to be i18ned.public boolean isJavaScriptEnabled()
public boolean isSubmitted()
public void requirePost()