org.restlet.util
Class WrapperResponse

java.lang.Object
  extended by org.restlet.data.Message
      extended by org.restlet.data.Response
          extended by org.restlet.util.WrapperResponse

public class WrapperResponse
extends Response

Request wrapper. Useful for application developer who need to enrich the request with application related properties and behavior.

Author:
Jerome Louvel
See Also:
The decorator (aka wrapper) pattern

Constructor Summary
WrapperResponse(Response wrappedResponse)
          Constructor.
 
Method Summary
 java.util.Set<Method> getAllowedMethods()
          Returns the set of methods allowed on the requested resource.
 java.util.Map<java.lang.String,java.lang.Object> getAttributes()
          Returns a modifiable attributes map that can be used by developers to save information relative to the message.
 ChallengeRequest getChallengeRequest()
          Deprecated. Use the getChallengeRequests() instead.
 java.util.List<ChallengeRequest> getChallengeRequests()
          Returns the list of authentication requests sent by an origin server to a client.
 Series<CookieSetting> getCookieSettings()
          Returns the cookie settings provided by the server.
 java.util.Set<Dimension> getDimensions()
          Returns the set of selecting dimensions on which the response entity may vary.
 Representation getEntity()
          Returns the entity representation.
 DomRepresentation getEntityAsDom()
          Returns the entity as a DOM representation.
Note that this triggers the parsing of the entity into a reusable DOM document stored in memory.
This method and the related getEntity*() methods can only be invoked once.
 Form getEntityAsForm()
          Returns the entity as a DOM representation.
Note that this triggers the parsing of the entity into a reusable DOM document stored in memory.
This method and the related getEntity*() methods can only be invoked once.
 java.lang.Object getEntityAsObject()
          Deprecated. Since 1.1, the ConverterService is deprecated, with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.
 SaxRepresentation getEntityAsSax()
          Returns the entity as a SAX representation.
Note that this kind of representation can only be parsed once.
 Reference getLocationRef()
          Returns the reference that the client should follow for redirections or resource creations.
 Reference getRedirectRef()
          Deprecated. Use the getLocationRef() method instead.
 Request getRequest()
          Returns the associated request
 ServerInfo getServerInfo()
          Returns the server-specific information.
 Status getStatus()
          Returns the status.
protected  Response getWrappedResponse()
          Returns the wrapped response.
 boolean isConfidential()
          Indicates if the call came over a confidential channel such as an SSL-secured connection.
 boolean isEntityAvailable()
          Indicates if a content is available and can be sent.
 void redirectPermanent(Reference targetRef)
          Permanently redirects the client to a target URI.
 void redirectPermanent(java.lang.String targetUri)
          Permanently redirects the client to a target URI.
 void redirectSeeOther(Reference targetRef)
          Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource.
 void redirectSeeOther(java.lang.String targetUri)
          Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource.
 void redirectTemporary(Reference targetRef)
          Temporarily redirects the client to a target URI.
 void redirectTemporary(java.lang.String targetUri)
          Temporarily redirects the client to a target URI.
 void setChallengeRequest(ChallengeRequest request)
          Sets the authentication request sent by an origin server to a client.
 void setChallengeRequests(java.util.List<ChallengeRequest> requests)
          Sets the list of authentication requests sent by an origin server to a client.
 void setEntity(java.lang.Object object)
          Deprecated. Since 1.1, the ConverterService is deprecated, with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.
 void setEntity(Representation entity)
          Sets the entity representation.
 void setEntity(java.lang.String value, MediaType mediaType)
          Sets a textual entity.
 void setLocationRef(Reference locationRef)
          Sets the reference that the client should follow for redirections or resource creations.
 void setLocationRef(java.lang.String locationUri)
          Sets the reference that the client should follow for redirections or resource creations.
 void setRedirectRef(Reference redirectRef)
          Deprecated. Use the setLocationRef() method instead.
 void setRedirectRef(java.lang.String redirectUri)
          Deprecated. Use the setLocationRef() method instead.
 void setRequest(Request request)
          Sets the associated request.
 void setRequest(WrapperRequest request)
          Sets the associated request.
 void setStatus(Status status)
          Sets the status.
 void setStatus(Status status, java.lang.String message)
          Sets the status.
 
Methods inherited from class org.restlet.data.Response
getCurrent, setAllowedMethods, setCookieSettings, setCurrent, setDimensions, setServerInfo, setStatus, setStatus
 
Methods inherited from class org.restlet.data.Message
release, setAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WrapperResponse

public WrapperResponse(Response wrappedResponse)
Constructor.

Parameters:
wrappedResponse - The wrapped response.
Method Detail

getAllowedMethods

public java.util.Set<Method> getAllowedMethods()
Returns the set of methods allowed on the requested resource. This property only has to be updated when a status CLIENT_ERROR_METHOD_NOT_ALLOWED is set.

