|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.uoc.pfc.j2ee.jalonsod.mtp.request.HttpRequestData
public class HttpRequestData
File: HttpRequestData.java
Created: 2012-04-30
HttpRequestData is the HTTP implementation of the RequestDataPrivate. Applications should not use
directly this class, they must use the requestData
interface.
RequestData
,
RequestDataPrivate
Field Summary | |
---|---|
private boolean |
authorized
The authorization status of the request. |
private Configurator |
configurator
The framework configuration of the application. |
private FormInstance |
formInstance
The formInstance object with the parameter values of the request associated with
the model . |
private Model |
model
The model configuraction selected for the request. |
private java.lang.Object |
modelInstance
The application model object. |
private java.lang.String |
modelResponse
The string that the application model object run method has returned. |
private javax.servlet.http.HttpServletRequest |
request
The request received from the user. |
private Language |
requestLanguage
The language inferred to the request. |
private Result |
result
The result inferred to the request. |
private int |
validationStatus
The validation status of the request. |
private java.lang.String |
view
The view selected to redirect the response (like a jsp page). |
Fields inherited from interface edu.uoc.pfc.j2ee.jalonsod.mtp.request.RequestDataPrivate |
---|
REQUEST_MODEL_ATTRIBUTE, SESSION_LANGUAGE_ATTRIBUTE, SESSION_ROLES_ATTRIBUTE |
Fields inherited from interface edu.uoc.pfc.j2ee.jalonsod.mtp.request.RequestData |
---|
MTP_LOGGER, REQUEST_EXCEPTION, REQUEST_REQUESTDATA_ATTRIBUTE, VALIDATION_ERROR_LOADING_PARAMETER_VALUES_INTO_MODEL, VALIDATION_ERROR_STAGE_1_DATATYPE_CONVERSION, VALIDATION_ERROR_STAGE_2_REQUIRED_FIELDS, VALIDATION_ERROR_STAGE_3_FIELD_VALIDATION_FUNCTIONS, VALIDATION_ERROR_STAGE_4_MODEL_VALIDATION_FUNCTION, VALIDATION_NO_VALIDATED, VALIDATION_OK |
Constructor Summary | |
---|---|
HttpRequestData(javax.servlet.http.HttpServletRequest request)
Constructor. |
Method Summary | |
---|---|
void |
authorize(boolean authorized)
Sets the request authorization status to run the model. |
void |
createSession()
Creates a new session for the user (framework creates a new session for the request if it does not has one). |
void |
deleteSessionAttribute(java.lang.String attributeName)
Removes an attribute from the session. |
Configurator |
getConfigurator()
Returns the main configuration object. |
FormInstance |
getFormInstance()
Returns the formInstance object with the parameters of the request associated
with the model . |
java.util.Hashtable<java.lang.String,Language> |
getLanguages()
Returns the application supported languages. |
java.lang.String |
getMessage(java.lang.String key)
Obtains a message text from a languageEntry in the request user's language with
the supplied key. |
Model |
getModel()
Gets the model configuration object selected for the request, or
null if the request has no model. |
java.lang.Object |
getModelInstance()
Returns the application model instance object. |
java.lang.String |
getModelResponse()
Returns the response string returned by the run method of the application model
object. |
private javax.servlet.http.HttpServletRequest |
getRequest()
|
java.lang.Object |
getRequestAttribute(java.lang.String attributeName)
Returns an attribute stored previously in the request. |
java.lang.String |
getRequestParameter(java.lang.String parameterName)
Obtains a parameter from the request. |
Result |
getResult()
Returns the result object of the request. |
java.util.Hashtable<java.lang.String,Role> |
getRoles()
Gets the roles granted to the session. |
private javax.servlet.http.HttpSession |
getSession()
|
java.lang.Object |
getSessionAttribute(java.lang.String attributeName)
Returns an attribute stored previously in the session. |
Language |
getUserLanguage()
Gets the language inferred for the request, based on previous
setUserLanguage call, request agent supported languages or default application
language. |
int |
getValidationStatus()
Returns the request validation status. |
java.lang.String |
getView()
Returns the view name to which the response will be redirected. |
boolean |
hasValidSession()
Checks if the request has a valid session. |
private Language |
inferUserLanguage()
Algorithm to infer the language of the request based on: the language of the session if it was set on previous request. |
boolean |
isAuthorized()
Returns the request session authorization status to run the model. |
boolean |
isValidated()
Returns if the request has passed all validations. |
void |
logoutSession()
Invalidates the session of the request. |
private void |
setConfigurator(Configurator configurator)
|
private void |
setDefaultRoles()
Stores the default roles defined by the configurator into the session. |
void |
setFormInstance(FormInstance formInstance)
Sets the formInstance object with the parameters of the request associated with
the model . |
void |
setModel(Model model)
Sets the model configuration object for the request. |
void |
setModelInstance(java.lang.Object modelInstance)
Sets the application model object. |
void |
setModelResponse(java.lang.String modelResponse)
Sets the response string returned by the run method of the application model
object. |
private void |
setRequest(javax.servlet.http.HttpServletRequest request)
|
void |
setRequestAttribute(java.lang.String attributeName,
java.lang.Object attributeObject)
Stores an attribute in the request. |
private void |
setRequestLanguage(Language requestLanguage)
Sets the language of the request. |
void |
setResult(Result result)
Sets the result object of the request. |
void |
setRoles(java.util.Hashtable<java.lang.String,Role> sessionRoles)
Sets the roles granted to the session. |
void |
setSessionAttribute(java.lang.String attributeName,
java.lang.Object attributeObject)
Stores an attribute into the session. |
void |
setUserLanguage(Language userLanguage)
Sets the language for the session. |
void |
setValidationStatus(int validationStatus)
Sets the request validation status. |
void |
setView(java.lang.String view)
Sets the view name to which response will be redirected. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private javax.servlet.http.HttpServletRequest request
private Configurator configurator
private Language requestLanguage
language
inferred to the request. It's one of the languages from the
configurator
.
private Model model
ModelMapper
stage of the request. It's one of the models from the
configurator
.
private java.lang.String modelResponse
string
that the application model object run method has returned. It's value
is stored after the ModelRunner
stage of the request. It can be null.
private Result result
ViewMapper
stage of the request. It's one of the results from the configurator
associated
with the model
selected for the request. It can be null.
private java.lang.String view
ViewMapper
stage of the request.
private java.lang.Object modelInstance
ModelMapper
stage
of the request.
private FormInstance formInstance
formInstance
object with the parameter values of the request associated with
the model
. It's value is stored during the Validator
stage of the
request.
private boolean authorized
AccessControl
stage of the request. false
means that request
is not authorized, true
means request is authorized to execute.
private int validationStatus
RequestData.VALIDATION_*
constants. The request is full validated when the
value is RequestData.VALIDATION_OK
Constructor Detail |
---|
public HttpRequestData(javax.servlet.http.HttpServletRequest request) throws ConfiguratorException
request
- the request object received from the user.
ConfiguratorException
- throws when the configurator
has any problem.Method Detail |
---|
public Configurator getConfigurator()
RequestData
getConfigurator
in interface RequestData
Configurator
private void setConfigurator(Configurator configurator)
public java.util.Hashtable<java.lang.String,Language> getLanguages()
RequestData
getLanguages
in interface RequestData
Language
public void createSession()
RequestData
This is done automatically by the framework, but application can create a new session for the request.
createSession
in interface RequestData
RequestData.hasValidSession()
,
RequestData.logoutSession()
public boolean hasValidSession()
RequestData
hasValidSession
in interface RequestData
true
if request has a valid session, false
otherwise.RequestData.createSession()
,
RequestData.logoutSession()
private javax.servlet.http.HttpSession getSession()
public void logoutSession()
RequestData
logoutSession
in interface RequestData
RequestData.createSession()
,
RequestData.hasValidSession()
public java.lang.Object getSessionAttribute(java.lang.String attributeName)
RequestData
getSessionAttribute
in interface RequestData
attributeName
- the name of the attribute to obtain.
null
if it's empty or
doesn't exists.public void setSessionAttribute(java.lang.String attributeName, java.lang.Object attributeObject)
RequestData
setSessionAttribute
in interface RequestData
attributeName
- the name of the attribute to store.attributeObject
- the object to store in the session.public void deleteSessionAttribute(java.lang.String attributeName)
RequestData
deleteSessionAttribute
in interface RequestData
attributeName
- the name of the attribute to remove.public java.util.Hashtable<java.lang.String,Role> getRoles()
RequestData
getRoles
in interface RequestData
Role
public void setRoles(java.util.Hashtable<java.lang.String,Role> sessionRoles)
RequestData
setRoles
in interface RequestData
sessionRoles
- the list of roles to grant to the session. The previous granted roles
are replaced with these.Role
private void setDefaultRoles()
configurator
into the session.
public Language getUserLanguage()
RequestData
language
inferred for the request, based on previous
setUserLanguage
call, request agent supported languages or default application
language.
getUserLanguage
in interface RequestData
language
inferred for the request.Language
public void setUserLanguage(Language userLanguage)
RequestData
setUserLanguage
in interface RequestData
userLanguage
- the language
to assign to the session.Language
private void setRequestLanguage(Language requestLanguage)
language
of the request.
requestLanguage
- the language
assigned to the request.private Language inferUserLanguage()
public java.lang.String getMessage(java.lang.String key)
RequestData
languageEntry
in the request user's language with
the supplied key.
getMessage
in interface RequestData
key
- the key string to match with a languageEntry
key.
string
message in request inferred language or null
if
not found.Language
,
LanguageEntry
private javax.servlet.http.HttpServletRequest getRequest()
private void setRequest(javax.servlet.http.HttpServletRequest request)
public java.lang.Object getRequestAttribute(java.lang.String attributeName)
RequestData
getRequestAttribute
in interface RequestData
attributeName
- the name of the attribute to obtain.
null
if it's empty or doesn't exists.public void setRequestAttribute(java.lang.String attributeName, java.lang.Object attributeObject)
RequestData
setRequestAttribute
in interface RequestData
attributeName
- the name of the attribute to store.attributeObject
- the object to store in the request.public java.lang.String getRequestParameter(java.lang.String parameterName)
RequestData
getRequestParameter
in interface RequestData
parameterName
- the name of the parameter to obtain.
string
with the parameter value or null
if
the parameter doesn't exists.public Model getModel()
RequestData
model
configuration object selected for the request, or
null
if the request has no model.
getModel
in interface RequestData
Model
public void setModel(Model model)
RequestDataPrivate
model
configuration object for the request.
This is done by the modelMapper
.
setModel
in interface RequestDataPrivate
model
- the model
configuration object to set into the request.Model
public java.lang.Object getModelInstance()
RequestData
getModelInstance
in interface RequestData
public void setModelInstance(java.lang.Object modelInstance)
RequestDataPrivate
This is done by the modelMapper
.
setModelInstance
in interface RequestDataPrivate
modelInstance
- the application model object.ModelMapper
public FormInstance getFormInstance()
RequestData
formInstance
object with the parameters of the request associated
with the model
.
getFormInstance
in interface RequestData
formInstance
configuration object.FormInstance
public void setFormInstance(FormInstance formInstance)
RequestDataPrivate
formInstance
object with the parameters of the request associated with
the model
.
This is done in the validation stage by the validator
.
setFormInstance
in interface RequestDataPrivate
formInstance
- the formInstance object with the parameters of the request associated
with the model
.public java.lang.String getModelResponse()
RequestData
string
returned by the run method of the application model
object.
getModelResponse
in interface RequestData
string
returned by the run method of the application model
object.public void setModelResponse(java.lang.String modelResponse)
RequestDataPrivate
string
returned by the run method of the application model
object.
This is done by the framework when the model run method finishes.
setModelResponse
in interface RequestDataPrivate
modelResponse
- the response string
returned by the run method of the
application model object.public Result getResult()
RequestData
result
object of the request.
getResult
in interface RequestData
result
object of the request or null
if it doesn't exists.Model
,
Result
public void setResult(Result result)
RequestDataPrivate
This is done by the viewMapper
.
setResult
in interface RequestDataPrivate
result
- the result object of the request.ViewMapper
public java.lang.String getView()
RequestData
getView
in interface RequestData
public void setView(java.lang.String view)
RequestDataPrivate
This is done by the viewMapper
.
setView
in interface RequestDataPrivate
public boolean isAuthorized()
RequestData
isAuthorized
in interface RequestData
true
if request session has been authorized, or false
otherwise.public void authorize(boolean authorized)
RequestDataPrivate
This is done by the accessControl
of the framework.
authorize
in interface RequestDataPrivate
authorized
- true
if request is authorized, false
otherwise.public int getValidationStatus()
RequestData
getValidationStatus
in interface RequestData
RequestData.VALIDATION_*
values.public void setValidationStatus(int validationStatus)
RequestDataPrivate
This is done by the framework in validation stage.
setValidationStatus
in interface RequestDataPrivate
validationStatus
- the validation status of the framework. It's one of the
RequestData.VALIDATION_*
values.public boolean isValidated()
RequestData
isValidated
in interface RequestData
true
if the request has passed all validations, false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |