Class IIIFUtils
java.lang.Object
org.dspace.app.iiif.service.utils.IIIFUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BitstreamServiceprotected com.fasterxml.jackson.databind.module.SimpleModuleprotected com.fasterxml.jackson.databind.ObjectMapperstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasJson(de.digitalcollections.iiif.model.sharedcanvas.Resource<?> resource) Serializes the json response.getBitstreamForCanvas(Context context, Item item, int canvasPosition) Retrives a bitstream based on its position in the IIIF bundle.getBitstreamMimeType(Bitstream bitstream, Context context) Returns the bitstream mime typegetBundleIIIFToC(Bundle bundle) Return the iiif toc for the specified bundleintgetCanvasHeight(Bitstream bitstream, Bundle bundle, Item item, int defaultHeight) Return the height for the canvas associated with the bitstream.getCanvasId(int position) Returns the canvas path with position.intgetCanvasId(String canvasId) Extracts canvas position from the URL input path.getCanvasNaming(Item item, String defaultNaming) Return the prefix to use to generate canvas name for canvas that has no an explicit IIIF labelintgetCanvasWidth(Bitstream bitstream, Bundle bundle, Item item, int defaultWidth) Return the width for the canvas associated with the bitstream.getIIIFBitstreams(Context context, Bundle bundle) Return all the bitstreams in the bundle to be used as IIIF resourcesgetIIIFBitstreams(Context context, Item item) Return all the bitstreams in the item to be used as IIIF resourcesgetIIIFBundles(Item item) getIIIFDescription(DSpaceObject dso, String defaultDescription) Return the custom iiif description for the resource or the provided default if nonegetIIIFLabel(DSpaceObject dso, String defaultLabel) Return the custom iiif label for the resource or the provided default if nonegetIIIFToCs(Bitstream bitstream, String prefix) Return the table of contents (toc) positions in the iiif structure where the resource appears.getIIIFViewingHint(Item item, String defaultHint) Return the iiif viewing hint for the itemint[]getImageDimensions(Bitstream bitstream) Retrieves image dimensions from the image server (IIIF Image API v.2.1.1).getSeeAlsoBitstreams(Item item) Return all the bitstreams in the item to be used as annotationsbooleanhasWidthMetadata(Bitstream bitstream) Test to see if the bitstream contains iiif image width metadata.booleanisIIIFBitstream(Context context, Bitstream b) Utility method to check is a bitstream can be used as IIIF resourcesbooleanisIIIFEnabled(Item item) booleanisSearchable(Item item) Checks to see if the item is searchable.
-
Field Details
-
OTHER_CONTENT_BUNDLE
- See Also:
-
METADATA_IIIF_ENABLED
- See Also:
-
METADATA_IIIF_SEARCH_ENABLED
- See Also:
-
METADATA_IIIF_LABEL
- See Also:
-
METADATA_IIIF_DESCRIPTION
- See Also:
-
METADATA_IIIF_TOC
- See Also:
-
METADATA_IIIF_CANVAS_NAMING
- See Also:
-
METADATA_IIIF_VIEWING_HINT
- See Also:
-
METADATA_IMAGE_WIDTH
- See Also:
-
METADATA_IMAGE_HEIGHT
- See Also:
-
TOC_SEPARATOR
- See Also:
-
TOC_SEPARATOR_REGEX
- See Also:
-
iiifModule
protected com.fasterxml.jackson.databind.module.SimpleModule iiifModule -
mapper
protected com.fasterxml.jackson.databind.ObjectMapper mapper -
bitstreamService
-
-
Constructor Details
-
IIIFUtils
public IIIFUtils()
-
-
Method Details
-
getIIIFBundles
-
isIIIFEnabled
-
getIIIFBitstreams
Return all the bitstreams in the item to be used as IIIF resources- Parameters:
context- the DSpace Contextitem- the DSpace item- Returns:
- a not null list of bitstreams to use as IIIF resources in the manifest
-
getIIIFBitstreams
Return all the bitstreams in the bundle to be used as IIIF resources- Parameters:
context- the DSpace Contextbundle- the DSpace Bundle- Returns:
- a not null list of bitstreams to use as IIIF resources in the manifest
-
isIIIFBitstream
Utility method to check is a bitstream can be used as IIIF resources- Parameters:
b- the DSpace bitstream to check- Returns:
- true if the bitstream can be used as IIIF resource
-
getBitstreamMimeType
Returns the bitstream mime type- Parameters:
bitstream- DSpace bitstreamcontext- DSpace context- Returns:
- mime type
-
isSearchable
Checks to see if the item is searchable. Based on theMETADATA_IIIF_SEARCH_ENABLEDmetadata.- Parameters:
item- DSpace item- Returns:
- true if the iiif search is enabled
-
getBitstreamForCanvas
Retrives a bitstream based on its position in the IIIF bundle.- Parameters:
context- DSpace Contextitem- DSpace ItemcanvasPosition- bitstream position- Returns:
- bitstream or null if the specified canvasPosition doesn't exist in the manifest
-
getCanvasId
Extracts canvas position from the URL input path.- Parameters:
canvasId- e.g. "c12"- Returns:
- the position, e.g. 12
-
getCanvasId
Returns the canvas path with position. The path returned is partial, not the fully qualified URI.- Parameters:
position- position of the bitstream in the DSpace bundle.- Returns:
- partial canvas path.
-
getSeeAlsoBitstreams
Return all the bitstreams in the item to be used as annotations- Parameters:
item- the DSpace item- Returns:
- a not null list of bitstreams to use as IIIF resources in the manifest
-
getIIIFLabel
Return the custom iiif label for the resource or the provided default if none- Parameters:
dso- the dspace object to use as iiif resourcedefaultLabel- the default label to return if none is specified in the metadata- Returns:
- the iiif label for the dspace object
-
getIIIFDescription
Return the custom iiif description for the resource or the provided default if none- Parameters:
dso- the dspace object to use as iiif resourcedefaultDescription- the default description to return if none is specified in the metadata- Returns:
- the iiif label for the dspace object
-
getIIIFToCs
Return the table of contents (toc) positions in the iiif structure where the resource appears. Please note that the same resource can belong to multiple ranges (i.e. a page that contains the last paragraph of a section and start the new section)- Parameters:
bitstream- the dspace bitstreamprefix- a string to add to all the returned toc inherited from the parent dspace object- Returns:
- the iiif tocs for the dspace object
-
getImageDimensions
@Cacheable(key="#bitstream.getID().toString()", cacheNames="canvasdimensions") public int[] getImageDimensions(Bitstream bitstream) Retrieves image dimensions from the image server (IIIF Image API v.2.1.1).- Parameters:
bitstream- the bitstream DSO- Returns:
- image dimensions
-
hasWidthMetadata
Test to see if the bitstream contains iiif image width metadata.- Parameters:
bitstream- the bitstream DSo- Returns:
- true if width metadata was found
-
getBundleIIIFToC
Return the iiif toc for the specified bundle- Parameters:
bundle- the dspace bundle- Returns:
- the iiif toc for the specified bundle
-
getIIIFViewingHint
Return the iiif viewing hint for the item- Parameters:
item- the dspace itemdefaultHint- the default hint to apply if nothing else is defined at the item leve- Returns:
- the iiif viewing hint for the item
-
getCanvasWidth
Return the width for the canvas associated with the bitstream. If the bitstream doesn't provide directly the information it is retrieved from the bundle, item or default.- Parameters:
bitstream- the dspace bitstream used in the canvasbundle- the bundle the bitstream belong toitem- the item the bitstream belong todefaultWidth- the default width to apply if no other preferences are found- Returns:
- the width in pixel for the canvas associated with the bitstream
-
getCanvasHeight
Return the height for the canvas associated with the bitstream. If the bitstream doesn't provide directly the information it is retrieved from the bundle, item or default.- Parameters:
bitstream- the dspace bitstream used in the canvasbundle- the bundle the bitstream belong toitem- the item the bitstream belong todefaultHeight- the default width to apply if no other preferences are found- Returns:
- the height in pixel for the canvas associated with the bitstream
-
getCanvasNaming
Return the prefix to use to generate canvas name for canvas that has no an explicit IIIF label- Parameters:
item- the DSpace ItemdefaultNaming- a default to return if the item has not a custom value- Returns:
- the prefix to use to generate canvas name for canvas that has no an explicit IIIF label
-