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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ResourceStoreprotected ResourceStoreprotected ResourceStorestatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.net.MediaTypebestContentType(Collection<com.google.common.net.MediaType> contentTypes) bestEncoding(Collection<String> encodings) static voidcomputeHashForEntity(RdfHttpEntityFile rdfEntity, Path tmp) Compute a hash (sha256) for the content at path tmp and associate it with the given entity.static org.apache.http.message.BasicHttpRequestcreateRequest(String url, String contentType, List<String> encodings) static org.apache.http.HttpRequestexpandHttpRequest(org.apache.http.HttpRequest request) findBestPlanToServeRequest(org.apache.http.HttpRequest request, Collection<RdfHttpEntityFile> entities, OpExecutor opExecutor) static voidforceCreateDirectories(Path path) static voidforceCreateFile(Path path) static RdfHttpEntityFileget(HttpResourceRepositoryFromFileSystem repo, String url, String contentType, List<String> encodings) Convenience method for requesting a resource with given content type and encodingsSget(org.apache.http.HttpRequest request, Function<org.apache.http.HttpRequest, Map.Entry<org.apache.http.HttpRequest, org.apache.http.HttpResponse>> httpRequester) 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.static PathgetEntities(String uri) getEntityForPath(Path path) Obtain an entity for the given path The repository may consult several stores to complete this action.org.apache.jena.rdf.model.ResourcegetStoreByPath(Path path) static PathhashToRelPath(String hash) Utility method to convert a hash value (e.g.static voidreadSymbolicLinkTransitive(Path absPath) 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 responsesaveResponse(RdfHttpResourceFile targetResource, org.apache.http.HttpRequest request, org.apache.http.HttpResponse response) Derives the suffix which to append to the base path from the entity's headers.voidsetCacheStore(ResourceStore cacheStore) voidsetDownloadStore(ResourceStore downloadStore) voidsetHashStore(ResourceStore hashStore) booleanvalidateEntity(RdfHttpEntityFile entity)
-
Field Details
-
downloadStore
-
cacheStore
-
hashStore
-
IDENTITY_ENCODING
- See Also:
-
-
Constructor Details
-
HttpResourceRepositoryFromFileSystemImpl
public HttpResourceRepositoryFromFileSystemImpl()
-
-
Method Details
-
hashToRelPath
Utility method to convert a hash value (e.g. sha256) to a relative path by splitting after 'n' characters- Parameters:
hash-- Returns:
-
create
-
getResourceStores
-
getDownloadStore
-
setDownloadStore
-
getCacheStore
-
setCacheStore
-
getHashStore
-
setHashStore
-
getStoreByPath
-
getInfo
-
readSymbolicLinkTransitive
-
getEntityForPath
Description copied from interface:HttpResourceRepositoryFromFileSystemObtain an entity for the given path The repository may consult several stores to complete this action.- Specified by:
getEntityForPathin interfaceHttpResourceRepositoryFromFileSystem- Returns:
-
getEntities
-
createRequest
-
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
-
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
-
get
public RdfHttpEntityFile get(org.apache.http.HttpRequest request, Function<org.apache.http.HttpRequest, Map.Entry<org.apache.http.HttpRequest, throws IOExceptionorg.apache.http.HttpResponse>> httpRequester) 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:
getin interfaceHttpRepository- Parameters:
request-httpRequester-- Returns:
- Throws:
IOException
-
forceCreateFile
-
forceCreateDirectories
-
computeHashForEntity
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:
IOExceptionUnsupportedOperationException
-
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
-
createDefault
- Throws:
IOException
-
main
- Throws:
IOException
-