java.lang.Object
io.goobi.viewer.model.iiif.presentation.v3.builder.AbstractBuilder
Direct Known Subclasses:
CanvasBuilder, CollectionBuilder, ManifestBuilder, RangeBuilder

public abstract class AbstractBuilder extends Object
Abstract base class for IIIF Presentation API v3 resource builders, providing shared URI construction and metadata helpers.
Author:
Florian Alpers
  • Field Details

  • Constructor Details

    • AbstractBuilder

      protected AbstractBuilder(AbstractApiUrlManager apiUrlManager, HttpServletRequest request)
      Creates a new AbstractBuilder instance.
      Parameters:
      apiUrlManager - URL manager providing API endpoint paths
      request - current HTTP servlet request
  • Method Details

    • getLabel

      protected de.intranda.metadata.multilanguage.IMetadataValue getLabel(String key)
      Parameters:
      key - message key used to look up translated label values
      Returns:
      IMetadataValue
    • absolutize

      public URI absolutize(URI uri)
      Parameters:
      uri - relative or absolute URI to resolve against the application base URL
      Returns:
      URI
    • absolutize

      public URI absolutize(String uri)
      Parameters:
      uri - string form of a relative or absolute URI to resolve
      Returns:
      URI
    • getLocale

      protected Locale getLocale(String language)
      getLocale.
      Parameters:
      language - BCP 47 language tag to convert
      Returns:
      the Locale for the given language tag, defaulting to English if not resolvable
    • getMetsResolverUrl

      public URI getMetsResolverUrl(StructElement ele)
      getMetsResolverUrl.
      Parameters:
      ele - struct element whose PI is used for the METS URL
      Returns:
      METS resolver link for the DFG Viewer
    • getLidoResolverUrl

      public URI getLidoResolverUrl(StructElement ele)
      getLidoResolverUrl.
      Parameters:
      ele - struct element whose PI is used for the LIDO URL
      Returns:
      LIDO resolver link for the DFG Viewer
    • getViewUrl

      public String getViewUrl(PhysicalElement ele, PageType pageType)
      getViewUrl.
      Parameters:
      ele - physical page element providing the PURL part
      pageType - viewer page type determining the URL prefix
      Returns:
      viewer url for the given page in the given PageType
    • getLabelIfExists

      public Optional<de.intranda.metadata.multilanguage.IMetadataValue> getLabelIfExists(org.apache.solr.common.SolrDocument solrDocument)
      Simple method to create a label for a SolrDocument from SolrConstants.LABEL, SolrConstants.TITLE or SolrConstants.DOCSTRCT.
      Parameters:
      solrDocument - Solr document to extract label, title, or docstrct from
      Returns:
      an Optional containing the label derived from LABEL, TITLE, or DOCSTRCT fields, or empty if none are present
    • addMetadata

      public void addMetadata(de.intranda.api.iiif.presentation.v3.AbstractPresentationModelElement3 manifest, StructElement ele)
      addMetadata.
      Parameters:
      manifest - presentation element to add the metadata entries to
      ele - struct element providing the Solr metadata fields
    • getSolrFieldValue

      protected Optional<String> getSolrFieldValue(StructElement ele, String fieldName)
      Parameters:
      ele - struct element to read the Solr field value from
      fieldName - name of the Solr field to retrieve
      Returns:
      Optional
    • getRightsStatement

      protected Optional<URI> getRightsStatement(StructElement ele)
      Parameters:
      ele - struct element providing the rights field value
      Returns:
      Optional
    • contained

      protected boolean contained(String field, List<String> displayFields)
      Return true if the field is contained in displayFields, accounting for wildcard characters.
      Parameters:
      field - Solr field name to test for inclusion
      displayFields - list of configured display field patterns to match against
      Returns:
      true if the given field name matches any entry in the display fields list, false otherwise
    • getAttributions

      protected List<de.intranda.metadata.multilanguage.IMetadataValue> getAttributions()
      Gets the attribution text configured in webapi.iiif.attribution and returns all translations if any are found, or the configured string itself otherwise.
      Returns:
      the configured attribution
    • getDescription

      protected Optional<de.intranda.metadata.multilanguage.IMetadataValue> getDescription(StructElement ele)
      getDescription.
      Parameters:
      ele - struct element to read description fields from
      Returns:
      an Optional containing the description metadata value, or empty if no configured field has a value
    • getLabel

      protected Optional<de.intranda.metadata.multilanguage.IMetadataValue> getLabel(StructElement ele)
      getLabel.
      Parameters:
      ele - struct element to read label fields from
      Returns:
      an Optional containing the label metadata value, or empty if no configured field has a value
    • getCollectionURI

      public URI getCollectionURI(String collectionField, String baseCollectionName)
      getCollectionURI.
      Parameters:
      collectionField - Solr field name used to group collection entries
      baseCollectionName - top-level collection name, or blank for root collection
      Returns:
      the URI identifying the IIIF collection resource
    • getRangeURI

      public URI getRangeURI(String pi, String logId)
      getRangeURI.
      Parameters:
      pi - persistent identifier of the record
      logId - logical structure element ID within the record
      Returns:
      the IIIF v3 range URI for the given record and logical structure element
    • getCanvasURI

      public URI getCanvasURI(String pi, int pageNo)
      getCanvasURI.
      Parameters:
      pi - persistent identifier of the record
      pageNo - 1-based physical page order number
      Returns:
      the IIIF v3 canvas URI for the given record and page number
    • getPageOrderFromCanvasURI

      public Integer getPageOrderFromCanvasURI(URI uri)
      Get the page order (1-based) from a canavs URI. That is the number in the last path parameter after '/canvas/' If the URI doesn't match a canvas URI, null is returned
      Parameters:
      uri - canvas URI to extract the page order from
      Returns:
      the 1-based page order number extracted from the canvas URI, or null if the URI does not match
    • getPIFromCanvasURI

      public String getPIFromCanvasURI(URI uri)
      Get the persistent identifier from a canvas URI. This is the URI path param between '/iiif/manifests/' and '/canvas/'
      Parameters:
      uri - canvas URI to extract the persistent identifier from
      Returns:
      The pi, or null if the URI doesn't match a iiif canvas URI
    • getAnnotationListURI

      public URI getAnnotationListURI(String pi, int pageNo, de.intranda.api.iiif.presentation.enums.AnnotationType type, boolean openAnnotation)
      getAnnotationListURI.
      Parameters:
      pi - persistent identifier of the record
      pageNo - 1-based physical page order number
      type - annotation type determining the URL path segment
      openAnnotation - true to request the Open Annotation format via query parameter
      Returns:
      the annotation list URI for the given record page and annotation type
    • getAnnotationListURI

      public URI getAnnotationListURI(String pi, de.intranda.api.iiif.presentation.enums.AnnotationType type)
      getAnnotationListURI.
      Parameters:
      pi - persistent identifier of the record
      type - annotation type appended as query parameter
      Returns:
      the annotation list URI for the given record and annotation type
    • getCommentAnnotationURI

      public URI getCommentAnnotationURI(long id)
      getCommentAnnotationURI.
      Parameters:
      id - database ID of the comment annotation
      Returns:
      the REST API URI for the comment annotation with the given ID
    • getImageAnnotationURI

      public URI getImageAnnotationURI(String pi, int order)
      getImageAnnotationURI.
      Parameters:
      pi - persistent identifier of the record
      order - 1-based physical page order number
      Returns:
      the image annotation URI for the given record page
    • getAnnotationURI

      public URI getAnnotationURI(String pi, int order, de.intranda.api.iiif.presentation.enums.AnnotationType type, int annoNum) throws URISyntaxException
      getAnnotationURI.
      Parameters:
      pi - persistent identifier of the record
      order - 1-based physical page order number
      type - annotation type used as URL path segment
      annoNum - 1-based index of the annotation within the page
      Returns:
      the URI for the specific annotation at the given position on the given page
      Throws:
      URISyntaxException - if any.
    • getAnnotationURI

      public URI getAnnotationURI(String id)
      getAnnotationURI.
      Parameters:
      id - annotation identifier used as URL path parameter
      Returns:
      the REST API URI for the annotation with the given identifier
    • getSearchServiceURI

      public URI getSearchServiceURI(String pi)
      Get URL to search service from ApiUrls.
      Parameters:
      pi - The persistent identifier of the work to search
      Returns:
      the service URI
    • getAutoCompleteServiceURI

      public URI getAutoCompleteServiceURI(String pi)
      Get URL to auto complete service from ApiUrls.
      Parameters:
      pi - The persistent identifier of the work to search for autocomplete
      Returns:
      the service URI
    • getSearchURI

      public URI getSearchURI(String pi, String query, List<String> motivation)
      getSearchURI.
      Parameters:
      pi - persistent identifier of the record to search
      query - search query string appended as q parameter
      motivation - list of motivation values to filter by
      Returns:
      the IIIF search URI for the given record, query, and motivation filters
    • getAutoSuggestURI

      public URI getAutoSuggestURI(String pi, String query, List<String> motivation)
      getAutoSuggestURI.
      Parameters:
      pi - persistent identifier of the record to autocomplete
      query - partial query string; skips query params if blank
      motivation - list of motivation values to filter by
      Returns:
      the IIIF auto-suggest URI for the given record, partial query, and motivation filters
    • createRecordLink

      protected de.intranda.api.iiif.presentation.v3.Manifest3 createRecordLink(StructElement rec)
      Parameters:
      rec - struct element representing the record to link to
      Returns:
      Manifest3
    • createAnchorLink

      protected de.intranda.api.iiif.presentation.v3.Collection3 createAnchorLink(StructElement rec)
      Parameters:
      rec - struct element representing the anchor record to link to
      Returns:
      Collection3
    • getRequiredStatement

      protected de.intranda.metadata.multilanguage.Metadata getRequiredStatement()
    • getProvider

      protected de.intranda.api.iiif.presentation.v3.IIIFAgent getProvider(ProviderConfiguration providerConfig)
      Parameters:
      providerConfig - configuration object describing the IIIF provider agent
      Returns:
      IIIFAgent
    • getThumbnail

      protected de.intranda.api.annotation.wa.ImageResource getThumbnail(String pi) throws IndexUnreachableException, PresentationException, ViewerConfigurationException
      Parameters:
      pi - persistent identifier of the record whose thumbnail to load
      Returns:
      ImageResource
      Throws:
      IndexUnreachableException
      PresentationException
      ViewerConfigurationException
    • getThumbnail

      protected de.intranda.api.annotation.wa.ImageResource getThumbnail(StructElement ele)
      Thumbnail (record).
      Parameters:
      ele - struct element used to resolve the thumbnail URL
      Returns:
      ImageResource
    • getThumbnail

      protected de.intranda.api.annotation.wa.ImageResource getThumbnail(StructElement ele, int pageNo)
      Thumbnail (page manifest).
      Parameters:
      ele - struct element of the parent record
      pageNo - physical page number whose thumbnail to retrieve
      Returns:
      ImageResource
    • getThumbnail

      protected de.intranda.api.annotation.wa.ImageResource getThumbnail(PhysicalElement page)
      Thumbnail (individual pages of a record manifest).
      Parameters:
      page - physical page element whose thumbnail URL to resolve
      Returns:
      ImageResource
    • createLabel

      protected de.intranda.metadata.multilanguage.IMetadataValue createLabel(String text)
      Parameters:
      text - plain string to wrap as a metadata value label
      Returns:
      a simple metadata value with the given text, or null if text is blank
    • getFilename

      protected String getFilename(String path)
      Parameters:
      path - file system path or filename string to extract the file name from
      Returns:
      File name
    • getManifestURI

      public URI getManifestURI(String pi)
      getManifestURI.
      Parameters:
      pi - persistent identifier of the record
      Returns:
      the IIIF v3 manifest URI for the given record, using an external URI if configured
    • getExternalManifestURI

      public Optional<URI> getExternalManifestURI(String pi)
    • escapeURI

      protected String escapeURI(String uri)
    • isAccessGranted

      protected boolean isAccessGranted(StructElement ele, String privilege) throws PresentationException
      Throws:
      PresentationException
    • isAccessGranted

      protected boolean isAccessGranted(String pi, String privilege) throws PresentationException
      Throws:
      PresentationException