Package com.atomgraph.server.model.impl
Class ResourceBase
java.lang.Object
com.atomgraph.core.model.impl.ResourceBase
com.atomgraph.core.model.impl.QueriedResourceBase
com.atomgraph.server.model.impl.ResourceBase
- All Implemented Interfaces:
com.atomgraph.core.model.QueriedResource,com.atomgraph.core.model.Resource,QueriedResource,Resource
- Direct Known Subclasses:
Item
@Path("/")
public class ResourceBase
extends com.atomgraph.core.model.impl.QueriedResourceBase
implements Resource, QueriedResource
Base class of generic read-write Linked Data resources.
Configured declaratively using sitemap ontology to provide Linked Data layer over a SPARQL endpoint.
Supports pagination on containers (implemented using SPARQL query solution modifiers).
- Author:
- Martynas Jusevičius <martynas@atomgraph.com>
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionResourceBase(javax.ws.rs.core.UriInfo uriInfo, javax.ws.rs.core.Request request, com.atomgraph.core.MediaTypes mediaTypes, com.atomgraph.core.model.Service service, Application application, Optional<org.apache.jena.ontology.Ontology> ontology, Optional<TemplateCall> templateCall, javax.ws.rs.core.HttpHeaders httpHeaders, javax.ws.rs.container.ResourceContext resourceContext) Public JAX-RS instance.protectedResourceBase(javax.ws.rs.core.UriInfo uriInfo, javax.ws.rs.core.Request request, com.atomgraph.core.MediaTypes mediaTypes, URI uri, com.atomgraph.core.model.Service service, Application application, org.apache.jena.ontology.Ontology ontology, Optional<TemplateCall> templateCall, javax.ws.rs.core.HttpHeaders httpHeaders, javax.ws.rs.container.ResourceContext resourceContext) -
Method Summary
Modifier and TypeMethodDescriptionjavax.ws.rs.core.Responsedelete()HandlesDELETEmethod, deletes the RDF representation of this resource from the application's dataset, and returns response.javax.ws.rs.core.Responseget()javax.ws.rs.core.CacheControlReturns the cache control of this resource, if specified.javax.ws.rs.core.HttpHeadersReturns HTTP headers of the current request.Content languages supported by the matching LDT template.org.apache.jena.ontology.Ontologyorg.apache.jena.ontology.OntResourceReturns this resource as ontology resource.org.apache.jena.query.QuerygetQuery()Returns query used to retrieve RDF description of this resource.org.apache.jena.rdf.model.Resourceorg.apache.jena.query.QuerySolutionMapReturns variable bindings for description query.javax.ws.rs.container.ResourceContextReturns sub-resource class.Returns LDT template that the URI of this resource matches.org.apache.jena.update.UpdateRequestReturns update used to remove RDF description of this resource.org.apache.jena.rdf.model.Resourcejavax.ws.rs.core.Responsepost(org.apache.jena.rdf.model.Model model) HandlesPOSTmethod.javax.ws.rs.core.Responseput(org.apache.jena.rdf.model.Model model) HandlesPUTmethod.Methods inherited from class com.atomgraph.core.model.impl.QueriedResourceBase
describe, getQuery, getServiceMethods inherited from class com.atomgraph.core.model.impl.ResourceBase
getEncodings, getEntityTag, getLastModified, getMediaTypes, getRequest, getResponse, getResponseBuilder, getURI, getUriInfo, getWritableMediaTypesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atomgraph.core.model.QueriedResource
describe
-
Constructor Details
-
ResourceBase
@Inject public ResourceBase(@Context javax.ws.rs.core.UriInfo uriInfo, @Context javax.ws.rs.core.Request request, com.atomgraph.core.MediaTypes mediaTypes, com.atomgraph.core.model.Service service, Application application, Optional<org.apache.jena.ontology.Ontology> ontology, Optional<TemplateCall> templateCall, @Context javax.ws.rs.core.HttpHeaders httpHeaders, @Context javax.ws.rs.container.ResourceContext resourceContext) Public JAX-RS instance. Suitable for subclassing. If the request URI does not match any URI template in the sitemap ontology, 404 Not Found is returned. If the matching template extendsldt:Document, this resource becomes a page resource and HATEOS metadata is added (relations to the container and previous/next page resources).- Parameters:
application- LDT applicationmediaTypes- mediaTypesuriInfo- URI information of the current requestrequest- current requestservice- SPARQL serviceontology- LDT ontologytemplateCall- templateCallhttpHeaders- HTTP headers of the current requestresourceContext- resource context
-
ResourceBase
protected ResourceBase(javax.ws.rs.core.UriInfo uriInfo, javax.ws.rs.core.Request request, com.atomgraph.core.MediaTypes mediaTypes, URI uri, com.atomgraph.core.model.Service service, Application application, org.apache.jena.ontology.Ontology ontology, Optional<TemplateCall> templateCall, javax.ws.rs.core.HttpHeaders httpHeaders, javax.ws.rs.container.ResourceContext resourceContext)
-
-
Method Details
-
getSubResource
Returns sub-resource class. If we want Jersey to manage the life-cycle of the sub-resource, we need to return a class, not an instance. By default matches any path.- Overrides:
getSubResourcein classcom.atomgraph.core.model.impl.QueriedResourceBase- Returns:
- resource object
- See Also:
-
get
public javax.ws.rs.core.Response get()- Specified by:
getin interfacecom.atomgraph.core.model.Resource- Overrides:
getin classcom.atomgraph.core.model.impl.QueriedResourceBase
-
post
public javax.ws.rs.core.Response post(org.apache.jena.rdf.model.Model model) HandlesPOSTmethod. Appends the submitted RDF representation to the application's dataset.- Specified by:
postin interfacecom.atomgraph.core.model.Resource- Overrides:
postin classcom.atomgraph.core.model.impl.QueriedResourceBase- Parameters:
model- the RDF payload- Returns:
- response
200 OK
-
put
public javax.ws.rs.core.Response put(org.apache.jena.rdf.model.Model model) HandlesPUTmethod. Deletes the resource description (if any) and appends the submitted RDF representation to the application's dataset.- Specified by:
putin interfacecom.atomgraph.core.model.Resource- Overrides:
putin classcom.atomgraph.core.model.impl.QueriedResourceBase- Parameters:
model- RDF payload- Returns:
- response
201 Createdif resource did not exist,200 OKif it did
-
delete
public javax.ws.rs.core.Response delete()HandlesDELETEmethod, deletes the RDF representation of this resource from the application's dataset, and returns response.- Specified by:
deletein interfacecom.atomgraph.core.model.Resource- Overrides:
deletein classcom.atomgraph.core.model.impl.QueriedResourceBase- Returns:
- response
204 No Content
-
getQuerySolutionMap
public org.apache.jena.query.QuerySolutionMap getQuerySolutionMap()Returns variable bindings for description query.- Returns:
- map with variable bindings
-
getLanguages
Content languages supported by the matching LDT template.- Overrides:
getLanguagesin classcom.atomgraph.core.model.impl.ResourceBase- Returns:
- list of locales
- See Also:
-
getOntResource
public org.apache.jena.ontology.OntResource getOntResource()Returns this resource as ontology resource.- Returns:
- ontology resource
-
getTemplateCall
Returns LDT template that the URI of this resource matches. If the request URI did not match any template,404 Not Foundwas returned.- Specified by:
getTemplateCallin interfaceResource- Returns:
- ontology class
-
getCacheControl
public javax.ws.rs.core.CacheControl getCacheControl()Returns the cache control of this resource, if specified. The control value can be specified asldt:cacheControlon templates in the sitemap ontology.- Returns:
- cache control object or null, if not specified
-
getQuery
public org.apache.jena.query.Query getQuery()Returns query used to retrieve RDF description of this resource. Query solution bindings are applied by default.- Specified by:
getQueryin interfacecom.atomgraph.core.model.QueriedResource- Overrides:
getQueryin classcom.atomgraph.core.model.impl.QueriedResourceBase- Returns:
- query object with applied solution bindings
- See Also:
-
getQueryResource
public org.apache.jena.rdf.model.Resource getQueryResource() -
getUpdate
public org.apache.jena.update.UpdateRequest getUpdate()Returns update used to remove RDF description of this resource. Query solution bindings are applied by default.- Specified by:
getUpdatein interfaceQueriedResource- Returns:
- update object with applied solution bindings
- See Also:
-
getUpdateResource
public org.apache.jena.rdf.model.Resource getUpdateResource() -
getHttpHeaders
public javax.ws.rs.core.HttpHeaders getHttpHeaders()Returns HTTP headers of the current request.- Returns:
- header object
-
getResourceContext
public javax.ws.rs.container.ResourceContext getResourceContext() -
getApplication
- Specified by:
getApplicationin interfaceResource
-
getOntology
public org.apache.jena.ontology.Ontology getOntology()- Specified by:
getOntologyin interfaceResource
-