Class IIIFResource
- Direct Known Subclasses:
IdentifierResource
,IdentifierResource
,IIIF2Resource
,ImageResource
,ImageResource
,InformationResource
,InformationResource
-
Field Summary
Fields inherited from class is.galia.resource.AbstractResource
PUBLIC_IDENTIFIER_HEADER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
constrainSizeToMaxPixels
(Size requestedSize, OperationList opList) When the size expressed in the endpoint URI ismax
, and the resulting image dimensions are larger thanKey.MAX_PIXELS
, the image must be downscaled to fit that area.void
doInit()
Initialization method, called after all necessary setters have been called but before any request handler method (likeAbstractResource.doGET()
etc.)protected Identifier
Returns the decoded identifier path component of the URI.protected String
Returns the first path argument, which, for IIIF Image API resources, is always an identifier.protected MetaIdentifier
Returns the decoded meta-identifier path component of the URI, which may include page number or other information.protected String
Returns the identifier that the client sees.protected 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
Variant ofAbstractImageResource.handleAuthInfo(AuthInfo)
For information requests, because information requests need to return a valid representation even for HTTP 4xx statuses per the IIIF Authentication API 1.0:protected void
setLastModifiedHeader
(Instant lastModified) protected void
validateScale
(Size orientedFullSize, Scale scale, Status invalidStatus) Ensures that the effective scale (considering scale constraint and any scale operation) is not greater than the value ofKey.MAX_SCALE
in the application configuration.Methods inherited from class is.galia.resource.AbstractImageResource
authorize, authorizeBeforeAccess, getPageIndex, handleAuthInfo, isBypassingCache, isBypassingCacheRead, redirectToNormalizedScaleConstraint
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
-
IIIFResource
public IIIFResource()
-
-
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 classAbstractImageResource
- Throws:
Exception
- upon any error. This may be aResourceException
to enable a custom status.
-
getIdentifier
Returns the decoded identifier path component of the URI. (This may not be the identifier that the client supplies or sees; for that, use
getPublicIdentifier()
.)N.B.: Depending on the image request endpoint API, The return value may include "meta-information" that is not part of the identifier but is encoded along with it. In that case, it is not safe to consume via this method, and
getMetaIdentifier()
should be used instead.- Specified by:
getIdentifier
in classAbstractImageResource
- Returns:
- Identifier, or
null
if the URI does not have an identifier path component. - See Also:
-
getIdentifierPathComponent
Returns the first path argument, which, for IIIF Image API resources, is always an identifier.
The result is not decoded and may be a
meta-identifier
. As such, it is not usable without additional processing.- Returns:
- Identifier, or
null
if no path arguments are available.
-
getMetaIdentifier
Description copied from class:AbstractImageResource
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.)- Specified by:
getMetaIdentifier
in classAbstractImageResource
- Returns:
- Instance corresponding to the first path argument, or
null
if no path arguments are available. - See Also:
-
getPublicIdentifier
Returns the identifier that the client sees. This will be the value of the
AbstractResource.PUBLIC_IDENTIFIER_HEADER
header, if available, or else theidentifier
URI path component.The result is not decoded, as the encoding may be influenced by
Key.SLASH_SUBSTITUTE
, for example.- See Also:
-
getPublicReference
Variant ofAbstractResource.getPublicReference()
that replaces the identifier path component's meta-identifier if an identifier path component is available.- Specified by:
getPublicReference
in classAbstractImageResource
- Parameters:
newMetaIdentifier
- Meta-identifier.
-
handleAuthInfoForInfoRequest
Variant of
AbstractImageResource.handleAuthInfo(AuthInfo)
For information requests, because information requests need to return a valid representation even for HTTP 4xx statuses per the IIIF Authentication API 1.0:In cases other than 302, the body of the response must be a valid Description Resource because the client needs to see the Authentication service descriptions in order to follow the appropriate workflow.
Using this method also requires overriding
AbstractImageResource.authorize()
andAbstractImageResource.authorizeBeforeAccess()
.- Throws:
IOException
ResourceException
-
setLastModifiedHeader
-
constrainSizeToMaxPixels
When the size expressed in the endpoint URI ismax
, and the resulting image dimensions are larger thanKey.MAX_PIXELS
, the image must be downscaled to fit that area. -
validateScale
protected void validateScale(Size orientedFullSize, Scale scale, Status invalidStatus) throws ScaleRestrictedException Ensures that the effective scale (considering scale constraint and any scale operation) is not greater than the value ofKey.MAX_SCALE
in the application configuration.- Parameters:
orientedFullSize
- Orientation-adjusted full source image size.scale
- May benull
.invalidStatus
- Status code to assign to theScaleRestrictedException
when validation fails.- Throws:
ScaleRestrictedException
-