Interface JavaDelegate
public interface JavaDelegate
Interface to be implemented by JVM language-based delegate classes.
The application will create an instance of an implementation early in the request cycle and dispose of it at the end of the request cycle. Instances don't need to be thread-safe, but sharing information across instances (requests) does need to be done thread-safely.
The methods in this interface are considered public API. No other part of the application is considered public API, unless so documented, and breaking changes to it may happen at any time.
- Since:
- 5.0
- 
Method SummaryModifier and Type Method Description java.lang.Objectauthorize()Returns authorization status for the current request.java.util.Map<java.lang.String,java.lang.Object>deserializeMetaIdentifier(java.lang.String metaIdentifier)Deserializes the given meta-identifier string into a map of its component parts.java.lang.StringgetAzureStorageSourceBlobKey()N.B.: this method should not try to perform authorization.JavaContextgetContext()java.util.Map<java.lang.String,java.lang.Object>getExtraIIIF2InformationResponseKeys()Adds additional keys to an Image API 2.x information response.java.util.Map<java.lang.String,java.lang.Object>getExtraIIIF3InformationResponseKeys()Adds additional keys to an Image API 2.x information response.java.lang.StringgetFilesystemSourcePathname()N.B.: this method should not try to perform authorization.java.util.Map<java.lang.String,java.lang.Object>getHTTPSourceResourceInfo()Returns one of the following:java.lang.StringgetJDBCSourceDatabaseIdentifier()N.B.: this method should not try to perform authorization.java.lang.StringgetJDBCSourceLookupSQL()java.lang.StringgetJDBCSourceMediaType()Returns either the media (MIME) type of an image, or an SQL statement that can be used to retrieve it, if it is stored in the database.java.lang.StringgetMetadata()Returns XMP metadata to embed in the derivative image.java.util.Map<java.lang.String,java.lang.Object>getOverlay()Tells the server what overlay, if any, to apply to an image.java.util.List<java.util.Map<java.lang.String,java.lang.Long>>getRedactions()Tells the server what regions of an image to redact in response to a request.java.util.Map<java.lang.String,java.lang.String>getS3SourceObjectInfo()N.B.: this method should not try to perform authorization.java.lang.StringgetSource()Tells the server which source for theidentifier in the context.java.lang.ObjectpreAuthorize()Returns authorization status for the current request.java.lang.StringserializeMetaIdentifier(java.util.Map<java.lang.String,java.lang.Object> metaIdentifier)Serializes the given meta-identifier map.voidsetContext(JavaContext context)Invoked automatically early in the request cycle and not for public use.
- 
Method Details- 
getContextJavaContext getContext()- Returns:
- Object containing information about the current request.
 
- 
setContextInvoked automatically early in the request cycle and not for public use.
- 
preAuthorizejava.lang.Object preAuthorize()Returns authorization status for the current request. This method is called upon all requests to all public endpoints early in the request cycle, before any image has been accessed. This means that some context properties (like full_size) will not be available yet.This method should implement all possible authorization logic except that which requires any of the context keys that aren't yet available. This will ensure efficient authorization failures. Implementations should assume that the underlying resource is available, and not try to check for it. Possible return values: - A boolean indicating whether the request is fully authorized or not. If not, the client will receive a 403 Forbidden response.
- Map with a status_codekey.- If it corresponds to an integer from 200-299, the request is authorized.
- If it corresponds to an integer from 300-399:
                 - If the map also contains a locationkey corresponding to a URI string, the request will be redirected to that URI using that code.
- If the map also contains scale_numeratorandscale_denominatorkeys, the request will be redirected using thhat code to a virtual reduced- scale version of the source image.
 
