Class BaseClientResponse<T>


  • public class BaseClientResponse<T>
    extends ClientResponse<T>
    Version:
    $Revision: 1 $
    • Field Detail

      • attributeExceptionsTo

        protected java.lang.String attributeExceptionsTo
      • headers

        protected javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> headers
      • alternateMediaType

        protected java.lang.String alternateMediaType
      • returnType

        protected java.lang.Class<?> returnType
      • genericReturnType

        protected java.lang.reflect.Type genericReturnType
      • annotations

        protected java.lang.annotation.Annotation[] annotations
      • status

        protected int status
      • wasReleased

        protected boolean wasReleased
      • unmarshaledEntity

        protected java.lang.Object unmarshaledEntity
      • readerInterceptors

        protected javax.ws.rs.ext.ReaderInterceptor[] readerInterceptors
      • exception

        protected java.lang.Exception exception
      • location

        protected Link location
      • attributes

        protected java.util.Map<java.lang.String,​java.lang.Object> attributes
    • Method Detail

      • copyFromError

        public static ClientResponse copyFromError​(ClientResponse copy)
        Store entity within a byte array input stream because we want to release the connection if a ClientResponseFailure is thrown. Copy status and headers, but ignore all type information stored in the ClientResponse.
        Parameters:
        copy -
        Returns:
      • getAttributes

        public java.util.Map<java.lang.String,​java.lang.Object> getAttributes()
        Description copied from class: ClientResponse
        Used to pass information to and between interceptors.
        Specified by:
        getAttributes in class ClientResponse<T>
        Returns:
      • setAttributes

        public void setAttributes​(java.util.Map<java.lang.String,​java.lang.Object> attributes)
      • setReaderInterceptors

        public void setReaderInterceptors​(javax.ws.rs.ext.ReaderInterceptor[] readerInterceptors)
      • setStatus

        public void setStatus​(int status)
      • setHeaders

        public void setHeaders​(javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> headers)
      • setReturnType

        public void setReturnType​(java.lang.Class<T> returnType)
      • getReturnType

        public java.lang.Class<?> getReturnType()
      • setGenericReturnType

        public void setGenericReturnType​(java.lang.reflect.Type genericReturnType)
      • setAnnotations

        public void setAnnotations​(java.lang.annotation.Annotation[] annotations)
      • getAttributeExceptionsTo

        public java.lang.String getAttributeExceptionsTo()
      • setAttributeExceptionsTo

        public void setAttributeExceptionsTo​(java.lang.String attributeExceptionsTo)
      • getException

        public java.lang.Exception getException()
      • setException

        public void setException​(java.lang.Exception exception)
      • getAnnotations

        public java.lang.annotation.Annotation[] getAnnotations()
      • getResponseHeader

        public java.lang.String getResponseHeader​(java.lang.String headerKey)
      • getLocationLink

        public Link getLocationLink()
        Description copied from class: ClientResponse
        Get the Location header as a Link so you can easily execute on it. All Link objects returned will automatically have the same ClientExecutor as the request.
        Specified by:
        getLocationLink in class ClientResponse<T>
        Returns:
      • getHeaderAsLink

        public Link getHeaderAsLink​(java.lang.String headerName)
        Description copied from class: ClientResponse
        Header is assumed to be a URL, a Link object is created from it if it exists. Also, the type field of the link with be initialized if there is another header appended with -Type. i.e. if the header was "custom" it will also look for a header of custom-type and expect that this is a media type.

        All Link objects returned will automatically have the same ClientExecutor as the request.

        Specified by:
        getHeaderAsLink in class ClientResponse<T>
        Returns:
        null if it doesn't exist
      • setAlternateMediaType

        public void setAlternateMediaType​(java.lang.String alternateMediaType)
      • resetStream

        public void resetStream()
        Description copied from class: ClientResponse
        Attempts to reset the InputStream of the response. Useful for refetching an entity after a marshalling failure
        Specified by:
        resetStream in class ClientResponse<T>
      • getEntity

        public T getEntity()
        Description copied from class: ClientResponse
        Unmarshal the target entity from the response OutputStream. You must have type information set via otherwise, this will not work.

        This method actually does the reading on the OutputStream. It will only do the read once. Afterwards, it will cache the result and return the cached result.

        Specified by:
        getEntity in class ClientResponse<T>
      • getEntity

        public <T2> T2 getEntity​(java.lang.Class<T2> type)
        Description copied from class: ClientResponse
        Extract the response body with the provided type information

        This method actually does the reading on the OutputStream. It will only do the read once. Afterwards, it will cache the result and return the cached result.

        Specified by:
        getEntity in class ClientResponse<T>
        Returns:
      • getEntity

        public <T2> T2 getEntity​(java.lang.Class<T2> type,
                                 java.lang.reflect.Type genericType)
        Description copied from class: ClientResponse
        Extract the response body with the provided type information

        This method actually does the reading on the OutputStream. It will only do the read once. Afterwards, it will cache the result and return the cached result.

        Specified by:
        getEntity in class ClientResponse<T>
        Returns:
      • getAnnotations

        private <T2> java.lang.annotation.Annotation[] getAnnotations​(java.lang.Class<T2> type,
                                                                      java.lang.reflect.Type genericType)
      • getEntity

        public <T2> T2 getEntity​(java.lang.Class<T2> type,
                                 java.lang.reflect.Type genericType,
                                 java.lang.annotation.Annotation[] anns)
        Specified by:
        getEntity in class ClientResponse<T>
        Returns:
      • getMediaType

        public javax.ws.rs.core.MediaType getMediaType()
        Specified by:
        getMediaType in class javax.ws.rs.core.Response
      • readFrom

        protected <T2> java.lang.Object readFrom​(java.lang.Class<T2> type,
                                                 java.lang.reflect.Type genericType,
                                                 javax.ws.rs.core.MediaType media,
                                                 java.lang.annotation.Annotation[] annotations)
      • getEntity

        public <T2> T2 getEntity​(GenericType<T2> genericType)
        Description copied from class: ClientResponse
        Extract the response body with the provided type information. GenericType is a trick used to pass in generic type information to the resteasy runtime.

        For example:

         List list = response.getEntity(new GenericType() {});
        
        
         This method actually does the reading on the OutputStream.  It will only do the read once.  Afterwards, it will
         cache the result and return the cached result.
        Specified by:
        getEntity in class ClientResponse<T>
        Returns:
      • getResponseHeaders

        public javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> getResponseHeaders()
        Description copied from class: ClientResponse
        This method returns the same exact map as Response.getMetadata() except as a map of strings rather than objects
        Specified by:
        getResponseHeaders in class ClientResponse<T>
        Returns:
      • getMetadata

        public javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.Object> getMetadata()
        Specified by:
        getMetadata in class javax.ws.rs.core.Response
      • getStatus

        public int getStatus()
        Specified by:
        getStatus in class javax.ws.rs.core.Response
      • getStatusInfo

        public javax.ws.rs.core.Response.StatusType getStatusInfo()
        Specified by:
        getStatusInfo in class javax.ws.rs.core.Response
      • checkFailureStatus

        public void checkFailureStatus()
      • createResponseFailure

        public ClientResponseFailure createResponseFailure​(java.lang.String message)
      • createResponseFailure

        public ClientResponseFailure createResponseFailure​(java.lang.String message,
                                                           java.lang.Exception e)
      • wasReleased

        public boolean wasReleased()
      • setWasReleased

        public void setWasReleased​(boolean wasReleased)
      • finalize

        protected final void finalize()
                               throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • readEntity

        public <T> T readEntity​(java.lang.Class<T> entityType)
        Specified by:
        readEntity in class javax.ws.rs.core.Response
      • readEntity

        public <T> T readEntity​(javax.ws.rs.core.GenericType<T> entityType)
        Specified by:
        readEntity in class javax.ws.rs.core.Response
      • readEntity

        public <T> T readEntity​(java.lang.Class<T> entityType,
                                java.lang.annotation.Annotation[] annotations)
        Specified by:
        readEntity in class javax.ws.rs.core.Response
      • readEntity

        public <T> T readEntity​(javax.ws.rs.core.GenericType<T> entityType,
                                java.lang.annotation.Annotation[] annotations)
        Specified by:
        readEntity in class javax.ws.rs.core.Response
      • hasEntity

        public boolean hasEntity()
        Specified by:
        hasEntity in class javax.ws.rs.core.Response
      • bufferEntity

        public boolean bufferEntity()
        Specified by:
        bufferEntity in class javax.ws.rs.core.Response
      • close

        public void close()
        Specified by:
        close in class javax.ws.rs.core.Response
      • getHeaderString

        public java.lang.String getHeaderString​(java.lang.String name)
        Specified by:
        getHeaderString in class javax.ws.rs.core.Response
      • getLanguage

        public java.util.Locale getLanguage()
        Specified by:
        getLanguage in class javax.ws.rs.core.Response
      • getLength

        public int getLength()
        Specified by:
        getLength in class javax.ws.rs.core.Response
      • getCookies

        public java.util.Map<java.lang.String,​javax.ws.rs.core.NewCookie> getCookies()
        Specified by:
        getCookies in class javax.ws.rs.core.Response
      • getEntityTag

        public javax.ws.rs.core.EntityTag getEntityTag()
        Specified by:
        getEntityTag in class javax.ws.rs.core.Response
      • getDate

        public java.util.Date getDate()
        Specified by:
        getDate in class javax.ws.rs.core.Response
      • getLastModified

        public java.util.Date getLastModified()
        Specified by:
        getLastModified in class javax.ws.rs.core.Response
      • getLinks

        public java.util.Set<javax.ws.rs.core.Link> getLinks()
        Specified by:
        getLinks in class javax.ws.rs.core.Response
      • hasLink

        public boolean hasLink​(java.lang.String relation)
        Specified by:
        hasLink in class javax.ws.rs.core.Response
      • getLink

        public javax.ws.rs.core.Link getLink​(java.lang.String relation)
        Specified by:
        getLink in class javax.ws.rs.core.Response
      • getLinkBuilder

        public javax.ws.rs.core.Link.Builder getLinkBuilder​(java.lang.String relation)
        Specified by:
        getLinkBuilder in class javax.ws.rs.core.Response
      • getLocation

        public java.net.URI getLocation()
        Specified by:
        getLocation in class javax.ws.rs.core.Response
      • getAllowedMethods

        public java.util.Set<java.lang.String> getAllowedMethods()
        Specified by:
        getAllowedMethods in class javax.ws.rs.core.Response
      • getStringHeaders

        public javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> getStringHeaders()
        Specified by:
        getStringHeaders in class javax.ws.rs.core.Response