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 - a Configuration object.
      dataUrlManager -
      contentUrlManager -
    • 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 - a int.
      height - a int.
      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 - a int.
      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 - a int.
      height - a int.
      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 - a int.
      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 - a String object.
      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
      Throws:
      ViewerConfigurationException - if any.
    • getFooter

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

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

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

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

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

      public Object3DHandler getObjects3D()

      getObjects3D.

      Returns:
      a Object3DHandler object.
    • 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 - a String object.
      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 -
      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 staticImagesURI
      Throws:
      ViewerConfigurationException - if any.
    • getIfExists

      public Optional<String> getIfExists(String url)

      getIfExists.

      Parameters:
      url - a String object.
      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 thumbs to set
    • setImages

      public void setImages(ImageHandler images)

      Setter for the field images.

      Parameters:
      images - the images to set
    • setPdf

      public void setPdf(PdfHandler pdf)

      Setter for the field pdf.

      Parameters:
      pdf - the pdf to set
    • getCurrentImageDownloadUrl

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

      public String getCurrentImageDownloadUrl(DownloadOption option)