Class WatermarkHandler
java.lang.Object
io.goobi.viewer.controller.imaging.WatermarkHandler
- All Implemented Interfaces:
Serializable
Applies configured watermarks to images delivered through the image service.
- Author:
- Florian Alpers
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWatermarkHandler(Configuration configuration, String servletPath) Creates a new WatermarkHandler instance. -
Method Summary
Modifier and TypeMethodDescriptiongetFooterIdIfExists(StructElement topDocument) Returns the watermark id for the givenStructElement.Optionally returns the watermark text for the given page.Optionally returns the watermark text for the given pi.getWatermarkUrl(de.unigoettingen.sub.commons.contentlib.imagelib.transform.Scale scale, ViewAttributes viewAttributes, Optional<String> watermarkId, Optional<String> watermarkText) Creates the watermark url for the given pageType, adding watermarkId for the currentActiveDocumentBean.getTopDocument()and watermarkText for the currentPhysicalElementpage.getWatermarkUrl(Optional<PhysicalElement> page, Optional<StructElement> doc, Optional<PageType> pageType) Creates the watermark url for the given pageType, adding watermarkId for the givenStructElementandPhysicalElementpage.
-
Field Details
-
WATERMARK_TEXT_TYPE_URN
ConstantWATERMARK_TEXT_TYPE_URN="URN".- See Also:
-
WATERMARK_TEXT_TYPE_PURL
ConstantWATERMARK_TEXT_TYPE_PURL="PURL".- See Also:
-
WATERMARK_TEXT_TYPE_SOLR
ConstantWATERMARK_TEXT_TYPE_SOLR="SOLR:".- See Also:
-
REQUIRED_SOLR_FIELDS
ConstantREQUIRED_SOLR_FIELDS.
-
-
Constructor Details
-
WatermarkHandler
Creates a new WatermarkHandler instance.- Parameters:
configuration- viewer configuration supplying watermark settingsservletPath- base servlet path used to build PURL watermark texts
-
-
Method Details
-
getWatermarkUrl
public Optional<String> getWatermarkUrl(Optional<PhysicalElement> page, Optional<StructElement> doc, Optional<PageType> pageType) throws ViewerConfigurationException, IndexUnreachableException, DAOException Creates the watermark url for the given pageType, adding watermarkId for the givenStructElementandPhysicalElementpage. 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 resolutiondoc- optional top-level struct element for watermark ID resolutionpageType- 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 currentActiveDocumentBean.getTopDocument()and watermarkText for the currentPhysicalElementpage. 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 URLviewAttributes- aViewAttributesobjectwatermarkId- optional footer image variant identifier to embed in the URLwatermarkText- 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
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
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
-