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

    Constructors
    Modifier
    Constructor
    Description
     
    ResourceBase(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.
    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 Summary

    Modifier and Type
    Method
    Description
    javax.ws.rs.core.Response
    Handles DELETE method, deletes the RDF representation of this resource from the application's dataset, and returns response.
    javax.ws.rs.core.Response
    get()
     
     
    javax.ws.rs.core.CacheControl
    Returns the cache control of this resource, if specified.
    javax.ws.rs.core.HttpHeaders
    Returns HTTP headers of the current request.
    Content languages supported by the matching LDT template.
    org.apache.jena.ontology.Ontology
     
    org.apache.jena.ontology.OntResource
    Returns this resource as ontology resource.
    org.apache.jena.query.Query
    Returns query used to retrieve RDF description of this resource.
    org.apache.jena.rdf.model.Resource
     
    org.apache.jena.query.QuerySolutionMap
    Returns variable bindings for description query.
    javax.ws.rs.container.ResourceContext
     
    Returns sub-resource class.
    Returns LDT template that the URI of this resource matches.
    org.apache.jena.update.UpdateRequest
    Returns update used to remove RDF description of this resource.
    org.apache.jena.rdf.model.Resource
     
    javax.ws.rs.core.Response
    post(org.apache.jena.rdf.model.Model model)
    Handles POST method.
    javax.ws.rs.core.Response
    put(org.apache.jena.rdf.model.Model model)
    Handles PUT method.

    Methods inherited from class com.atomgraph.core.model.impl.QueriedResourceBase

    describe, getQuery, getService

    Methods inherited from class com.atomgraph.core.model.impl.ResourceBase

    getEncodings, getEntityTag, getLastModified, getMediaTypes, getRequest, getResponse, getResponseBuilder, getURI, getUriInfo, getWritableMediaTypes

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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 extends ldt:Document, this resource becomes a page resource and HATEOS metadata is added (relations to the container and previous/next page resources).
      Parameters:
      application - LDT application
      mediaTypes - mediaTypes
      uriInfo - URI information of the current request
      request - current request
      service - SPARQL service
      ontology - LDT ontology
      templateCall - templateCall
      httpHeaders - HTTP headers of the current request
      resourceContext - 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

      @Path("{path: .+}") public Class 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:
      getSubResource in class com.atomgraph.core.model.impl.QueriedResourceBase
      Returns:
      resource object
      See Also:
    • get

      public javax.ws.rs.core.Response get()
      Specified by:
      get in interface com.atomgraph.core.model.Resource
      Overrides:
      get in class com.atomgraph.core.model.impl.QueriedResourceBase
    • post

      public javax.ws.rs.core.Response post(org.apache.jena.rdf.model.Model model)
      Handles POST method. Appends the submitted RDF representation to the application's dataset.
      Specified by:
      post in interface com.atomgraph.core.model.Resource
      Overrides:
      post in class com.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)
      Handles PUT method. Deletes the resource description (if any) and appends the submitted RDF representation to the application's dataset.
      Specified by:
      put in interface com.atomgraph.core.model.Resource
      Overrides:
      put in class com.atomgraph.core.model.impl.QueriedResourceBase
      Parameters:
      model - RDF payload
      Returns:
      response 201 Created if resource did not exist, 200 OK if it did
    • delete

      public javax.ws.rs.core.Response delete()
      Handles DELETE method, deletes the RDF representation of this resource from the application's dataset, and returns response.
      Specified by:
      delete in interface com.atomgraph.core.model.Resource
      Overrides:
      delete in class com.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

      public List<Locale> getLanguages()
      Content languages supported by the matching LDT template.
      Overrides:
      getLanguages in class com.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

      public Optional<TemplateCall> getTemplateCall()
      Returns LDT template that the URI of this resource matches. If the request URI did not match any template, 404 Not Found was returned.
      Specified by:
      getTemplateCall in interface Resource
      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 as ldt:cacheControl on 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:
      getQuery in interface com.atomgraph.core.model.QueriedResource
      Overrides:
      getQuery in class com.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:
      getUpdate in interface QueriedResource
      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

      public Application getApplication()
      Specified by:
      getApplication in interface Resource
    • getOntology

      public org.apache.jena.ontology.Ontology getOntology()
      Specified by:
      getOntology in interface Resource