Overrides:
getAllowedMethods in class Response
Returns:
The list of allowed methods.

getAttributes

public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Returns a modifiable attributes map that can be used by developers to save information relative to the message. This is an easier alternative to the creation of a wrapper instance around the whole message.

In addition, this map is a shared space between the developer and the connectors. In this case, it is used to exchange information that is not uniform across all protocols and couldn't therefore be directly included in the API. For this purpose, all attribute names starting with "org.restlet" are reserved. Currently the following attributes are used:
Attribute name Class name Description
org.restlet.http.headers org.restlet.data.Form Server HTTP connectors must provide all request headers and client HTTP connectors must provide all response headers, exactly as they were received. In addition, developers can also use this attribute to specify non-standard headers that should be added to the request or to the response.
Adding standard HTTP headers is forbidden because it could conflict with the connector's internal behavior, limit portability or prevent future optimizations.

Overrides:
getAttributes in class Message
Returns:
The modifiable attributes map.

getChallengeRequest

@Deprecated
public ChallengeRequest getChallengeRequest()
Deprecated. Use the getChallengeRequests() instead.

Returns the authentication request sent by an origin server to a client.

Overrides:
getChallengeRequest in class Response
Returns:
The authentication request sent by an origin server to a client.

getChallengeRequests

public java.util.List<ChallengeRequest> getChallengeRequests()
Returns the list of authentication requests sent by an origin server to a client.

Overrides:
getChallengeRequests in class Response
Returns:
The list of authentication requests sent by an origin server to a client.

getCookieSettings

public Series<CookieSetting> getCookieSettings()
Returns the cookie settings provided by the server.

Overrides:
getCookieSettings in class Response
Returns:
The cookie settings provided by the server.

getDimensions

public java.util.Set<Dimension> getDimensions()
Returns the set of selecting dimensions on which the response entity may vary. If some server-side content negotiation is done, this set should be properly updated, other it can be left empty.

Overrides:
getDimensions in class Response
Returns:
The set of dimensions on which the response entity may vary.

getEntity

public Representation getEntity()
Returns the entity representation.

Overrides:
getEntity in class Message
Returns:
The entity representation.

getEntityAsDom

public DomRepresentation getEntityAsDom()
Returns the entity as a DOM representation.
Note that this triggers the parsing of the entity into a reusable DOM document stored in memory.
This method and the related getEntity*() methods can only be invoked once.

Overrides:
getEntityAsDom in class Message
Returns:
The entity as a DOM representation.

getEntityAsForm

public Form getEntityAsForm()
Returns the entity as a DOM representation.
Note that this triggers the parsing of the entity into a reusable DOM document stored in memory.
This method and the related getEntity*() methods can only be invoked once.

Overrides:
getEntityAsForm in class Message
Returns:
The entity as a DOM representation.

getEntityAsObject

@Deprecated
public java.lang.Object getEntityAsObject()
Deprecated. Since 1.1, the ConverterService is deprecated, with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.

Returns the entity as a higher-level object. This object is created by the Application's converter service. If you want to use this method to facilitate the processing of request entities, you need to provide a custom implementation of the ConverterService class, overriding the toObject(Representation) method.
Note that this triggers the parsing of the entity.
This method and the related getEntity*() methods can only be invoked once.

Overrides:
getEntityAsObject in class Message
Returns:
The entity as a higher-level object.
See Also:
ConverterService

getEntityAsSax

public SaxRepresentation getEntityAsSax()
Returns the entity as a SAX representation.
Note that this kind of representation can only be parsed once. If you evaluate an XPath expression, it can also only be done once. If you need to reuse the entity multiple times, consider using the getEntityAsDom() method instead.

Overrides:
getEntityAsSax in class Message
Returns:
The entity as a SAX representation.

getLocationRef

public Reference getLocationRef()
Returns the reference that the client should follow for redirections or resource creations.

Overrides:
getLocationRef in class Response
Returns:
The redirection reference.

getRedirectRef

@Deprecated
public Reference getRedirectRef()
Deprecated. Use the getLocationRef() method instead.

Returns the reference that the client should follow for redirections or resource creations.

Overrides:
getRedirectRef in class Response
Returns:
The redirection reference.

getRequest

public Request getRequest()
Returns the associated request

Overrides:
getRequest in class Response
Returns:
The associated request

getServerInfo

public ServerInfo getServerInfo()
Returns the server-specific information.

Overrides:
getServerInfo in class Response
Returns:
The server-specific information.

getStatus

public Status getStatus()
Returns the status.

Overrides:
getStatus in class Response
Returns:
The status.

getWrappedResponse

protected Response getWrappedResponse()
Returns the wrapped response.

Returns:
The wrapped response.

isConfidential

public boolean isConfidential()
Indicates if the call came over a confidential channel such as an SSL-secured connection.

