Class HttpResourceRepositoryFromFileSystemImpl

java.lang.Object
org.aksw.jena_sparql_api.http.repository.impl.HttpResourceRepositoryFromFileSystemImpl
All Implemented Interfaces:
HttpRepository, HttpResourceRepositoryFromFileSystem

public class HttpResourceRepositoryFromFileSystemImpl extends Object implements HttpResourceRepositoryFromFileSystem
  • Field Details

  • Constructor Details

    • HttpResourceRepositoryFromFileSystemImpl

      public HttpResourceRepositoryFromFileSystemImpl()
  • Method Details

    • hashToRelPath

      public static Path hashToRelPath(String hash)
      Utility method to convert a hash value (e.g. sha256) to a relative path by splitting after 'n' characters
      Parameters:
      hash -
      Returns:
    • create

      public static HttpResourceRepositoryFromFileSystemImpl create(Path absBasePath)
    • getResourceStores

      public Collection<ResourceStore> getResourceStores()
    • getDownloadStore

      public ResourceStore getDownloadStore()
    • setDownloadStore

      public void setDownloadStore(ResourceStore downloadStore)
    • getCacheStore

      public ResourceStore getCacheStore()
    • setCacheStore

      public void setCacheStore(ResourceStore cacheStore)
    • getHashStore

      public ResourceStore getHashStore()
    • setHashStore

      public void setHashStore(ResourceStore hashStore)
    • getStoreByPath

      public ResourceStore getStoreByPath(Path path)
    • getInfo

      public org.apache.jena.rdf.model.Resource getInfo(Path path)
    • readSymbolicLinkTransitive

      public List<Path> readSymbolicLinkTransitive(Path absPath)
    • getEntityForPath

      public RdfHttpEntityFile getEntityForPath(Path path)
      Description copied from interface: HttpResourceRepositoryFromFileSystem
      Obtain an entity for the given path The repository may consult several stores to complete this action.
      Specified by:
      getEntityForPath in interface HttpResourceRepositoryFromFileSystem
      Returns:
    • getEntities

      public Collection<RdfHttpEntityFile> getEntities(String uri)
    • createRequest

      public static org.apache.http.message.BasicHttpRequest createRequest(String url, String contentType, List<String> encodings)
    • get

      public static RdfHttpEntityFile get(HttpResourceRepositoryFromFileSystem repo, String url, String contentType, List<String> encodings) throws IOException
      Convenience method for requesting a resource with given content type and encodingsS
      Parameters:
      url -
      contentType -
      encodings -
      Returns:
      Throws:
      IOException
    • bestEncoding

      public String bestEncoding(Collection<String> encodings)
    • bestContentType

      public com.google.common.net.MediaType bestContentType(Collection<com.google.common.net.MediaType> contentTypes)
    • findBestPlanToServeRequest

      public static HttpResourceRepositoryFromFileSystemImpl.Plan findBestPlanToServeRequest(org.apache.http.HttpRequest request, Collection<RdfHttpEntityFile> entities, OpExecutor opExecutor) throws IOException
      Throws:
      IOException
    • expandHttpRequest

      public static org.apache.http.HttpRequest expandHttpRequest(org.apache.http.HttpRequest request)
    • validateEntity

      public boolean validateEntity(RdfHttpEntityFile entity)
    • get

      public RdfHttpEntityFile get(org.apache.http.HttpRequest request, Function<org.apache.http.HttpRequest,Map.Entry<org.apache.http.HttpRequest,org.apache.http.HttpResponse>> httpRequester) throws IOException
      Lookup an entity First, this method checks if the request can be served from the locally cached entities: It attempts to create a plan that transforms the available entities into a requested one. If this fails, this method examines the cached resource vary headers for whether fetching a remote entity can help to serve the request. If there is no cached resource, a request to the remote server is made with expanded headers. If this leads to a new entity being generated, then the process of planning is repeated with it. TODO I thought there was a way to enumerate in the HTTP headers for which values exists for Vary By default Vary only says that a request with a different value for the given header name may yield a different representation
      Specified by:
      get in interface HttpRepository
      Parameters:
      request -
      httpRequester -
      Returns:
      Throws:
      IOException
    • forceCreateFile

      public static void forceCreateFile(Path path)
    • forceCreateDirectories

      public static void forceCreateDirectories(Path path)
    • computeHashForEntity

      public static void computeHashForEntity(RdfHttpEntityFile rdfEntity, Path tmp)
      Compute a hash (sha256) for the content at path tmp and associate it with the given entity. If tmp is null, use the content of the entity.
      Parameters:
      rdfEntity -
      tmp -
    • saveResponse

      public RdfHttpEntityFile saveResponse(RdfHttpResourceFile targetResource, org.apache.http.HttpRequest request, org.apache.http.HttpResponse response) throws UnsupportedOperationException, IOException
      Derives the suffix which to append to the base path from the entity's headers.
      Parameters:
      basePath -
      entity -
      Throws:
      IOException
      UnsupportedOperationException
    • resolveRequest

      public static Map.Entry<org.apache.http.HttpRequest,org.apache.http.HttpResponse> resolveRequest(org.apache.http.HttpRequest request)
      May rewrite an original request and returns it together with its response
      Parameters:
      request -
      Returns:
    • getDefaultPath

      public static Path getDefaultPath()
    • createDefault

      public static HttpResourceRepositoryFromFileSystemImpl createDefault() throws IOException
      Throws:
      IOException
    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException