Class ImageDeliveryBean

java.lang.Object
io.goobi.viewer.managedbeans.ImageDeliveryBean
All Implemented Interfaces:
Serializable

@Named("imageDelivery") @SessionScoped public class ImageDeliveryBean extends Object implements Serializable
Provides methods for creation all urls for media delivery (images and other) Examples:
  • imageDelivery.thumbs.thumbnailUrl(pyhsicalElement[, width, height])
  • imageDelivery.thumbs.thumbnailUrl(structElement[, width, height])
  • imageDelivery.thumbs.thumbnailUrl(solrDocument[, width, height])
  • imageDelivery.thumbs.thumbnailUrl(cmsMediaItem[, width, height])
  • imageDelivery.thumbs.squareThumbnailUrl(pyhsicalElement[, size])
  • imageDelivery.thumbs.squareThumbnailUrl(structElement[, size])
  • imageDelivery.thumbs.squareThumbnailUrl(solrDocument[, size])
  • imageDelivery.images.imageUrl(pyhsicalElement[, pageType])
  • imageDelivery.pdf.pdfUrl(structElement[, pyhsicalElement[, more physicalElements...]])
  • imageDelivery.media.mediaUrl(mimeType, pi, filename)
.
Author:
Florian Alpers
See Also:
  • Constructor Details

    • ImageDeliveryBean

      public ImageDeliveryBean()
  • Method Details

    • init

      public void init(Configuration config, AbstractApiUrlManager dataUrlManager, AbstractApiUrlManager contentUrlManager)
      Initialize for testing.
      Parameters:
      config - viewer configuration to read settings from
      dataUrlManager - URL manager for data (IIIF) API endpoints
      contentUrlManager - URL manager for content delivery endpoints
    • getRepresentativeThumbnail

      public String getRepresentativeThumbnail()
      Returns the default size thumbnail url of the current top level document (according to the ViewManager Returns an empty string if no current document exists.
      Returns:
      The representative thumbnail for the current top docStruct element
    • getRepresentativeThumbnail

      public String getRepresentativeThumbnail(int width, int height)
      Returns a thumbnail url of the current top level document (according to the ViewManager with the given width/height. Returns an empty string if no current document exists
      Parameters:
      width - desired thumbnail width in pixels
      height - desired thumbnail height in pixels
      Returns:
      The representative thumbnail for the current top docStruct element
    • getRepresentativeSquareThumbnail

      public String getRepresentativeSquareThumbnail()
      Returns the default size thumbnail url of the current top level document (according to the ViewManager for a square thumbnail image. Returns an empty string if no current document exists
      Returns:
      The representative thumbnail for the current top docStruct element
    • getRepresentativeSquareThumbnail

      public String getRepresentativeSquareThumbnail(int size)
      Returns a thumbnail url of the current top level document (according to the ViewManager for a square thumbnail image of the given size. Returns an empty string if no current document exists
      Parameters:
      size - desired square thumbnail side length in pixels
      Returns:
      The representative thumbnail for the current top docStruct element
    • getCurrentPageThumbnail

      public String getCurrentPageThumbnail()
      Returns the default size thumbnail url of the current page (according to the ViewManager. Returns an empty string if no current page exists
      Returns:
      The thumbnail of the current page
    • getCurrentPageThumbnail

      public String getCurrentPageThumbnail(int width, int height)
      Returns a thumbnail url of the current page (according to the ViewManager of the given width/height.

      Returns an empty string if no current page exists

      Parameters:
      width - desired thumbnail width in pixels
      height - desired thumbnail height in pixels
      Returns:
      The thumbnail of the current page
    • getCurrentPageSquareThumbnail

      public String getCurrentPageSquareThumbnail()
      Returns the default size thumbnail url of the current page (according to the ViewManager for a square thumbnail image. Returns an empty string if no current page exists
      Returns:
      The thumbnail of the current page
    • getCurrentPageSquareThumbnail

      public String getCurrentPageSquareThumbnail(int size)
      Returns a thumbnail url of the current page (according to the ViewManager for a square thumbnail image of the given size. Returns an empty string if no current page exists
      Parameters:
      size - desired square thumbnail side length in pixels
      Returns:
      The thumbnail of the current page
    • getCurrentImage

      public String getCurrentImage()
      Returns the url to the image of the current page: Either a IIIF manifest if available, or a full image url For image size and tiling ingormation PageType.viewImage is assumed.
      Returns:
      The url to the image of the current page: Either a IIIF manifest if available, or a full image url
    • getCurrentImage

      public String getCurrentImage(String pageType)
      Returns the url to the image of the current page: Either a IIIF image information if available, or a full image url The given pageType affects image size and tiling suggestions for IIIF image information. If the given pageType does not match any known pageType, an empty String is returned
      Parameters:
      pageType - name of the page type determining image size and tiling
      Returns:
      The url to the image of the current page for the current pageType: Either a IIIF manifest if available, or a full image url
    • getIiifManifest

      public String getIiifManifest()
      Return the URL to the IIIF manifest of the current work, if it exists. Otherwise return empty String
      Returns:
      the manifest url
    • getIiifPageManifest

      public String getIiifPageManifest()
      Return the URL to the IIIF manifest of the current page, if it exists. Otherwise return empty String
      Returns:
      the manifest url
    • getIiif

      Retrieves the #IIIFUrlHandler, creates it if it doesn't exist yet.
      Returns:
      the IIIF URL handler instance
      Throws:
      ViewerConfigurationException - if any.
    • getFooter

      public WatermarkHandler getFooter()
      Retrieves the #WatermarkHandler, creates it if it doesn't exist yet.
      Returns:
      the watermark handler instance
    • getImages

      public ImageHandler getImages()
      Retrieves the #ImageHandler, creates it if it doesn't exist yet.
      Returns:
      the image handler instance
    • getPdf

      public PdfHandler getPdf()
      Retrieves the #PdfHandler, creates it if it doesn't exist yet.
      Returns:
      the PDF handler instance
    • getThumbs

      public ThumbnailHandler getThumbs()
      Retrieves the #ThumbnailHandler, creates it if it doesn't exist yet.
      Returns:
      the thumbnail handler instance
    • getMedia

      public MediaHandler getMedia()
      Retrieves the #MediaHandler, creates it if it doesn't exist yet.
      Returns:
      the media handler instance
    • getObjects3D

      public Object3DHandler getObjects3D()
      getObjects3D.
      Returns:
      the handler for 3D object delivery
    • getPresentation

      public IIIFPresentationAPIHandler getPresentation()
      Retrieves the #IIIFPresentationAPIHandler, creates it if it doesn't exist yet.
      Returns:
      the IIIF presentation handler
    • isExternalUrl

      public boolean isExternalUrl(String urlString) throws ViewerConfigurationException
      Returns true if the given String denotes an absolute url that is not a file url, false otherwise.
      Parameters:
      urlString - the string to test
      Returns:
      whether the given string denotes to an external url resource
      Throws:
      ViewerConfigurationException - if any.
    • getStaticImagesPath

      public static String getStaticImagesPath(String servletPath, String theme)
      Retrieves the url path to the viewer image resource folder. Ith the theme is given, the image resource folder within the theme is returned
      Parameters:
      servletPath - base servlet path including host
      theme - The name of the theme housing the images. If this is null or empty, the images are taken from the viewer core
      Returns:
      The url to the images folder in resources (possibly in the given theme)
    • isCmsUrl

      public boolean isCmsUrl(String url) throws ViewerConfigurationException
      Tests whether the given url points to a cms media file - i.e. any file within the configured cms media path
      Parameters:
      url - The url to test
      Returns:
      true if the url points to a cms media file
      Throws:
      ViewerConfigurationException - if any.
    • isTempUrl

      public boolean isTempUrl(String url) throws ViewerConfigurationException
      Tests whether the given url points to a temporary media file - i.e. any file within the configured temp media path
      Parameters:
      url - The url to test
      Returns:
      true if the url points to a temp media file
      Throws:
      ViewerConfigurationException - if any.
    • isPublicUrl

      public boolean isPublicUrl(String url) throws ViewerConfigurationException
      Parameters:
      url - URL to test
      Returns:
      true if given url is cms or temp url; false otherwise
      Throws:
      ViewerConfigurationException
    • isStaticImageUrl

      public boolean isStaticImageUrl(String url) throws ViewerConfigurationException
      Tests whether the given url points to a static image resource within the current theme.
      Parameters:
      url - the url to test
      Returns:
      true if the url points to a static image resource within the current theme
      Throws:
      ViewerConfigurationException - if any.
    • getStaticImagesURI

      public String getStaticImagesURI() throws ViewerConfigurationException
      Returns the url path to the static images folder of the viewer theme (or the viewer itself if no theme is found.
      Returns:
      the URI path to the static images folder of the active theme
      Throws:
      ViewerConfigurationException - if any.
    • getIfExists

      public Optional<String> getIfExists(String url)
      getIfExists.
      Parameters:
      url - URL string to wrap as optional
      Returns:
      an optional containing the given String if it is non-empty, otherwise an empty optional
    • setThumbs

      public void setThumbs(ThumbnailHandler thumbs)
      Setter for the field thumbs.
      Parameters:
      thumbs - the ThumbnailHandler instance to inject for testing
    • setImages

      public void setImages(ImageHandler images)
      Setter for the field images.
      Parameters:
      images - the ImageHandler instance to inject for testing
    • setPdf

      public void setPdf(PdfHandler pdf)
      Setter for the field pdf.
      Parameters:
      pdf - the PdfHandler instance to inject for testing
    • getCurrentImageDownloadUrl

      public String getCurrentImageDownloadUrl(int width, int height, String format)
    • getCurrentImageDownloadUrl

      public String getCurrentImageDownloadUrl(DownloadOption option)