- If the map also contains a 
- If it corresponds to 401, the map must include a challengekey corresponding to aWWW-Authenticateheader value.
 
 
- 
authorizejava.lang.Object authorize()Returns authorization status for the current request. Will be called upon all requests to all public image (not information) endpoints. This is a counterpart of preAuthorize()that is invoked later in the request cycle, once more information about the underlying image has become available. It should only contain logic that depends on context properties that contain information about the source image (likeJavaContext.getFullSize(),JavaContext.getMetadata(), etc.Implementations should assume that the underlying resource is available, and not try to check for it. The available return values are the same as for preAuthorize().
- 
deserializeMetaIdentifierjava.util.Map<java.lang.String,java.lang.Object> deserializeMetaIdentifier(java.lang.String metaIdentifier)Deserializes the given meta-identifier string into a map of its component parts. This method is called only when the meta_identifier.transformerconfiguration key is set toDelegateMetaIdentifierTransformer.The map contains the following keys: - identifier(required)
- String identifier.
- page_number(optional)
- Integer page number.
- scale_constraint(optional>
- Two-element array with scale constraint numerator at position 0 and denominator at position 1.
 - Returns:
- See above. The return value should be compatible with the
         argument to serializeMetaIdentifier(Map).
- See Also:
- serializeMetaIdentifier(Map)
 
- 
getExtraIIIF2InformationResponseKeysjava.util.Map<java.lang.String,java.lang.Object> getExtraIIIF2InformationResponseKeys()Adds additional keys to an Image API 2.x information response. See the IIIF Image API 2.1 specification and "endpoints" section of the user manual.- Returns:
- Map to merge into an Image API 2.x information response. Return an empty map to add nothing.
 
- 
getExtraIIIF3InformationResponseKeysjava.util.Map<java.lang.String,java.lang.Object> getExtraIIIF3InformationResponseKeys()Adds additional keys to an Image API 2.x information response. See the IIIF Image API 3.0 specification and "endpoints" section of the user manual.- Returns:
- Map to merge into an Image API 3.x information response. Return an empty map to add nothing.
 
- 
getSourcejava.lang.String getSource()Tells the server which source for theidentifier in the context.- Returns:
- Source name.
 
- 
getAzureStorageSourceBlobKeyjava.lang.String getAzureStorageSourceBlobKey()N.B.: this method should not try to perform authorization.preAuthorize()andauthorize()should be used instead.- Returns:
- Blob key of the image corresponding to the identifier in the context, ornullif not found.
 
- 
getFilesystemSourcePathnamejava.lang.String getFilesystemSourcePathname()N.B.: this method should not try to perform authorization.preAuthorize()andauthorize()should be used instead.- Returns:
- Absolute pathname of the image corresponding to the identifier in the context, ornullif not found.
 
- 
getHTTPSourceResourceInfojava.util.Map<java.lang.String,java.lang.Object> getHTTPSourceResourceInfo()Returns one of the following: - String URI
- Map with the following keys:
         - uri
- String (required)
- username
- String (required for HTTP Basic authentication)
- secret
- String (required for HTTP Basic authentication)
- headers
- Map of request header name-value pairs (optional)
 
- nullif not found
 N.B.: this method should not try to perform authorization. preAuthorize()andauthorize()should be used instead.
- 
getJDBCSourceDatabaseIdentifierjava.lang.String getJDBCSourceDatabaseIdentifier()N.B.: this method should not try to perform authorization. preAuthorize()andauthorize()should be used instead.- Returns:
- Database identifier of the image corresponding to the identifier in the context, ornullif not found.
 
- 
getJDBCSourceMediaTypejava.lang.String getJDBCSourceMediaType()Returns either the media (MIME) type of an image, or an SQL statement that can be used to retrieve it, if it is stored in the database. In the latter case, theSELECTandFROMclauses should be in uppercase in order to be autodetected. Ifnullis returned, the media type will be inferred some other way, such as by identifier extension or magic bytes.
- 
getJDBCSourceLookupSQLjava.lang.String getJDBCSourceLookupSQL()- Returns:
- SQL statement that selects the BLOB corresponding to the value
         returned by getJDBCSourceDatabaseIdentifier().
 
- 
getS3SourceObjectInfojava.util.Map<java.lang.String,java.lang.String> getS3SourceObjectInfo()N.B.: this method should not try to perform authorization.preAuthorize()andauthorize()should be used instead.- Returns:
- Map containing bucketandkeykeys, ornullif not found.
 
- 
getOverlayjava.util.Map<java.lang.String,java.lang.Object> getOverlay()Tells the server what overlay, if any, to apply to an image. Called upon all image requests to any endpoint if overlays are enabled and the overlay strategy is set to ScriptStrategyin the application configuration.Possible return values: - For string overlays, a map with the following keys:
         - background_color
- CSS-compliant RGB(A) color.
- color
- CSS-compliant RGB(A) color.
- font
- Font name.
- font_min_size
- Minimum font size in points (ignored when word_wrapistrue.
- font_size
- Font size in points.
- font_weight
- Font weight based on 1.
- glyph_spacing
- Glyph spacing based on 0.
- inset
- Pixels of inset.
- position
- Position like top left,center right, etc.
- string
- String to render.
- stroke_color
- CSS-compliant RGB(A) text outline color.
- stroke_width
- Text outline width in pixels.
- word_wrap
- Whether to wrap long lines within string.
 
- For image overlays, a map with the following keys:
         - image
- Image pathname or URL.
- position
- See above.
- inset
- See above.
 
- nullfor no overlay.
 
- For string overlays, a map with the following keys:
         
- 
getRedactionsjava.util.List<java.util.Map<java.lang.String,java.lang.Long>> getRedactions()Tells the server what regions of an image to redact in response to a request. Will be called upon all image requests to any endpoint.- Returns:
- List of maps, each with x,y,width, andheightkeys; or an empty list if no redactions are to be applied.
 
- 
getMetadatajava.lang.String getMetadata()Returns XMP metadata to embed in the derivative image. Source image metadata is available in the metadata context property.Only XMP can be embedded in derivative images. See the user manual for examples of working with the XMP model programmatically. - Returns:
- String or containing XMP data to embed in the derivative image,
         or nullto not embed anything.
 
- 
serializeMetaIdentifierjava.lang.String serializeMetaIdentifier(java.util.Map<java.lang.String,java.lang.Object> metaIdentifier)Serializes the given meta-identifier map. This method is called only when the meta_identifier.transformerconfiguration key is set toDelegateMetaIdentifierTransformer.- Parameters:
- metaIdentifier- See- deserializeMetaIdentifier(String)for a description of the map structure.
- Returns:
- Serialized meta-identifier compatible with the argument to
         deserializeMetaIdentifier(String).
- See Also:
- deserializeMetaIdentifier(String)
 
 
-