Package org.trellisldp.api
Interface ResourceService
-
- All Superinterfaces:
RetrievalService<Resource>
- All Known Implementing Classes:
DBResourceService
,InMemoryResourceService
,NoopResourceService
,TriplestoreResourceService
public interface ResourceService extends RetrievalService<Resource>
The ResourceService provides methods for creating, retrieving and manipulating Trellis resources.- Implementation Requirements:
- Implementations should take care to provide any initialization needed, in a constructor or methods
managed by an external framework (e.g. using
PostConstruct
). This may or may not include actions in external systems like databases, which may be better managed elsewhere.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CompletionStage<Void>
add(IRI identifier, Dataset dataset)
default CompletionStage<Void>
create(Metadata metadata, Dataset dataset)
Create a resource in the server.CompletionStage<Void>
delete(Metadata metadata)
Delete a resource from the server.String
generateIdentifier()
An identifier generator.default IRI
getResourceIdentifier(String baseUrl, String path)
Get a resource identifier from a request URL.CompletionStage<Void>
replace(Metadata metadata, Dataset dataset)
Replace a resource in the server.default RDFTerm
skolemize(RDFTerm term)
Skolemize a blank node.Set<IRI>
supportedInteractionModels()
Return a collection of interaction models supported by this Resource Service.default <T extends RDFTerm>
TtoExternal(T term, String baseUrl)
Return an "external" representation of an RDF term.default <T extends RDFTerm>
TtoInternal(T term, String baseUrl)
Return an "internal" representation of an RDF term.CompletionStage<Void>
touch(IRI identifier)
Update the modification date of the provided resource.default RDFTerm
unskolemize(RDFTerm term)
Un-skolemize a blank node.-
Methods inherited from interface org.trellisldp.api.RetrievalService
get
-
-
-
-
Method Detail
-
create
default CompletionStage<Void> create(Metadata metadata, Dataset dataset)
Create a resource in the server.- Parameters:
metadata
- metadata for the new resourcedataset
- the dataset to be persisted- Returns:
- a new completion stage that, when the stage completes normally, indicates that the supplied data were
successfully created in the corresponding persistence layer. In the case of an unsuccessful write operation,
the
CompletionStage
will complete exceptionally and can be handled withCompletionStage.handle(java.util.function.BiFunction<? super T, java.lang.Throwable, ? extends U>)
,CompletionStage.exceptionally(java.util.function.Function<java.lang.Throwable, ? extends T>)
or similar methods. - Implementation Requirements:
- the default implementation of this method is to proxy create requests to the
replace(org.trellisldp.api.Metadata, org.apache.commons.rdf.api.Dataset)
method.
-
replace
CompletionStage<Void> replace(Metadata metadata, Dataset dataset)
Replace a resource in the server.- Parameters:
metadata
- metadata for the resourcedataset
- the dataset to be persisted- Returns:
- a new completion stage that, when the stage completes normally, indicates that the supplied data
were successfully stored in the corresponding persistence layer. In the case of an unsuccessful write operation,
the
CompletionStage
will complete exceptionally and can be handled withCompletionStage.handle(java.util.function.BiFunction<? super T, java.lang.Throwable, ? extends U>)
,CompletionStage.exceptionally(java.util.function.Function<java.lang.Throwable, ? extends T>)
or similar methods.
-
delete
CompletionStage<Void> delete(Metadata metadata)
Delete a resource from the server.- Parameters:
metadata
- metadata for the resource- Returns:
- a new completion stage that, when the stage completes normally, indicates that the resource
was successfully deleted from the corresponding persistence layer. In the case of an unsuccessful delete
operation, the
CompletionStage
will complete exceptionally and can be handled withCompletionStage.handle(java.util.function.BiFunction<? super T, java.lang.Throwable, ? extends U>)
,CompletionStage.exceptionally(java.util.function.Function<java.lang.Throwable, ? extends T>)
or similar methods.
-
add
CompletionStage<Void> add(IRI identifier, Dataset dataset)
- Parameters:
identifier
- the identifier under which to persist a datasetdataset
- a dataset to persist- Returns:
- a new completion stage that, when the stage completes normally, indicates that the supplied data
were successfully stored in the corresponding persistence layer. In the case of an unsuccessful write operation,
the
CompletionStage
will complete exceptionally and can be handled withCompletionStage.handle(java.util.function.BiFunction<? super T, java.lang.Throwable, ? extends U>)
,CompletionStage.exceptionally(java.util.function.Function<java.lang.Throwable, ? extends T>)
or similar methods.
-
skolemize
default RDFTerm skolemize(RDFTerm term)
Skolemize a blank node.- Parameters:
term
- the RDF term- Returns:
- a skolemized node, if a blank node; otherwise the original term
-
unskolemize
default RDFTerm unskolemize(RDFTerm term)
Un-skolemize a blank node.- Parameters:
term
- the RDF term- Returns:
- a blank node, if a previously-skolemized node; otherwise the original term
-
toInternal
default <T extends RDFTerm> T toInternal(T term, String baseUrl)
Return an "internal" representation of an RDF term.- Type Parameters:
T
- the type of RDF term- Parameters:
term
- the RDF termbaseUrl
- the base URL of the domain- Returns:
- the "internal" RDF term
-
toExternal
default <T extends RDFTerm> T toExternal(T term, String baseUrl)
Return an "external" representation of an RDF term.- Type Parameters:
T
- the type of RDF term- Parameters:
term
- the RDF termbaseUrl
- the base URL of the domain- Returns:
- the "external" RDF term
-
getResourceIdentifier
default IRI getResourceIdentifier(String baseUrl, String path)
Get a resource identifier from a request URL.- Parameters:
path
- the request pathbaseUrl
- the request base URL- Returns:
- the Trellis resource identifier
- Implementation Requirements:
- the default implementation of this method removes the base URL from the internal identifier.
-
touch
CompletionStage<Void> touch(IRI identifier)
Update the modification date of the provided resource.- Parameters:
identifier
- the identifier of the resource- Returns:
- a new completion stage that, when the stage completes normally, indicates that the identified resource has been updated with a new modification date.
- API Note:
- In general, when this method is called, it can be expected that the target resource will already exist. In cases where that resource does not already exist, an implementation may choose to throw an exception, log an error or simply do nothing.
-
supportedInteractionModels
Set<IRI> supportedInteractionModels()
Return a collection of interaction models supported by this Resource Service.- Returns:
- a set of supported interaction models
-
generateIdentifier
String generateIdentifier()
An identifier generator.- Returns:
- a new identifier
-
-