Class 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 Detail

      • WrapperResponse

        public WrapperResponse​(Response wrappedResponse)
        Constructor.
        Parameters:
        wrappedResponse - The wrapped response.
    • Method Detail

      • abort

        public void abort()
        Description copied from class: Response
        Ask the connector to abort the related network connection, for example immediately closing the socket.
        Overrides:
        abort in class Response
      • commit

        public void commit()
        Description copied from class: Response
        Asks the server connector to immediately commit the given response, making it ready to be sent back to the client. Note that all server connectors don't necessarily support this feature.

        When the response is in autoCommit mode (see related property), then calling this method isn't necessary. Also, be aware that committing the response doesn't necessarily means that is will be immediately be written on the network as some buffering can occurs. If you want to ensure that response buffers are flushed,

        Note that this calls back Request.commit(Response) on the parent request which holds the link with the underlying network connection.
        Overrides:
        commit in class Response
      • getAge

        public int getAge()
        Description copied from class: Response
        Returns the estimated amount of time since a response was generated or revalidated by the origin server. Origin servers should leave the 0 default value. Only caches are expected to set this property.

        Note that when used with HTTP connectors, this property maps to the "Age" header.
        Overrides:
        getAge in class Response
        Returns:
        The response age.
      • 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.concurrent.ConcurrentMap<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:
        list of supported attributes
        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.
      • getAuthenticationInfo

        public AuthenticationInfo getAuthenticationInfo()
        Description copied from class: Response
        Returns information sent by an origin server related to an successful authentication attempt. If none is available, null is returned.

        Note that when used with HTTP connectors, this property maps to the "Authentication-Info" header.
        Overrides:
        getAuthenticationInfo in class Response
        Returns:
        The authentication information provided by the server.
      • 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.
      • 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.
      • getProxyChallengeRequests

        public java.util.List<ChallengeRequest> getProxyChallengeRequests()
        Returns the list of authentication requests sent by a proxy to a client.
        Overrides:
        getProxyChallengeRequests in class Response
        Returns:
        The list of authentication requests sent by a proxy to a client.
      • getRequest

        public Request getRequest()
        Returns the associated request
        Overrides:
        getRequest in class Response
        Returns:
        The associated request
      • getRetryAfter

        public java.util.Date getRetryAfter()
        Description copied from class: Response
        Indicates how long the service is expected to be unavailable to the requesting client. Default value is null.

        Note that when used with HTTP connectors, this property maps to the "Retry-After" header.
        Overrides:
        getRetryAfter in class Response
        Returns:
        Date after with a retry attempt could occur.
      • 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.
      • isAutoCommitting

        public boolean isAutoCommitting()
        Description copied from class: Response
        Indicates if the response should be automatically committed. When processing a request on the server-side, setting this property to 'false' let you ask to the server connector to wait before sending the response back to the client when the initial calling thread returns. This will let you do further updates to the response and manually calling Response.commit() later on, using another thread.
        Overrides:
        isAutoCommitting in class Response
        Returns:
        True if the response should be automatically committed.
      • isCommitted

        public boolean isCommitted()
        Description copied from class: Response
        Indicates if the response has already been committed.
        Overrides:
        isCommitted in class Response
        Returns:
        True if the response has already been committed.
      • 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.
      • setAge

        public void setAge​(int age)
        Description copied from class: Response
        Sets the estimated amount of time since a response was generated or revalidated by the origin server. Origin servers should leave the 0 default value. Only caches are expected to set this property.

        Note that when used with HTTP connectors, this property maps to the "Age" header.
        Overrides:
        setAge in class Response
        Parameters:
        age - The response age.
      • setAllowedMethods

        public void setAllowedMethods​(java.util.Set<Method> allowedMethods)
        Description copied from class: Response
        Sets the set of methods allowed on the requested resource. The set instance set must be thread-safe (use CopyOnWriteArraySet for example.

        Note that when used with HTTP connectors, this property maps to the "Allow" header.
        Overrides:
        setAllowedMethods in class Response
        Parameters:
        allowedMethods - The set of methods allowed on the requested resource.
      • setAuthenticationInfo

        public void setAuthenticationInfo​(AuthenticationInfo authenticationInfo)
        Description copied from class: Response
        Sets the authentication information sent by an origin server to a client after a successful authentication attempt.

        Note that when used with HTTP connectors, this property maps to the "Authentication-Info" header.
        Overrides:
        setAuthenticationInfo in class Response
        Parameters:
        authenticationInfo - The data returned by the server in response to successful authentication.
      • setAutoCommitting

        public void setAutoCommitting​(boolean autoCommitting)
        Description copied from class: Response
        Indicates if the response should be automatically committed.
        Overrides:
        setAutoCommitting in class Response
        Parameters:
        autoCommitting - True if the response should be automatically committed
      • 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.
      • setCommitted

        public void setCommitted​(boolean committed)
        Description copied from class: Response
        Indicates if the response has already been committed.
        Overrides:
        setCommitted in class Response
        Parameters:
        committed - True if the response has already been committed.
      • setCookieSettings

        public void setCookieSettings​(Series<CookieSetting> cookieSettings)
        Description copied from class: Response
        Sets the modifiable series of cookie settings provided by the server. Note that when used with HTTP connectors, this property maps to the "Set-Cookie" and "Set-Cookie2" headers. This method clears the current series and adds all entries in the parameter series.
        Overrides:
        setCookieSettings in class Response
        Parameters:
        cookieSettings - A series of cookie settings provided by the server.
      • setDimensions

        public void setDimensions​(java.util.Set<Dimension> dimensions)
        Description copied from class: Response
        Sets the set of dimensions on which the response entity may vary. Note that when used with HTTP connectors, this property maps to the "Vary" header. This method clears the current set and adds all entries in the parameter set.
        Overrides:
        setDimensions in class Response
        Parameters:
        dimensions - The set of dimensions on which the response entity may vary.
      • 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.
        See Also:
        Response.setLocationRef(Reference)
      • setProxyChallengeRequests

        public void setProxyChallengeRequests​(java.util.List<ChallengeRequest> requests)
        Sets the list of authentication requests sent by a proxy to a client.
        Overrides:
        setProxyChallengeRequests in class Response
        Parameters:
        requests - The list of authentication requests sent by a proxy to a client.
      • 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
      • setRetryAfter

        public void setRetryAfter​(java.util.Date retryAfter)
        Description copied from class: Response
        Indicates how long the service is expected to be unavailable to the requesting client. Default value is null.

        Note that when used with HTTP connectors, this property maps to the "Retry-After" header.
        Overrides:
        setRetryAfter in class Response
        Parameters:
        retryAfter - Date after with a retry attempt could occur.
      • setServerInfo

        public void setServerInfo​(ServerInfo serverInfo)
        Description copied from class: Response
        Sets the server-specific information.
        Overrides:
        setServerInfo in class Response
        Parameters:
        serverInfo - The server-specific information.
      • 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.
      • setStatus

        public void setStatus​(Status status,
                              java.lang.Throwable throwable)
        Description copied from class: Response
        Sets the status.
        Overrides:
        setStatus in class Response
        Parameters:
        status - The status to set.
        throwable - The related error or exception.
      • setStatus

        public void setStatus​(Status status,
                              java.lang.Throwable throwable,
                              java.lang.String message)
        Description copied from class: Response
        Sets the status.
        Overrides:
        setStatus in class Response
        Parameters:
        status - The status to set.
        throwable - The related error or exception.
        message - The status message.
      • toString

        public java.lang.String toString()
        Description copied from class: Response
        Displays a synthesis of the response like an HTTP status line.
        Overrides:
        toString in class Response
        Returns:
        A synthesis of the response like an HTTP status line.