Class FcrepoClient

  • All Implemented Interfaces:
    Closeable, AutoCloseable
    Direct Known Subclasses:
    TransactionalFcrepoClient

    public class FcrepoClient
    extends Object
    implements Closeable
    Represents a client to interact with Fedora's HTTP API.

    Users of the FcrepoClient are responsible for managing connection resources. Specifically, the underlying HTTP connections of this client must be freed. Suggested usage is to create the FcrepoResponse within a try-with-resources block, insuring that any resources held by the response are freed automatically.

     FcrepoClient client = ...;
     try (FcrepoResponse res = client.get(...).perform()) {
         // do something with the response
     } catch (FcrepoOperationFailedException|IOException e) {
         // handle any exceptions
     }
     
    Since:
    October 20, 2014
    Author:
    Aaron Coburn
    • Constructor Detail

      • FcrepoClient

        protected FcrepoClient​(String username,
                               String password,
                               String host,
                               Boolean throwExceptionOnFailure)
        Create a FcrepoClient with a set of authentication values.
        Parameters:
        username - the username for the repository
        password - the password for the repository
        host - the authentication hostname (realm) for the repository
        throwExceptionOnFailure - whether to throw an exception on any non-2xx or 3xx HTTP responses
      • FcrepoClient

        protected FcrepoClient​(FcrepoHttpClientBuilder httpClientBuilder,
                               Boolean throwExceptionOnFailure)
        Create a FcrepoClient which uses the given FcrepoHttpClientBuilder to manage its http client. FcrepoClient will close the httpClient when close() is called.
        Parameters:
        httpClientBuilder - http client builder to use to connect to the repository
        throwExceptionOnFailure - whether to throw an exception on any non-2xx or 3xx HTTP responses
      • FcrepoClient

        protected FcrepoClient​(org.apache.http.impl.client.CloseableHttpClient httpClient,
                               Boolean throwExceptionOnFailure)
        Create a FcrepoClient which uses the given CloseableHttpClient. FcrepoClient will close the httpClient when close() is called.
        Parameters:
        httpClient - http client to use to connect to the repository
        throwExceptionOnFailure - whether to throw an exception on any non-2xx or 3xx HTTP responses
    • Method Detail

      • put

        public PutBuilder put​(URI url)
        Make a PUT request to create a resource with a specified path, or replace the triples associated with a resource with the triples provided in the request body.
        Parameters:
        url - the URL of the resource to which to PUT
        Returns:
        a put request builder object
      • patch

        public PatchBuilder patch​(URI url)
        Make a PATCH request to modify the triples associated with a resource with SPARQL-Update.
        Parameters:
        url - the URL of the resource to which to PATCH
        Returns:
        a patch request builder object
      • post

        public PostBuilder post​(URI url)
        Make a POST request to create a new resource within an LDP container.
        Parameters:
        url - the URL of the resource to which to POST
        Returns:
        a post request builder object
      • createMemento

        public OriginalMementoBuilder createMemento​(URI url)
        Make a POST request to create a new memento (LDPRm) within an LDPCv of the current version of a resource.
        Parameters:
        url - the URL of the LDPCv in which to create the LDPRm.
        Returns:
        a memento creation request builder object
      • createMemento

        public HistoricMementoBuilder createMemento​(URI url,
                                                    Instant mementoInstant)
        Make a POST request to create a new memento (LDPRm) within an LDPCv using the given memento-datetime and the request body.
        Parameters:
        url - the URL of the LDPCv in which to create the LDPRm.
        mementoInstant - the memento datetime as an Instant.
        Returns:
        a memento creation request builder object
      • createMemento

        public HistoricMementoBuilder createMemento​(URI url,
                                                    String mementoDatetime)
        Make a POST request to create a new memento (LDPRm) within an LDPCv using the given memento-datetime and the request body.
        Parameters:
        url - the URL of the LDPCv in which to create the LDPRm.
        mementoDatetime - the RFC1123 formatted memento datetime.
        Returns:
        a memento creation request builder object
      • delete

        public DeleteBuilder delete​(URI url)
        Make a DELETE request to delete a resource
        Parameters:
        url - the URL of the resource to which to DELETE
        Returns:
        a delete request builder object
      • get

        public GetBuilder get​(URI url)
        Make a GET request to retrieve the content of a resource
        Parameters:
        url - the URL of the resource to which to GET
        Returns:
        a get request builder object
      • head

        public HeadBuilder head​(URI url)
        Make a HEAD request to retrieve resource headers.
        Parameters:
        url - the URL of the resource to make the HEAD request on.
        Returns:
        a HEAD request builder object
      • options

        public OptionsBuilder options​(URI url)
        Make a OPTIONS request to output information about the supported HTTP methods, etc.
        Parameters:
        url - the URL of the resource to make the OPTIONS request on.
        Returns:
        a OPTIONS request builder object