pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.service.request
Class ServiceRequestImpl

java.lang.Object
  extended by org.torweg.pulse.service.request.ServiceRequestImpl
All Implemented Interfaces:
ServiceRequest

public final class ServiceRequestImpl
extends java.lang.Object
implements ServiceRequest

The request sent to the service.

The ServiceRequestImpl contains the Command and ServiceSession associated to the request to the pulse service. It also provides access to Cookies and TemporaryFiles belonging to the request.

Moreover, the ServiceRequestImpl takes care of authenticating the User.

Version:
$Revision: 1873 $
Author:
Thomas Weber

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.torweg.pulse.service.request.ServiceRequest
ServiceRequest.SessionMode
 
Constructor Summary
ServiceRequestImpl()
          protected constructor. for internal use only.
 
Method Summary
 void addCookie(Cookie cookie)
          adds the given Cookie to the response.
 void addUploadedFile(IUploadedFile file)
          adds an IUploadedFile to the list.
 AcceptLanguages getAcceptLanguages()
          parses the accept-language header and returns the language and country components of the first locale.
 java.lang.String getBaseURI()
          get the base URI to the servlet.
 Command getCommand()
          get the Command sent to the pulse service.
 java.util.Collection<Cookie> getCookies()
          get all Cookies sent by the browser.
 EventManagerImpl getEventManager()
          returns all events produced by bundles in an EventManagerImpl.
 javax.servlet.http.HttpServletRequest getHttpServletRequest()
          get access to the underlying HttpServletRequest.
 javax.servlet.http.HttpServletResponse getHttpServletResponse()
          get access to the underlying HttpServletRequest.
 long getIntelliCacheMaxAge()
          returns the maximum age for a dynamic page cached using IntelliCache to be considered for 304 Not Modified responses upon a stateless ServiceSession.
 java.util.Locale getLocale()
          returns the currently set Locale for the request.
 GeoLocation getRequestOrigin()
          returns the country the request is made from or null, if the country could not be resolved by Lifecycle.getGeoLocationProvider() .
 ServiceSession getSession()
          get the ServiceSession associated to the request.
 ServiceRequest.SessionMode getSessionMode()
          indicates whether the session shall be used with URL based session IDs and Cookies or with Cookies only.
 java.util.List<IUploadedFile> getUploadedFiles()
          get all files that where uploaded during the request.
 User getUser()
          returns the User associated with the request.
 ServiceRequestImpl init(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          initializes the ServiceRequestImpl from the HttpServletRequest.
 void refreshUser()
          refreshes the internal User information from the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceRequestImpl

public ServiceRequestImpl()
protected constructor. for internal use only.

Method Detail

init

public ServiceRequestImpl init(javax.servlet.http.HttpServletRequest req,
                               javax.servlet.http.HttpServletResponse res)
initializes the ServiceRequestImpl from the HttpServletRequest.

Specified by:
init in interface ServiceRequest
Parameters:
req - the request sent to the controller servlet
res - the response used by the controller servlet
Returns:
the initialised service request

getBaseURI

public java.lang.String getBaseURI()
Description copied from interface: ServiceRequest
get the base URI to the servlet.

Specified by:
getBaseURI in interface ServiceRequest
Returns:
Returns the baseURI.

getCommand

public Command getCommand()
Description copied from interface: ServiceRequest
get the Command sent to the pulse service.

Specified by:
getCommand in interface ServiceRequest
Returns:
the command associated with the service request
See Also:
ServiceRequest.getCommand()

getAcceptLanguages

public AcceptLanguages getAcceptLanguages()
parses the accept-language header and returns the language and country components of the first locale.

Specified by:
getAcceptLanguages in interface ServiceRequest
Returns:
the split locale

getIntelliCacheMaxAge

public long getIntelliCacheMaxAge()
returns the maximum age for a dynamic page cached using IntelliCache to be considered for 304 Not Modified responses upon a stateless ServiceSession.

Specified by:
getIntelliCacheMaxAge in interface ServiceRequest
Returns:
the maximum age in milliseconds

getSession

public ServiceSession getSession()
Description copied from interface: ServiceRequest
get the ServiceSession associated to the request.

Specified by:
getSession in interface ServiceRequest
Returns:
the serviceSession associated with the service request
See Also:
ServiceRequest.getSession()

addUploadedFile

public void addUploadedFile(IUploadedFile file)
adds an IUploadedFile to the list.

Parameters:
file - the uploaded file

getUploadedFiles

public java.util.List<IUploadedFile> getUploadedFiles()
Description copied from interface: ServiceRequest
get all files that where uploaded during the request.

Specified by:
getUploadedFiles in interface ServiceRequest
Returns:
a list of all files which were uploaded with the service request
See Also:
ServiceRequest.getUploadedFiles()

getRequestOrigin

public GeoLocation getRequestOrigin()
returns the country the request is made from or null, if the country could not be resolved by Lifecycle.getGeoLocationProvider() .

Specified by:
getRequestOrigin in interface ServiceRequest
Returns:
the country the request is made from or null, if the country could not be resolved

getLocale

public java.util.Locale getLocale()
Description copied from interface: ServiceRequest
returns the currently set Locale for the request.

Specified by:
getLocale in interface ServiceRequest
Returns:
the locale associated with the service request
See Also:
ServiceRequest.getLocale()

getUser

public User getUser()
Description copied from interface: ServiceRequest
returns the User associated with the request.

Specified by:
getUser in interface ServiceRequest
Returns:
the user context associated with the service request
See Also:
ServiceRequest.getUser()

getEventManager

public EventManagerImpl getEventManager()
returns all events produced by bundles in an EventManagerImpl.

Specified by:
getEventManager in interface ServiceRequest
Returns:
the EventManagerImpl

getCookies

public java.util.Collection<Cookie> getCookies()
Description copied from interface: ServiceRequest
get all Cookies sent by the browser.

Specified by:
getCookies in interface ServiceRequest
Returns:
all cookies associated with the service request
See Also:
ServiceRequest.getCookies()

addCookie

public void addCookie(Cookie cookie)
adds the given Cookie to the response.

Specified by:
addCookie in interface ServiceRequest
Parameters:
cookie - the cookie to add
See Also:
Cookie

getHttpServletRequest

public javax.servlet.http.HttpServletRequest getHttpServletRequest()
get access to the underlying HttpServletRequest.

Specified by:
getHttpServletRequest in interface ServiceRequest
Returns:
the underlying HttpServletRequest

getHttpServletResponse

public javax.servlet.http.HttpServletResponse getHttpServletResponse()
get access to the underlying HttpServletRequest.

Specified by:
getHttpServletResponse in interface ServiceRequest
Returns:
the underlying HttpServletRequest

getSessionMode

public ServiceRequest.SessionMode getSessionMode()
indicates whether the session shall be used with URL based session IDs and Cookies or with Cookies only.

Specified by:
getSessionMode in interface ServiceRequest
Returns:
true, if only cookie based sessions are to be used

refreshUser

public void refreshUser()
refreshes the internal User information from the session.

Specified by:
refreshUser in interface ServiceRequest