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 voidconstrainSizeToMaxPixels(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.voiddoInit()Initialization method, called after all necessary setters have been called but before any request handler method (likeAbstractResource.doGET()etc.)protected IdentifierReturns the decoded identifier path component of the URI.protected StringReturns the first path argument, which, for IIIF Image API resources, is always an identifier.protected MetaIdentifierReturns the decoded meta-identifier path component of the URI, which may include page number or other information.protected StringReturns the identifier that the client sees.protected ReferencegetPublicReference(MetaIdentifier newMetaIdentifier) Variant ofAbstractResource.getPublicReference()that replaces the identifier path component's meta-identifier if an identifier path component is available.protected booleanVariant 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 voidsetLastModifiedHeader(Instant lastModified) protected voidvalidateScale(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_SCALEin the application configuration.Methods inherited from class is.galia.resource.AbstractImageResource
authorize, authorizeBeforeAccess, getPageIndex, handleAuthInfo, isBypassingCache, isBypassingCacheRead, redirectToNormalizedScaleConstraintMethods 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:AbstractResourceInitialization 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:
doInitin classAbstractImageResource- Throws:
Exception- upon any error. This may be aResourceExceptionto 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:
getIdentifierin classAbstractImageResource- Returns:
- Identifier, or
nullif 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
nullif no path arguments are available.
-
getMetaIdentifier
Description copied from class:AbstractImageResourceReturns 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:
getMetaIdentifierin classAbstractImageResource- Returns:
- Instance corresponding to the first path argument, or
nullif 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_HEADERheader, if available, or else theidentifierURI 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:
getPublicReferencein 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:
IOExceptionResourceException
-
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_SCALEin the application configuration.- Parameters:
orientedFullSize- Orientation-adjusted full source image size.scale- May benull.invalidStatus- Status code to assign to theScaleRestrictedExceptionwhen validation fails.- Throws:
ScaleRestrictedException
-