TypedRest for Java
Public Member Functions | List of all members
net.typedrest.BlobEndpointImpl Class Reference

REST endpoint that represents a single binary blob that can downloaded and uploaded. More...

Inheritance diagram for net.typedrest.BlobEndpointImpl:
net.typedrest.AbstractEndpoint net.typedrest.BlobEndpoint net.typedrest.Endpoint net.typedrest.Endpoint

Public Member Functions

 BlobEndpointImpl (Endpoint referrer, URI relativeUri)
 
 BlobEndpointImpl (Endpoint referrer, String relativeUri)
 
void probe () throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 Queries the server about capabilities of the endpoint without performing any action. More...
 
Optional< Boolean > isDownloadAllowed ()
 Shows whether the server has indicated that download() is currently allowed. More...
 
InputStream download () throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 Downloads the blob's content. More...
 
Optional< Boolean > isUploadAllowed ()
 Shows whether the server has indicated that upload(java.io.InputStream, org.apache.http.entity.ContentType) is currently allowed. More...
 
void upload (InputStream stream, ContentType contentType) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 Uploads new content for the blob. More...
 
void upload (byte[] data, ContentType contentType) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 Uploads a byte array as the blob's content. More...
 
void upload (File file, ContentType contentType) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 Uploads a local file as the blob's content. More...
 
Optional< Boolean > isDeleteAllowed ()
 Shows whether the server has indicated that delete() is currently allowed. More...
 
void delete () throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException
 Deletes the blob from the server. More...
 
- Public Member Functions inherited from net.typedrest.AbstractEndpoint
final void setDefaultLink (String rel, String... hrefs)
 Registers one or more default links for a specific relation type. More...
 
final void setDefaultLinkTemplate (String rel, String href)
 Registers a default link template for a specific relation type. More...
 
Set< URI > getLinks (String rel)
 Retrieves all links with a specific relation type cached from the last request. More...
 
Map< URI, String > getLinksWithTitles (String rel)
 Retrieves all links (with titles) with a specific relation type cached from the last request. More...
 
URI link (String rel)
 Retrieves a single link with a specific relation type. More...
 
UriTemplate linkTemplate (String rel)
 Retrieves a link template with a specific relation type. More...
 
String toString ()
 
- Public Member Functions inherited from net.typedrest.Endpoint
URI getUri ()
 The HTTP URI of the remote resource. More...
 
Executor getExecutor ()
 The REST executor used to communicate with the remote resource. More...
 
ObjectMapper getSerializer ()
 Controls the serialization of entities sent to and received from the server. More...
 
default URI linkTemplate (String rel, String variableName, Object value)
 Retrieves a link template with a specific relation type and resolves it. More...
 

Additional Inherited Members

- Protected Member Functions inherited from net.typedrest.AbstractEndpoint
 AbstractEndpoint (URI uri, Executor executor, ObjectMapper serializer)
 Creates a new REST endpoint with an absolute URI. More...
 
 AbstractEndpoint (Endpoint referrer, URI relativeUri)
 Creates a new REST endpoint with a relative URI. More...
 
 AbstractEndpoint (Endpoint referrer, String relativeUri)
 Creates a new REST endpoint with a relative URI. More...
 
HttpResponse executeAndHandle (Request request) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Executes a REST request and wraps HTTP status codes in appropriate Exception types. More...
 
HttpResponse execute (Request request) throws IOException
 Executes a REST request adding any configured defaultHeaders. More...
 
void handleResponse (HttpResponse response, Request request) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Handles the response of a REST request and wraps HTTP status codes in appropriate Exception types. More...
 
void handleErrors (HttpResponse response, Request request) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IllegalStateException
 Wraps HTTP status codes in appropriate Exception types. More...
 
void handleHeaderLinks (HttpResponse response, Map< String, Map< URI, String >> links, Map< String, String > linkTemplates)
 Handles links embedded in HTTP response headers. More...
 
void handleBodyLinks (JsonNode jsonBody, Map< String, Map< URI, String >> links, Map< String, String > linkTemplates)
 Handles links embedded in JSON response bodies. More...
 
void handleCapabilities (HttpResponse response)
 Handles allowed HTTP methods and other capabilities reported by the server. More...
 
Optional< Boolean > isMethodAllowed (String method)
 Shows whether the server has indicated that a specific HTTP method is currently allowed. More...
 
- Protected Attributes inherited from net.typedrest.AbstractEndpoint
final URI uri
 
final Executor executor
 
final ObjectMapper serializer
 
final Collection< Header > defaultHeaders = new LinkedList<>()
 A set of default HTTP headers to be added to each request.
 

Detailed Description

REST endpoint that represents a single binary blob that can downloaded and uploaded.

Member Function Documentation

◆ delete()

void net.typedrest.BlobEndpointImpl.delete ( ) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException

Deletes the blob from the server.

Exceptions
IOExceptionNetwork communication failed.
IllegalArgumentExceptionHttpStatus#SC_BAD_REQUEST
IllegalAccessExceptionHttpStatus#SC_UNAUTHORIZED or HttpStatus#SC_FORBIDDEN
FileNotFoundExceptionHttpStatus#SC_NOT_FOUND or HttpStatus#SC_GONE
IllegalStateExceptionHttpStatus#SC_CONFLICT
RuntimeExceptionOther non-success status code.

Implements net.typedrest.BlobEndpoint.

◆ download()

InputStream net.typedrest.BlobEndpointImpl.download ( ) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException

Downloads the blob's content.

Returns
A stream with the blob's content.
Exceptions
IOExceptionNetwork communication failed.
IllegalArgumentExceptionHttpStatus#SC_BAD_REQUEST
IllegalAccessExceptionHttpStatus#SC_UNAUTHORIZED or HttpStatus#SC_FORBIDDEN
FileNotFoundExceptionHttpStatus#SC_NOT_FOUND or HttpStatus#SC_GONE
IllegalStateExceptionHttpStatus#SC_CONFLICT
RuntimeExceptionOther non-success status code.

Implements net.typedrest.BlobEndpoint.

◆ isDeleteAllowed()

Optional<Boolean> net.typedrest.BlobEndpointImpl.isDeleteAllowed ( )

Shows whether the server has indicated that delete() is currently allowed.

Uses cached data from last response.

Returns
An indicator whether the method is allowed. If no request has been sent yet or the server did not specify allowed methods Optional#empty() is returned.

Implements net.typedrest.BlobEndpoint.

◆ isDownloadAllowed()

Optional<Boolean> net.typedrest.BlobEndpointImpl.isDownloadAllowed ( )

Shows whether the server has indicated that download() is currently allowed.

Uses cached data from last response.

Returns
An indicator whether the method is allowed. If no request has been sent yet or the server did not specify allowed methods Optional#empty() is returned.

Implements net.typedrest.BlobEndpoint.

◆ isUploadAllowed()

Optional<Boolean> net.typedrest.BlobEndpointImpl.isUploadAllowed ( )

Shows whether the server has indicated that upload(java.io.InputStream, org.apache.http.entity.ContentType) is currently allowed.

Uses cached data from last response.

Returns
An indicator whether the method is allowed. If no request has been sent yet or the server did not specify allowed methods Optional#empty() is returned.

Implements net.typedrest.BlobEndpoint.

◆ probe()

void net.typedrest.BlobEndpointImpl.probe ( ) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException

Queries the server about capabilities of the endpoint without performing any action.

Exceptions
IOExceptionNetwork communication failed.
IllegalArgumentExceptionHttpStatus#SC_BAD_REQUEST
IllegalAccessExceptionHttpStatus#SC_UNAUTHORIZED or HttpStatus#SC_FORBIDDEN
FileNotFoundExceptionHttpStatus#SC_NOT_FOUND or HttpStatus#SC_GONE
IllegalStateExceptionHttpStatus#SC_CONFLICT
RuntimeExceptionOther non-success status code.

Implements net.typedrest.BlobEndpoint.

◆ upload() [1/3]

void net.typedrest.BlobEndpointImpl.upload ( InputStream  stream,
ContentType  contentType 
) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException

Uploads new content for the blob.

Parameters
streamA stream with the blob's new content.
contentTypeThe MIME type of the file to upload.
Exceptions
IOExceptionNetwork communication failed.
IllegalArgumentExceptionHttpStatus#SC_BAD_REQUEST
IllegalAccessExceptionHttpStatus#SC_UNAUTHORIZED or HttpStatus#SC_FORBIDDEN
FileNotFoundExceptionHttpStatus#SC_NOT_FOUND or HttpStatus#SC_GONE
IllegalStateExceptionHttpStatus#SC_CONFLICT
RuntimeExceptionOther non-success status code.

Implements net.typedrest.BlobEndpoint.

◆ upload() [2/3]

void net.typedrest.BlobEndpointImpl.upload ( byte []  data,
ContentType  contentType 
) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException

Uploads a byte array as the blob's content.

Parameters
dataThe byte array holding the data to upload.
contentTypeThe MIME type of the file to upload.
Exceptions
IOExceptionNetwork communication failed.
IllegalArgumentExceptionHttpStatus#SC_BAD_REQUEST
IllegalAccessExceptionHttpStatus#SC_UNAUTHORIZED or HttpStatus#SC_FORBIDDEN
FileNotFoundExceptionHttpStatus#SC_NOT_FOUND or HttpStatus#SC_GONE
IllegalStateExceptionHttpStatus#SC_CONFLICT
RuntimeExceptionOther non-success status code.

Implements net.typedrest.BlobEndpoint.

◆ upload() [3/3]

void net.typedrest.BlobEndpointImpl.upload ( File  file,
ContentType  contentType 
) throws IOException, IllegalArgumentException, IllegalAccessException, FileNotFoundException

Uploads a local file as the blob's content.

Parameters
fileThe local file to read the data from.
contentTypeThe MIME type of the file to upload.
Exceptions
IOExceptionNetwork communication failed.
IllegalArgumentExceptionHttpStatus#SC_BAD_REQUEST
IllegalAccessExceptionHttpStatus#SC_UNAUTHORIZED or HttpStatus#SC_FORBIDDEN
FileNotFoundExceptionHttpStatus#SC_NOT_FOUND or HttpStatus#SC_GONE
IllegalStateExceptionHttpStatus#SC_CONFLICT
RuntimeExceptionOther non-success status code.

Implements net.typedrest.BlobEndpoint.


The documentation for this class was generated from the following file: