Class WatermarkHandler

java.lang.Object
io.goobi.viewer.controller.imaging.WatermarkHandler
All Implemented Interfaces:
Serializable

public class WatermarkHandler extends Object implements Serializable
Applies configured watermarks to images delivered through the image service.
Author:
Florian Alpers
See Also:
  • Field Details

    • WATERMARK_TEXT_TYPE_URN

      public static final String WATERMARK_TEXT_TYPE_URN
      Constant WATERMARK_TEXT_TYPE_URN="URN".
      See Also:
    • WATERMARK_TEXT_TYPE_PURL

      public static final String WATERMARK_TEXT_TYPE_PURL
      Constant WATERMARK_TEXT_TYPE_PURL="PURL".
      See Also:
    • WATERMARK_TEXT_TYPE_SOLR

      public static final String WATERMARK_TEXT_TYPE_SOLR
      Constant WATERMARK_TEXT_TYPE_SOLR="SOLR:".
      See Also:
    • REQUIRED_SOLR_FIELDS

      public static final String[] REQUIRED_SOLR_FIELDS
      Constant REQUIRED_SOLR_FIELDS.
  • Constructor Details

    • WatermarkHandler

      public WatermarkHandler(Configuration configuration, String servletPath)
      Creates a new WatermarkHandler instance.
      Parameters:
      configuration - viewer configuration supplying watermark settings
      servletPath - base servlet path used to build PURL watermark texts
  • Method Details

    • getWatermarkUrl

      Creates the watermark url for the given pageType, adding watermarkId for the given StructElement and PhysicalElement page. If the watermark height of the given pageType and image is 0, an empty optional is returned
      Parameters:
      page - optional physical page element for watermark text resolution
      doc - optional top-level struct element for watermark ID resolution
      pageType - The pageType of the currentView. Taken into consideration for footer height, if not null
      Returns:
      an Optional containing the watermark URL, or empty if the footer height is zero
      Throws:
      ViewerConfigurationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
    • getWatermarkUrl

      public Optional<String> getWatermarkUrl(de.unigoettingen.sub.commons.contentlib.imagelib.transform.Scale scale, ViewAttributes viewAttributes, Optional<String> watermarkId, Optional<String> watermarkText) throws IndexUnreachableException, DAOException, ViewerConfigurationException
      Creates the watermark url for the given pageType, adding watermarkId for the current ActiveDocumentBean.getTopDocument() and watermarkText for the current PhysicalElement page. If the watermark height of the given pageType and image is 0, an empty optional is returned.
      Parameters:
      scale - image scale to use in the watermark URL
      viewAttributes - a ViewAttributes object
      watermarkId - optional footer image variant identifier to embed in the URL
      watermarkText - optional text string to overlay on the watermark image
      Returns:
      an Optional containing the constructed watermark URL, or empty if the footer height is zero
      Throws:
      IndexUnreachableException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getWatermarkTextIfExists

      public Optional<String> getWatermarkTextIfExists(PhysicalElement page)
      Optionally returns the watermark text for the given page. If the text is empty or none is configures, an empty optional is returned
      Parameters:
      page - physical page element used to resolve URN, PURL, or Solr-based watermark text
      Returns:
      an Optional containing the resolved watermark text, or empty if no text is configured or resolved
    • getWatermarkTextIfExists

      public Optional<String> getWatermarkTextIfExists(StructElement doc)
      Optionally returns the watermark text for the given pi. If the text is empty or none is configures, an empty optional is returned
      Parameters:
      doc - struct element used to resolve URN, PURL, or Solr-based watermark text
      Returns:
      an Optional containing the resolved watermark text for the struct element, or empty if none is found
    • getFooterIdIfExists

      public Optional<String> getFooterIdIfExists(StructElement topDocument)
      Returns the watermark id for the given StructElement.
      Parameters:
      topDocument - top-level struct element whose metadata fields supply the footer ID
      Returns:
      an Optional containing the resolved footer ID, or empty if none is found in the configured fields