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 one 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());
-
Interface Summary Interface Description SolidResource -
Class Summary Class Description Metadata Solid Resource Metadata.Metadata.Builder A Builder class for Metadata instances.SolidClient A high-level client for interacting with Solid resources.SolidClient.Builder A builder class for aSolidClient
.SolidContainer A Solid Container Object.SolidNonRDFSource A non-RDF-bearing Solid Resource.SolidRDFSource A Solid Resource Object.SolidResourceHandlers Body handlers for Solid Resources.SolidResourceReference A reference to a Solid Resource without any corresponding data.SolidSyncClient A high-level synchronous client for interacting with Solid resources.SolidSyncClient.Builder A builder class for aSolidSyncClient
. -
Exception Summary Exception Description DataMappingException SolidClientException A runtime exception for use with SolidClient HTTP operations.SolidResourceException A runtime exception for use with Solid resource related errors.