Overrides:
isConfidential in class Response
Returns:
True if the call came over a confidential channel.

isEntityAvailable

public boolean isEntityAvailable()
Indicates if a content is available and can be sent. Several conditions must be met: the content must exists and have some available data.

Overrides:
isEntityAvailable in class Message
Returns:
True if a content is available and can be sent.

redirectPermanent

public void redirectPermanent(Reference targetRef)
Permanently redirects the client to a target URI. The client is expected to reuse the same method for the new request.

Overrides:
redirectPermanent in class Response
Parameters:
targetRef - The target URI reference.

redirectPermanent

public void redirectPermanent(java.lang.String targetUri)
Permanently redirects the client to a target URI. The client is expected to reuse the same method for the new request.

Overrides:
redirectPermanent in class Response
Parameters:
targetUri - The target URI.

redirectSeeOther

public void redirectSeeOther(Reference targetRef)
Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource.

Overrides:
redirectSeeOther in class Response
Parameters:
targetRef - The target reference.

redirectSeeOther

public void redirectSeeOther(java.lang.String targetUri)
Redirects the client to a different URI that SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource.

Overrides:
redirectSeeOther in class Response
Parameters:
targetUri - The target URI.

redirectTemporary

public void redirectTemporary(Reference targetRef)
Temporarily redirects the client to a target URI. The client is expected to reuse the same method for the new request.

Overrides:
redirectTemporary in class Response
Parameters:
targetRef - The target reference.

redirectTemporary

public void redirectTemporary(java.lang.String targetUri)
Temporarily redirects the client to a target URI. The client is expected to reuse the same method for the new request.

Overrides:
redirectTemporary in class Response
Parameters:
targetUri - The target URI.

setChallengeRequest

public void setChallengeRequest(ChallengeRequest request)
Sets the authentication request sent by an origin server to a client.

Overrides:
setChallengeRequest in class Response
Parameters:
request - The authentication request sent by an origin server to a client.

setChallengeRequests

public void setChallengeRequests(java.util.List<ChallengeRequest> requests)
Sets the list of authentication requests sent by an origin server to a client.

Overrides:
setChallengeRequests in class Response
Parameters:
requests - The list of authentication requests sent by an origin server to a client.

setEntity

@Deprecated
public void setEntity(java.lang.Object object)
Deprecated. Since 1.1, the ConverterService is deprecated, with no replacement as it doesn't fit well with content negotiation. Most users prefer to handle those conversion in Resource subclasses.

Sets the entity from a higher-level object. This object is converted to a representation using the Application's converter service. If you want to use this method to facilitate the setting of entities, you need to provide a custom implementation of the ConverterService class, overriding the toRepresentation(Object) method.

Overrides:
setEntity in class Message
Parameters:
object - The higher-level object.
See Also:
ConverterService

setEntity

public void setEntity(Representation entity)
Sets the entity representation.

Overrides:
setEntity in class Message
Parameters:
entity - The entity representation.

setEntity

public void setEntity(java.lang.String value,
                      MediaType mediaType)
Sets a textual entity.

Overrides:
setEntity in class Message
Parameters:
value - The represented string.
mediaType - The representation's media type.

setLocationRef

public void setLocationRef(Reference locationRef)
Sets the reference that the client should follow for redirections or resource creations.

Overrides:
setLocationRef in class Response
Parameters:
locationRef - The reference to set.

setLocationRef

public void setLocationRef(java.lang.String locationUri)
Sets the reference that the client should follow for redirections or resource creations.

Overrides:
setLocationRef in class Response
Parameters:
locationUri - The URI to set.

setRedirectRef

@Deprecated
public void setRedirectRef(Reference redirectRef)
Deprecated. Use the setLocationRef() method instead.

Sets the reference that the client should follow for redirections or resource creations.

Overrides:
setRedirectRef in class Response
Parameters:
redirectRef - The redirection reference.

setRedirectRef

@Deprecated
public void setRedirectRef(java.lang.String redirectUri)
Deprecated. Use the setLocationRef() method instead.

Sets the reference that the client should follow for redirections or resource creations.

Overrides:
setRedirectRef in class Response
Parameters:
redirectUri - The redirection URI.

setRequest

public void setRequest(Request request)
Sets the associated request.

Overrides:
setRequest in class Response
Parameters:
request - The associated request

setRequest

public void setRequest(WrapperRequest request)
Sets the associated request.

Parameters:
request - The associated request

setStatus

public void setStatus(Status status)
Sets the status.

Overrides:
setStatus in class Response
Parameters:
status - The status to set.

setStatus

public void setStatus(Status status,
                      java.lang.String message)
Sets the status.

Overrides:
setStatus in class Response
Parameters:
status - The status to set.
message - The status message.


Copyright © 2005-2008 Noelios Technologies.