public abstract class ContentExposingResource extends FedoraBaseResource
Modifier and Type | Field and Description |
---|---|
static String |
ACCEPT_DATETIME |
protected javax.servlet.ServletContext |
context |
protected ExternalContentHandlerFactory |
extContentHandlerFactory |
protected PathLockManager |
lockManager |
protected RdfNamespaceRegistry |
namespaceRegistry |
protected MultiPrefer |
prefer |
protected javax.ws.rs.core.Request |
request |
protected static com.google.common.base.Splitter.MapSplitter |
RFC3230_SPLITTER |
protected javax.servlet.http.HttpServletResponse |
servletResponse |
idTranslator, securityContext, session
binaryService, containerService, defaultPidMinter, headers, nodeService, pidMinter, uriInfo, versionService
Constructor and Description |
---|
ContentExposingResource() |
Modifier and Type | Method and Description |
---|---|
protected void |
addCacheControlHeaders(javax.servlet.http.HttpServletResponse servletResponse,
FedoraResource resource,
HttpSession session)
Add ETag and Last-Modified cache control headers to the response
|
protected void |
addExternalContentHeaders(FedoraResource resource) |
protected void |
addLinkAndOptionsHttpHeaders(FedoraResource resource)
Add Link and Option headers
|
protected void |
addResourceHttpHeaders(FedoraResource resource)
Add any resource-specific headers to the response
|
protected static String |
buildLink(String linkUri,
String relation)
Utility function for building a Link.
|
protected void |
checkCacheControlHeaders(javax.ws.rs.core.Request request,
javax.servlet.http.HttpServletResponse servletResponse,
FedoraResource resource,
HttpSession session)
Evaluate the cache control headers for the request to see if it can be served from
the cache.
|
protected void |
checkForInsufficientStorageException(Throwable rootThrowable,
Throwable throwable) |
protected static URI |
checksumURI(String checksum)
Create a checksum URI object.
|
protected javax.ws.rs.core.Response |
createUpdateResponse(FedoraResource resource,
boolean created)
Create the appropriate response after a create or update request is processed.
|
protected void |
evaluateRequestPreconditions(javax.ws.rs.core.Request request,
javax.servlet.http.HttpServletResponse servletResponse,
FedoraResource resource,
HttpSession session)
Evaluate request preconditions to ensure the resource is the expected state
|
protected abstract String |
externalPath() |
protected javax.ws.rs.core.MediaType |
getBinaryResourceMediaType(FedoraResource resource)
This method returns a MediaType for a binary resource.
|
protected int |
getChildrenLimit()
Calculate the max number of children to display at once.
|
protected javax.ws.rs.core.Response |
getContent(String rangeValue,
int limit,
RdfStream rdfStream,
FedoraResource resource)
This method returns an HTTP response with content body appropriate to the following arguments.
|
protected RdfStream |
getResourceTriples(FedoraResource resource) |
protected static javax.ws.rs.core.MediaType |
getSimpleContentType(javax.ws.rs.core.MediaType requestContentType) |
protected URI |
getUri(FedoraResource resource) |
protected static void |
hasRestrictedPath(String externalPath)
Check if a path has a segment prefixed with fedora:
|
protected static boolean |
isRdfContentType(String contentTypeString) |
protected static Collection<String> |
parseDigestHeader(String digest)
Parse the RFC-3230 Digest response header value.
|
protected void |
patchResourcewithSparql(FedoraResource resource,
String requestBody,
RdfStream resourceTriples) |
void |
postConstruct()
Run these actions after initializing this resource
|
protected void |
replaceResourceBinaryWithStream(FedoraBinary result,
InputStream requestBodyStream,
org.glassfish.jersey.media.multipart.ContentDisposition contentDisposition,
javax.ws.rs.core.MediaType contentType,
Collection<String> checksums,
String externalHandling,
String externalUrl) |
protected void |
replaceResourceWithStream(FedoraResource resource,
InputStream requestBodyStream,
javax.ws.rs.core.MediaType contentType,
RdfStream resourceTriples) |
protected FedoraResource |
resource() |
protected void |
setVaryAndPreferenceAppliedHeaders(javax.servlet.http.HttpServletResponse servletResponse,
MultiPrefer prefer,
FedoraResource resource) |
protected List<String> |
unpackLinks(List<String> rawLinks)
Multi-value Link header values parsed by the javax.ws.rs.core are not split out by the framework Therefore we
must do this ourselves.
|
asNode, getResourceFromPath, getUserPrincipal, setUpJMSInfo, translator
toPath
public static final String ACCEPT_DATETIME
@Context protected javax.ws.rs.core.Request request
@Context protected javax.servlet.http.HttpServletResponse servletResponse
@Context protected javax.servlet.ServletContext context
@BeanParam protected MultiPrefer prefer
@Inject protected PathLockManager lockManager
@Inject protected ExternalContentHandlerFactory extContentHandlerFactory
@Inject protected RdfNamespaceRegistry namespaceRegistry
protected static final com.google.common.base.Splitter.MapSplitter RFC3230_SPLITTER
public ContentExposingResource()
protected abstract String externalPath()
@PostConstruct public void postConstruct()
protected javax.ws.rs.core.Response getContent(String rangeValue, int limit, RdfStream rdfStream, FedoraResource resource) throws IOException
rangeValue
- starting and ending byte offsets, see Range
limit
- is the number of child resources returned in the response, -1 for allrdfStream
- to which response RDF will be concatenatedresource
- the fedora resourceIOException
- in case of error extracting contentprotected void setVaryAndPreferenceAppliedHeaders(javax.servlet.http.HttpServletResponse servletResponse, MultiPrefer prefer, FedoraResource resource)
protected RdfStream getResourceTriples(FedoraResource resource)
protected URI getUri(FedoraResource resource)
protected FedoraResource resource()
protected void addExternalContentHeaders(FedoraResource resource)
protected void addLinkAndOptionsHttpHeaders(FedoraResource resource)
resource
- the resource to generate headers forprotected static String buildLink(String linkUri, String relation)
linkUri
- String of URI for the link.relation
- the relation string.protected List<String> unpackLinks(List<String> rawLinks)
rawLinks
- the list of unprocessed linksprotected void addResourceHttpHeaders(FedoraResource resource)
resource
- the resourceprotected void checkCacheControlHeaders(javax.ws.rs.core.Request request, javax.servlet.http.HttpServletResponse servletResponse, FedoraResource resource, HttpSession session)
request
- the requestservletResponse
- the servlet responseresource
- the fedora resourcesession
- the sessionprotected void addCacheControlHeaders(javax.servlet.http.HttpServletResponse servletResponse, FedoraResource resource, HttpSession session)
Note: In this implementation, the HTTP headers for ETags and Last-Modified dates are swapped for fedora:Binary resources and their descriptions. Here, we are drawing a distinction between the HTTP resource and the LDP resource. As an HTTP resource, the last-modified header should reflect when the resource at the given URL was last changed. With fedora:Binary resources and their descriptions, this is a little complicated, for the descriptions have, as their subjects, the binary itself. And the fedora:lastModified property produced by that NonRdfSourceDescription refers to the last-modified date of the binary -- not the last-modified date of the NonRdfSourceDescription.
servletResponse
- the servlet responseresource
- the fedora resourcesession
- the sessionprotected void evaluateRequestPreconditions(javax.ws.rs.core.Request request, javax.servlet.http.HttpServletResponse servletResponse, FedoraResource resource, HttpSession session)
request
- the requestservletResponse
- the servlet responseresource
- the resourcesession
- the sessionprotected javax.ws.rs.core.Response createUpdateResponse(FedoraResource resource, boolean created)
resource
- The created or updated Fedora resource.created
- True for a newly-created resource, false for an updated resource.protected static javax.ws.rs.core.MediaType getSimpleContentType(javax.ws.rs.core.MediaType requestContentType)
protected static boolean isRdfContentType(String contentTypeString)
protected void replaceResourceBinaryWithStream(FedoraBinary result, InputStream requestBodyStream, org.glassfish.jersey.media.multipart.ContentDisposition contentDisposition, javax.ws.rs.core.MediaType contentType, Collection<String> checksums, String externalHandling, String externalUrl) throws InvalidChecksumException
InvalidChecksumException
protected void replaceResourceWithStream(FedoraResource resource, InputStream requestBodyStream, javax.ws.rs.core.MediaType contentType, RdfStream resourceTriples) throws MalformedRdfException
MalformedRdfException
protected void patchResourcewithSparql(FedoraResource resource, String requestBody, RdfStream resourceTriples)
protected javax.ws.rs.core.MediaType getBinaryResourceMediaType(FedoraResource resource)
resource
- the fedora resourceprotected static URI checksumURI(String checksum)
protected int getChildrenLimit()
protected static void hasRestrictedPath(String externalPath)
externalPath
- the path.protected static Collection<String> parseDigestHeader(String digest) throws UnsupportedAlgorithmException
digest
- The Digest header valueUnsupportedAlgorithmException
- if an unsupported digest is usedprotected void checkForInsufficientStorageException(Throwable rootThrowable, Throwable throwable) throws InvalidChecksumException
rootThrowable
- The original throwablethrowable
- The throwable under direct scrutiny.InvalidChecksumException
- in case there was a checksum mismatchCopyright © 2013–2018 DuraSpace, Inc.. All rights reserved.