Class AbstractBuilder
java.lang.Object
io.goobi.viewer.model.iiif.presentation.v3.builder.AbstractBuilder
- Direct Known Subclasses:
CanvasBuilder,CollectionBuilder,ManifestBuilder,RangeBuilder
Abstract base class for IIIF Presentation API v3 resource builders, providing shared URI construction and metadata helpers.
- Author:
- Florian Alpers
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Configurationprotected final DataRetrieverprotected final HttpServletRequestprotected final intprotected final intprotected final AbstractApiUrlManagerprotected final AbstractBuilder -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractBuilder(AbstractApiUrlManager apiUrlManager, HttpServletRequest request) Creates a new AbstractBuilder instance. -
Method Summary
Modifier and TypeMethodDescriptionabsolutize(String uri) absolutize(URI uri) voidaddMetadata(de.intranda.api.iiif.presentation.v3.AbstractPresentationModelElement3 manifest, StructElement ele) addMetadata.protected booleanReturn true if the field is contained in displayFields, accounting for wildcard characters.protected de.intranda.api.iiif.presentation.v3.Collection3protected de.intranda.metadata.multilanguage.IMetadataValuecreateLabel(String text) protected de.intranda.api.iiif.presentation.v3.Manifest3protected StringgetAnnotationListURI(String pi, int pageNo, de.intranda.api.iiif.presentation.enums.AnnotationType type, boolean openAnnotation) getAnnotationListURI.getAnnotationListURI(String pi, de.intranda.api.iiif.presentation.enums.AnnotationType type) getAnnotationListURI.getAnnotationURI.getAnnotationURI(String pi, int order, de.intranda.api.iiif.presentation.enums.AnnotationType type, int annoNum) getAnnotationURI.protected List<de.intranda.metadata.multilanguage.IMetadataValue> Gets the attribution text configured in webapi.iiif.attribution and returns all translations if any are found, or the configured string itself otherwise.Get URL to auto complete service fromApiUrls.getAutoSuggestURI(String pi, String query, List<String> motivation) getAutoSuggestURI.getCanvasURI(String pi, int pageNo) getCanvasURI.getCollectionURI(String collectionField, String baseCollectionName) getCollectionURI.getCommentAnnotationURI(long id) getCommentAnnotationURI.protected Optional<de.intranda.metadata.multilanguage.IMetadataValue> getDescription.protected StringgetFilename(String path) getImageAnnotationURI(String pi, int order) getImageAnnotationURI.protected Optional<de.intranda.metadata.multilanguage.IMetadataValue> getLabel(StructElement ele) getLabel.protected de.intranda.metadata.multilanguage.IMetadataValueOptional<de.intranda.metadata.multilanguage.IMetadataValue> getLabelIfExists(org.apache.solr.common.SolrDocument solrDocument) Simple method to create a label for aSolrDocumentfromSolrConstants.LABEL,SolrConstants.TITLEorSolrConstants.DOCSTRCT.getLidoResolverUrl.protected LocalegetLocale.getManifestURI(String pi) getManifestURI.getMetsResolverUrl.Get the page order (1-based) from a canavs URI.getPIFromCanvasURI(URI uri) Get the persistent identifier from a canvas URI.protected de.intranda.api.iiif.presentation.v3.IIIFAgentgetProvider(ProviderConfiguration providerConfig) getRangeURI(String pi, String logId) getRangeURI.protected de.intranda.metadata.multilanguage.MetadataGet URL to search service fromApiUrls.getSearchURI(String pi, String query, List<String> motivation) getSearchURI.getSolrFieldValue(StructElement ele, String fieldName) protected de.intranda.api.annotation.wa.ImageResourcegetThumbnail(PhysicalElement page) Thumbnail (individual pages of a record manifest).protected de.intranda.api.annotation.wa.ImageResourceThumbnail (record).protected de.intranda.api.annotation.wa.ImageResourcegetThumbnail(StructElement ele, int pageNo) Thumbnail (page manifest).protected de.intranda.api.annotation.wa.ImageResourcegetThumbnail(String pi) getViewUrl(PhysicalElement ele, PageType pageType) getViewUrl.protected booleanisAccessGranted(StructElement ele, String privilege) protected booleanisAccessGranted(String pi, String privilege)
-
Field Details
-
urls
-
dataRetriever
-
v1Builder
-
thumbWidth
protected final int thumbWidth -
thumbHeight
protected final int thumbHeight -
config
-
request
-
-
Constructor Details
-
AbstractBuilder
Creates a new AbstractBuilder instance.- Parameters:
apiUrlManager- URL manager providing API endpoint pathsrequest- current HTTP servlet request
-
-
Method Details
-
getLabel
- Parameters:
key- message key used to look up translated label values- Returns:
IMetadataValue
-
absolutize
- Parameters:
uri- relative or absolute URI to resolve against the application base URL- Returns:
URI
-
absolutize
- Parameters:
uri- string form of a relative or absolute URI to resolve- Returns:
URI
-
getLocale
getLocale.- Parameters:
language- BCP 47 language tag to convert- Returns:
- the Locale for the given language tag, defaulting to English if not resolvable
-
getMetsResolverUrl
getMetsResolverUrl.- Parameters:
ele- struct element whose PI is used for the METS URL- Returns:
- METS resolver link for the DFG Viewer
-
getLidoResolverUrl
getLidoResolverUrl.- Parameters:
ele- struct element whose PI is used for the LIDO URL- Returns:
- LIDO resolver link for the DFG Viewer
-
getViewUrl
getViewUrl.- Parameters:
ele- physical page element providing the PURL partpageType- 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 aSolrDocumentfromSolrConstants.LABEL,SolrConstants.TITLEorSolrConstants.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 toele- struct element providing the Solr metadata fields
-
getSolrFieldValue
- Parameters:
ele- struct element to read the Solr field value fromfieldName- name of the Solr field to retrieve- Returns:
- Optional
-
getRightsStatement
- Parameters:
ele- struct element providing the rights field value- Returns:
- Optional
-
contained
Return true if the field is contained in displayFields, accounting for wildcard characters.- Parameters:
field- Solr field name to test for inclusiondisplayFields- 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
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
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
getCollectionURI.- Parameters:
collectionField- Solr field name used to group collection entriesbaseCollectionName- top-level collection name, or blank for root collection- Returns:
- the URI identifying the IIIF collection resource
-
getRangeURI
getRangeURI.- Parameters:
pi- persistent identifier of the recordlogId- logical structure element ID within the record- Returns:
- the IIIF v3 range URI for the given record and logical structure element
-
getCanvasURI
getCanvasURI.- Parameters:
pi- persistent identifier of the recordpageNo- 1-based physical page order number- Returns:
- the IIIF v3 canvas URI for the given record and page number
-
getPageOrderFromCanvasURI
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
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 recordpageNo- 1-based physical page order numbertype- annotation type determining the URL path segmentopenAnnotation- 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 recordtype- annotation type appended as query parameter- Returns:
- the annotation list URI for the given record and annotation type
-
getCommentAnnotationURI
getCommentAnnotationURI.- Parameters:
id- database ID of the comment annotation- Returns:
- the REST API URI for the comment annotation with the given ID
-
getImageAnnotationURI
getImageAnnotationURI.- Parameters:
pi- persistent identifier of the recordorder- 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 recordorder- 1-based physical page order numbertype- annotation type used as URL path segmentannoNum- 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
getAnnotationURI.- Parameters:
id- annotation identifier used as URL path parameter- Returns:
- the REST API URI for the annotation with the given identifier
-
getSearchServiceURI
Get URL to search service fromApiUrls.- Parameters:
pi- The persistent identifier of the work to search- Returns:
- the service URI
-
getAutoCompleteServiceURI
Get URL to auto complete service fromApiUrls.- Parameters:
pi- The persistent identifier of the work to search for autocomplete- Returns:
- the service URI
-
getSearchURI
getSearchURI.- Parameters:
pi- persistent identifier of the record to searchquery- search query string appended as q parametermotivation- list of motivation values to filter by- Returns:
- the IIIF search URI for the given record, query, and motivation filters
-
getAutoSuggestURI
getAutoSuggestURI.- Parameters:
pi- persistent identifier of the record to autocompletequery- partial query string; skips query params if blankmotivation- list of motivation values to filter by- Returns:
- the IIIF auto-suggest URI for the given record, partial query, and motivation filters
-
createRecordLink
- Parameters:
rec- struct element representing the record to link to- Returns:
Manifest3
-
createAnchorLink
- 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:
IndexUnreachableExceptionPresentationExceptionViewerConfigurationException
-
getThumbnail
Thumbnail (record).- Parameters:
ele- struct element used to resolve the thumbnail URL- Returns:
ImageResource
-
getThumbnail
Thumbnail (page manifest).- Parameters:
ele- struct element of the parent recordpageNo- physical page number whose thumbnail to retrieve- Returns:
ImageResource
-
getThumbnail
Thumbnail (individual pages of a record manifest).- Parameters:
page- physical page element whose thumbnail URL to resolve- Returns:
ImageResource
-
createLabel
- 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
- Parameters:
path- file system path or filename string to extract the file name from- Returns:
- File name
-
getManifestURI
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
-
escapeURI
-
isAccessGranted
- Throws:
PresentationException
-
isAccessGranted
- Throws:
PresentationException
-