edu.uoc.pfc.j2ee.jalonsod.mtp.request
Interface RequestData

All Known Subinterfaces:
RequestDataPrivate
All Known Implementing Classes:
HttpRequestData

public interface RequestData

File: RequestData.java Created: 2012-04-29 RequestData is the façade API for applications using the framework. It's also the store of the MTP, session and request information during the request life cycle.

Applications using the framework must use this API to interact with the framework. The life of an requestData object is the same as the request.

Author:
José Alonso de Motta

Field Summary
static java.lang.String MTP_LOGGER
          Logger name of the framework.
static java.lang.String REQUEST_EXCEPTION
          The request attribute name of the exception thrown in the request life-cycle.
static java.lang.String REQUEST_REQUESTDATA_ATTRIBUTE
          The request attribute name of the RequestData object.
static int VALIDATION_ERROR_LOADING_PARAMETER_VALUES_INTO_MODEL
          Request has not been validated, because some fields cannot be loaded into application model object.
static int VALIDATION_ERROR_STAGE_1_DATATYPE_CONVERSION
          Request has not been validated, because datatype conversion has failed.
static int VALIDATION_ERROR_STAGE_2_REQUIRED_FIELDS
          Request has not been validated, because some required fields are empty.
static int VALIDATION_ERROR_STAGE_3_FIELD_VALIDATION_FUNCTIONS
          Request has not been validated, because some field validation functions has returned with error.
static int VALIDATION_ERROR_STAGE_4_MODEL_VALIDATION_FUNCTION
          Request has not been validated, because the validation function of the model has returned with error.
static int VALIDATION_NO_VALIDATED
          Request has not been validated, because no validation is done.
static int VALIDATION_OK
          Request has been validated, all stages are passed right.
 
Method Summary
 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.
 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.
 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.
 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.
 void setRequestAttribute(java.lang.String attributeName, java.lang.Object attributeObject)
          Stores an attribute in 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.
 

Field Detail

MTP_LOGGER

static final java.lang.String MTP_LOGGER
Logger name of the framework.

See Also:
Constant Field Values

REQUEST_REQUESTDATA_ATTRIBUTE

static final java.lang.String REQUEST_REQUESTDATA_ATTRIBUTE
The request attribute name of the RequestData object.

See Also:
Constant Field Values

REQUEST_EXCEPTION

static final java.lang.String REQUEST_EXCEPTION
The request attribute name of the exception thrown in the request life-cycle. If there is no exception thrown, the attribute doesn't exists.

See Also:
Constant Field Values

VALIDATION_NO_VALIDATED

static final int VALIDATION_NO_VALIDATED
Request has not been validated, because no validation is done.

See Also:
getValidationStatus(), Constant Field Values

VALIDATION_ERROR_STAGE_1_DATATYPE_CONVERSION

static final int VALIDATION_ERROR_STAGE_1_DATATYPE_CONVERSION
Request has not been validated, because datatype conversion has failed.

See Also:
getValidationStatus(), Constant Field Values

VALIDATION_ERROR_STAGE_2_REQUIRED_FIELDS

static final int VALIDATION_ERROR_STAGE_2_REQUIRED_FIELDS
Request has not been validated, because some required fields are empty.

See Also:
getValidationStatus(), Constant Field Values

VALIDATION_ERROR_STAGE_3_FIELD_VALIDATION_FUNCTIONS

static final int VALIDATION_ERROR_STAGE_3_FIELD_VALIDATION_FUNCTIONS
Request has not been validated, because some field validation functions has returned with error.

See Also:
getValidationStatus(), Constant Field Values

VALIDATION_ERROR_LOADING_PARAMETER_VALUES_INTO_MODEL

static final int VALIDATION_ERROR_LOADING_PARAMETER_VALUES_INTO_MODEL
Request has not been validated, because some fields cannot be loaded into application model object.

See Also:
getValidationStatus(), Constant Field Values

VALIDATION_ERROR_STAGE_4_MODEL_VALIDATION_FUNCTION

static final int VALIDATION_ERROR_STAGE_4_MODEL_VALIDATION_FUNCTION
Request has not been validated, because the validation function of the model has returned with error.

See Also:
getValidationStatus(), Constant Field Values

VALIDATION_OK

static final int VALIDATION_OK
Request has been validated, all stages are passed right.

See Also:
getValidationStatus(), Constant Field Values
Method Detail

getConfigurator

Configurator getConfigurator()
Returns the main configuration object.

Returns:
the configuration main object.
See Also:
Configurator

getLanguages

java.util.Hashtable<java.lang.String,Language> getLanguages()
Returns the application supported languages.

Returns:
the list of application supported languages.
See Also:
Language

createSession

void createSession()
Creates a new session for the user (framework creates a new session for the request if it does not has one).

This is done automatically by the framework, but application can create a new session for the request.

See Also:
hasValidSession(), logoutSession()

hasValidSession

boolean hasValidSession()
Checks if the request has a valid session.

Returns:
true if request has a valid session, false otherwise.
See Also:
createSession(), logoutSession()

logoutSession

void logoutSession()
Invalidates the session of the request.

See Also:
createSession(), hasValidSession()

getSessionAttribute

java.lang.Object getSessionAttribute(java.lang.String attributeName)
Returns an attribute stored previously in the session.

Parameters:
attributeName - the name of the attribute to obtain.
Returns:
the object stored in the session, or null if it's empty or doesn't exists.

setSessionAttribute

void setSessionAttribute(java.lang.String attributeName,
                         java.lang.Object attributeObject)
Stores an attribute into the session.

Parameters:
attributeName - the name of the attribute to store.
attributeObject - the object to store in the session.

deleteSessionAttribute

void deleteSessionAttribute(java.lang.String attributeName)
Removes an attribute from the session.

Parameters:
attributeName - the name of the attribute to remove.

getRoles

java.util.Hashtable<java.lang.String,Role> getRoles()
Gets the roles granted to the session.

Returns:
the list of roles granted to the session.
See Also:
Role

setRoles

void setRoles(java.util.Hashtable<java.lang.String,Role> sessionRoles)
Sets the roles granted to the session.

Parameters:
sessionRoles - the list of roles to grant to the session. The previous granted roles are replaced with these.
See Also:
Role

getUserLanguage

Language getUserLanguage()
Gets the language inferred for the request, based on previous setUserLanguage call, request agent supported languages or default application language.

Returns:
the language inferred for the request.
See Also:
Language

setUserLanguage

void setUserLanguage(Language userLanguage)
Sets the language for the session. This language is stored in the session for use on the next requests from the same session.

Parameters:
userLanguage - the language to assign to the session.
See Also:
Language

getMessage

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.

Parameters:
key - the key string to match with a languageEntry key.
Returns:
a string message in request inferred language or null if not found.
See Also:
Language, LanguageEntry

getRequestAttribute

java.lang.Object getRequestAttribute(java.lang.String attributeName)
Returns an attribute stored previously in the request.

Parameters:
attributeName - the name of the attribute to obtain.
Returns:
the object stored in the request with supplied name, or null if it's empty or doesn't exists.

setRequestAttribute

void setRequestAttribute(java.lang.String attributeName,
                         java.lang.Object attributeObject)
Stores an attribute in the request. The life of the attribute is the same as the request.

Parameters:
attributeName - the name of the attribute to store.
attributeObject - the object to store in the request.

getRequestParameter

java.lang.String getRequestParameter(java.lang.String parameterName)
Obtains a parameter from the request.

Parameters:
parameterName - the name of the parameter to obtain.
Returns:
the string with the parameter value or null if the parameter doesn't exists.

getModel

Model getModel()
Gets the model configuration object selected for the request, or null if the request has no model.

Returns:
the model configuration object.
See Also:
Model

getModelInstance

java.lang.Object getModelInstance()
Returns the application model instance object.

Returns:
the application model instance object.

getFormInstance

FormInstance getFormInstance()
Returns the formInstance object with the parameters of the request associated with the model.

Returns:
the formInstance configuration object.
See Also:
FormInstance

getModelResponse

java.lang.String getModelResponse()
Returns the response string returned by the run method of the application model object.

Returns:
the response string returned by the run method of the application model object.

getResult

Result getResult()
Returns the result object of the request.

Returns:
the result object of the request or null if it doesn't exists.
See Also:
Model, Result

getView

java.lang.String getView()
Returns the view name to which the response will be redirected.

Returns:
the view name selected for the response.

isAuthorized

boolean isAuthorized()
Returns the request session authorization status to run the model.

Returns:
true if request session has been authorized, or false otherwise.

getValidationStatus

int getValidationStatus()
Returns the request validation status.

Returns:
the validation status of the request. It's one of the RequestData.VALIDATION_* values.

isValidated

boolean isValidated()
Returns if the request has passed all validations.

Returns:
true if the request has passed all validations, false otherwise.