Class AbstractImageResource
- Direct Known Subclasses:
IIIFResource
,InformationResource
,TileResource
Resource
implementations that
respond to requests for images.-
Field Summary
Fields inherited from class is.galia.resource.AbstractResource
PUBLIC_IDENTIFIER_HEADER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Uses anAuthorizer
to determine how to respond to the request.protected boolean
Uses anAuthorizer
to determine how to respond to the request.void
doInit()
Initialization method, called after all necessary setters have been called but before any request handler method (likeAbstractResource.doGET()
etc.)protected abstract Identifier
Returns the identifier of the source image, which may be a filename, an object store key, or something else.protected abstract MetaIdentifier
Returns the decoded meta-identifier path component of the URI, which may include page number or other information.protected int
protected abstract Reference
getPublicReference
(MetaIdentifier newMetaIdentifier) Variant ofAbstractResource.getPublicReference()
that replaces the identifier path component's meta-identifier if an identifier path component is available.protected boolean
handleAuthInfo
(AuthInfo info) Handles anAuthInfo
which has been constructed from the return value of the pre-authorization or authorization delegate method.protected final boolean
Returns whether there is acache
argument set tofalse
ornocache
in the URI query string, indicating that cache reads and writes are both bypassed.protected final boolean
Returns whether there is acache
argument set torecache
in the URI query string, indicating that cache reads are bypassed.protected final boolean
If an identifier is present in the URI, and it contains a scale constraint suffix in a non-normalized form, this method redirects to a normalized URI.Methods inherited from class is.galia.resource.AbstractResource
authenticateUsingBasic, decodePathComponent, destroy, doDELETE, doGET, doHEAD, doOPTIONS, doPATCH, doPOST, doPUT, getCanonicalClientIPAddress, getCommonTemplateVars, getDelegate, getLocalBasePath, getLogger, getPreferredMediaTypes, getPublicReference, getPublicRootReference, getRepresentationDisposition, getRequest, getRequestContext, getResponse, getRoutes, negotiateContentType, setRequest, setResponse
-
Constructor Details
-
AbstractImageResource
public AbstractImageResource()
-
-
Method Details
-
doInit
Description copied from class:AbstractResource
Initialization method, called after all necessary setters have been called but before any request handler method (like
AbstractResource.doGET()
etc.)If an implementation class has anything to do with
image identifiers
, it should add the request identifier to therequest context
.Overrides must call
super
.- Overrides:
doInit
in classAbstractResource
- Throws:
Exception
- upon any error. This may be aResourceException
to enable a custom status.
-
authorize
Uses an
Authorizer
to determine how to respond to the request. The response is modified if necessary.The authorization system supports simple boolean authorization which maps to the HTTP 200 and 403 statuses.
Authorization can simultaneously be used in the context of the IIIF Authentication API, where it works a little differently. Here, HTTP 401 is returned instead of 403, and the response body does include image information. (See Interaction with Access-Controlled Resources. This means that IIIF information endpoints should swallow any
ResourceException
s with HTTP 401 status.- Returns:
- Whether authorization was successful.
false
indicates a redirect, and client code should abort. - Throws:
IOException
- if there was an I/O error while checking authorization.ResourceException
- if authorization resulted in an HTTP 400-level response.
-
authorizeBeforeAccess
Uses an
Authorizer
to determine how to respond to the request. The response is modified if necessary.The authorization system supports simple boolean authorization which maps to the HTTP 200 and 403 statuses.
Authorization can simultaneously be used in the context of the IIIF Authentication API, where it works a little differently. Here, HTTP 401 is returned instead of 403, and the response body does include image information. (See Interaction with Access-Controlled Resources. This means that IIIF information endpoints should swallow any
ResourceException
s with HTTP 401 status.- Returns:
- Whether authorization was successful.
false
indicates a redirect, and client code should abort. - Throws:
IOException
- if there was an I/O error while checking authorization.ResourceException
- if authorization resulted in an HTTP 400-level response.
-
handleAuthInfo
Handles anAuthInfo
which has been constructed from the return value of the pre-authorization or authorization delegate method. TheAuthInfo
may signal us to redirect (via HTTP 3xx), to authenticate (via HTTP 401), to forbid (via HTTP 403), or something else. We honor that by setting an appropriate status, setting appropriate response headers, maybe streaming an appropriate response entity, and ultimately returning eithertrue
if the request is authorized as-is, orfalse
if not.- Throws:
IOException
ResourceException
-
getIdentifier
Returns the identifier of the source image, which may be a filename, an object store key, or something else.- Returns:
- The identifier of the source image.
-
getMetaIdentifier
Returns the decoded meta-identifier path component of the URI, which may include page number or other information. (This may not be the path component that the client supplies or sees.)- Returns:
- Instance corresponding to the first path argument, or
null
if no path arguments are available. - See Also:
-
getPageIndex
protected int getPageIndex()- Returns:
- The page index (i.e. page number - 1) from the
meta-identifier
. If it does not exist,0
is returned.
-
getPublicReference
Variant ofAbstractResource.getPublicReference()
that replaces the identifier path component's meta-identifier if an identifier path component is available.- Parameters:
newMetaIdentifier
- Meta-identifier.
-
isBypassingCache
protected final boolean isBypassingCache()Returns whether there is acache
argument set tofalse
ornocache
in the URI query string, indicating that cache reads and writes are both bypassed.- Returns:
- Whether there is a
cache
argument set tofalse
ornocache
in the URI query string.
-
isBypassingCacheRead
protected final boolean isBypassingCacheRead()Returns whether there is acache
argument set torecache
in the URI query string, indicating that cache reads are bypassed.- Returns:
- Whether there is a
cache
argument set torecache
in the URI query string.
-
redirectToNormalizedScaleConstraint
If an identifier is present in the URI, and it contains a scale constraint suffix in a non-normalized form, this method redirects to a normalized URI.
Examples:
- 1:2
- No redirect
- 2:4
- Redirect to 1:2
- 1:1 & 5:5
- Redirect to no constraint
- Returns:
true
if redirecting. Clients should stop processing if this is the case.- Throws:
IOException
-