CRUD Module
Both SolidSyncClient and SolidClient provide methods for reading and writing resources to your Solid Pod; that is, performing create/read/update/delete (CRUD) operations. The resources can be RDF resources as well as non-RDF resources (such as .jpg, .pdf, .txt, .json files).
SolidClient
SolidClientSolidClient is an asynchronous client for interacting with Solid resources.
SolidClient client = SolidClient.getClient();For an authenticated client, pass the authenticated Session object to the client:
client.session(mySession);See also:
.create()
.create()SolidClient.create() creates a new resource (SolidRDFSource, SolidContainer, and SolidNonRDFSource) at the specified location in your Pod.
For example, assume an Expense class that extends SolidRDFSource. To save an Expense object to a Pod, pass the object to the method:
client.create(newExpense).toCompletableFuture().join();If any container in the location path does not exist, the method creates the missing containers as well as the resource.
If the resource already exists at the location, the operation errors with
PreconditionFailedException. Use.update()instead.
.read()
.read()SolidClient.read() reads a resource from your Pod and map to a specified class.
For example, assume an Expense class that extends SolidRDFSource. To read the Expense resource from a Pod, pass the resource’s identifier (i.e., its URI) and the class:
.update()
.update()SolidClient.update() updates a resource in your Pod.
If the resource does not exist at the location, creates a new resource.
If the resource already exists at the location, overwrites the resource.
For example, assume an Expense class that extends SolidRDFSource. To update (or create) an Expense resource in a Pod, pass the object to the method:
.delete()
.delete()SolidClient.delete() deletes a resource from your Pod.
You can specify the URL of the resource to delete:
or
You can pass the object to delete:
For example, assume an
Expenseclass that extends SolidRDFSource.
SolidSyncClient
SolidSyncClient is a synchronous client for interacting with Solid resources.
For an authenticated client, pass the authenticated Session object to the client:
.create()
.create()SolidSyncClient.create() creates a new resource (SolidRDFSource, SolidContainer, and SolidNonRDFSource) at the specified location in your Pod.
For example, assume an Expense class that extends SolidRDFSource. To save an Expense object to a Pod, pass the object to the method:
.read()
.read()SolidSyncClient.read() reads a resource from your Pod and map to a specified class.
or example, assume an Expense class that extends SolidRDFSource. To read the Expense resource from a Pod, pass the resource’s identifier (i.e., its URI) and the class:
.update()
.update()SolidSyncClient.update() updates a resource in your Pod.
If the resource does not exist at the location, it creates a new resource.
If the resource already exists at the location, it overwrites the resource.
For example, assume a Expense class that extends SolidRDFSource. To update (or create) an Expense resource in a Pod, pass the object to the method:
.delete()
.delete()SolidSyncClient.delete() deletes a resource from your Pod.
You can specify the URL of the resource to delete:
or
You can specify the object to delete:
For example, assume a
Expenseclass that extends SolidRDFSource.
Headers
You can use the resource class’ getHeaders() method to get the headers:
See also Headers.
Alternatively, you can also use the resource class’ getMetadata() methods:
The getMetadata() methods return Solid-specific data (parsed into Java types) from a resource’s response headers. To access the complete set of response headers, use the getHeaders() method.
Last updated