Package com.inrupt.client.solid
Support for Solid specific concepts for the Inrupt Java Client Libraries.
Solid Client
This Solid domain-specific module contains two dedicated Solid clients you can make use of:
SolidClient
which works asynchronously and SolidSyncClient
which works synchronously.
One can instantiate a Solid client in different ways, depending on the use case:
A simple direct way is with the following line:
SolidClient client = SolidClient.getClient();
This will make use of the client that is currently loaded on the classpath. (If you have the core module (inrupt-client-core) loaded, this will make use of the DefaultClient).
The above line is equivalent to:
Client classPathClient = ClientProvider.getClient();
SolidClient client = SolidClient.getClientBuilder().client(classPathClient).build();
The Solid client can be used to perform CRUD operations on Solid resources.
In this example, the client reads a Solid resource as a Playlist
object.
var playlist = client.read(uri, Playlist.class);
playlist.thenAccept(p -> {
displayTitle(p.getTitle());
displaySongs(p.getSongs());
}).toCompletableFuture().join();
One may also create new resources.
var playlist = new Playlist(uri);
playlist.setTitle("Jazz Collection");
playlist.addSong(song1);
playlist.addSong(song2);
client.create(playlist).toCompletableFuture().join();
Or update existing resources.
var playlist = client.read(uri, Playlist.class);
playlist.thenCompose(p -> {
p.setTitle("Bossa Nova");
p.removeSong(song1);
p.addSong(song3);
return client.update(p);
}).toCompletableFuture().join();
Or delete resources.
client.delete(uri).toCompletableFuture().join();
Solid RDFSource and Solid Container
This module also contains a BodyHandler which consumes the response body
and converts it into a SolidRDFSource
or a SolidContainer
Java object.
The following example reads a Solid Container and presents it as a SolidContainer
Java object:
Request request = Request.newBuilder()
.uri(URI.create("https://solid.example/storage/"))
.header("Accept", "text/turtle")
.GET()
.build();
Response<SolidContainer> response = client.send(
request,
SolidResourceHandlers.ofSolidContainer()
).toCompletableFuture().join();
System.out.println("HTTP status: " + response.statusCode());
System.out.println("Resource URI: " + response.body().getId());
-
ClassDescriptionA runtime exception that represents an HTTP bad request (400) response.A runtime exception that represents an HTTP conflict (409) response..A runtime exception that represents an HTTP forbidden (403) response.A runtime exception that represents an HTTP gone (410) response.A runtime exception that represents an HTTP internal server error (500) response.Solid Resource Metadata.A Builder class for Metadata instances.A runtime exception that represents an HTTP method not allowed (405) response.A runtime exception that represents an HTTP not acceptable (406) response.A runtime exception that represents an HTTP not found (404) response.A runtime exception that represents an HTTP precondition failed (412) response.A high-level client for interacting with Solid resources.A builder class for a
SolidClient
.A runtime exception for use with SolidClient HTTP operations.A Solid Container Object.A non-RDF-bearing Solid Resource.A Solid Resource Object.A runtime exception for use with Solid resource related errors.Body handlers for Solid Resources.A reference to a Solid Resource without any corresponding data.A high-level synchronous client for interacting with Solid resources.A builder class for aSolidSyncClient
.A runtime exception that represents an HTTP too many requests (429) response.A runtime exception that represents an HTTP unauthorized (401) response.A runtime exception that represents an HTTP unsupported media type (415) response.