Class RecordResource

java.lang.Object
io.goobi.viewer.api.rest.v1.records.RecordResource

@Path("/records/{pi}") public class RecordResource extends Object
REST resource providing record metadata, IIIF manifests, full-text, and various export formats for digitized records.
Author:
Florian Alpers
  • Constructor Details

  • Method Details

    • getRISAsFile

      @GET @Path("/ris") @Produces("text/plain") public String getRISAsFile() throws PresentationException, IndexUnreachableException, DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the RIS citation for the record as a downloadable file attachment.

      The response carries a Content-Disposition header naming the file <pi>_<logid>.ris; the citation text itself is identical to that returned by getRISAsText(). Records whose access conditions deny the list privilege are reported as not found rather than forbidden.

      Returns:
      the RIS citation for the record as plain text
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - if no record exists for the given identifier, or the caller lacks the list privilege for it
      PresentationException
      IndexUnreachableException
      DAOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
    • getRISAsText

      @GET @Path("/ris.txt") @Produces("text/plain") public String getRISAsText() throws PresentationException, IndexUnreachableException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException, DAOException
      Returns the RIS citation for the record as plain text, without triggering a browser download.

      The citation content is produced by the same builder as getRISAsFile(); this endpoint merely omits the Content-Disposition attachment header set by the file variant. Records whose access conditions deny the list privilege are reported as not found rather than forbidden.

      Returns:
      the RIS citation for the record as plain text
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - if no record exists for the given identifier, or the caller lacks the list privilege for it
      DAOException - if any.
    • getTOCAsText

      @GET @Path("/toc") @Produces("text/plain") public String getTOCAsText() throws PresentationException, IndexUnreachableException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException, DAOException, ViewerConfigurationException
      Returns the table of contents of the record as an indented plain-text tree.

      Generating the table of contents requires the metadata-download privilege for the record; each hierarchy level in the returned text is indented by five characters.

      Returns:
      the table of contents as indented plain text
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - if the record does not exist or access to it is denied
      PresentationException
      IndexUnreachableException
      DAOException
      ViewerConfigurationException
    • getAnnotationsForRecord

      @GET @Path("/annotations") @Produces("application/json") public de.intranda.api.annotation.IAnnotationCollection getAnnotationsForRecord(@QueryParam("format") String format) throws DAOException
      Returns all crowdsourcing annotations attached to any page of the record, combined into a single collection.

      Annotations are collected across every page of the record and returned as one flat, unpaginated list. The format parameter selects the serialization: Open Annotation when it is oa, W3C Web Annotation otherwise.

      Parameters:
      format - annotation format of the response. If it is 'oa' the comments will be delivered as OpenAnnotations, otherwise as W3C-Webannotations
      Returns:
      the annotation collection or list for the record, in the requested format
      Throws:
      DAOException - if any.
    • getCommentsForRecord

      @GET @Path("/comments") @Produces("application/json") public de.intranda.api.annotation.IAnnotationCollection getCommentsForRecord(@QueryParam("format") String format) throws DAOException
      Returns the user comments for the record as an annotation collection or list.

      Comments are stored separately from crowdsourcing annotations. Both formats return every comment for the record: the default W3C Web Annotation format wraps them in an AnnotationCollection whose first (and only) AnnotationPage already contains all of them, while the Open Annotation format (format=oa) returns them directly as a flat AnnotationList with no paging envelope.

      Parameters:
      format - annotation format of the response. If it is 'oa' the comments will be delivered as OpenAnnotations, otherwise as W3C-Webannotations
      Returns:
      the comment collection or list for the record, in the requested format
      Throws:
      DAOException - if any.
    • getCommentPageForRecord

      @GET @Path("/comments/{page}") @Produces("application/json") public de.intranda.api.annotation.wa.collection.AnnotationPage getCommentPageForRecord(@PathParam("page") Integer page) throws DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException
      Returns one page of the paginated Web Annotation collection of comments for the record.

      Page numbers are 1-based. A record with no comments at all is reported as not found, since there is then no valid page to return.

      Parameters:
      page - Page number (1-based)
      Returns:
      the requested page of the comment collection
      Throws:
      DAOException - if any.
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException - if the page number is less than 1
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - if the record has no comments
    • getSource

      @GET @Path("/metadata/source") @Produces("text/xml") public StreamingOutput getSource() throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException, PresentationException, IndexUnreachableException
      Returns the record's metadata source file (e.g. METS or LIDO) as originally delivered to the indexer.

      The source format is taken from the record's indexed metadata and defaults to METS if none is set; the file is read from the record's data repository on disk rather than regenerated from the index.

      Returns:
      the source file content as XML
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - if no record is indexed for the given identifier, or if no source file exists on disk for the record
      PresentationException
      IndexUnreachableException
    • getManifest

      @GET @Path("/manifest") @Produces("application/json") public de.intranda.api.iiif.presentation.IPresentationModelElement getManifest(@QueryParam("mode") String mode) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException, PresentationException, IndexUnreachableException, URISyntaxException, ViewerConfigurationException, DAOException
      Returns the IIIF Presentation 2.1.1 manifest (or collection, for anchor records) for the record.

      When the full manifest is requested and the record is configured to delegate to an external IIIF service, the response is instead an HTTP redirect to that service's manifest URL rather than a locally generated manifest.

      Parameters:
      mode - Build mode for manifest to select type of resources to include. Default is 'iiif' which returns the full IIIF manifest with all resources. 'thumbs' Does not read width and height of canvas resources and 'iiif_simple' ignores all resources from files
      Returns:
      the generated manifest or collection, or null when a redirect to an external manifest was issued instead
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - if no document exists for the given identifier
      PresentationException
      IndexUnreachableException
      URISyntaxException
      ViewerConfigurationException
      DAOException
    • getLayer

      @GET @Path("/layers/{name}") @Produces("application/json") public de.intranda.api.iiif.presentation.IPresentationModelElement getLayer(@PathParam("name") String layerName, @QueryParam("mode") String mode) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException, PresentationException, IndexUnreachableException, URISyntaxException, ViewerConfigurationException, DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException, IOException
      Returns a single IIIF annotation layer of the record for the given annotation type.

      For the layer names tei and cmdi, the layer is built directly from the record's TEI or CMDI files; every other name is resolved against the page sequence's annotation lists (e.g. fulltext, ALTO), built the same way as when generating the full manifest. An unrecognized layer name is not validated up front and results in an unmapped server error rather than a client error response.

      Parameters:
      layerName - Name of the manifest layer
      mode - Build mode for manifest to select type of resources to include. Default is 'iiif' which returns the full IIIF manifest with all resources. 'thumbs' Does not read width and height of canvas resources and 'iiif_simple' ignores all resources from files
      Returns:
      the IIIF layer for the given record and layer name
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - if no document exists for the given identifier
      PresentationException
      IndexUnreachableException
      URISyntaxException
      ViewerConfigurationException
      DAOException
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
      IOException
    • getNERTags

      @GET @Path("/ner/tags") @Produces("application/json") public DocumentReference getNERTags(@QueryParam("start") Integer start, @QueryParam("end") Integer end, @QueryParam("step") Integer stepSize, @QueryParam("type") String type) throws PresentationException, IndexUnreachableException
      Returns named-entity tags extracted from the record's ALTO files, grouped into page ranges.

      Tags are extracted per page from ALTO and grouped into consecutive ranges of stepSize pages each; pages the requester has no fulltext access to are silently skipped rather than causing an error, but still count towards the page ranges.

      Parameters:
      start - First page to get tags for
      end - Last page to get tags for
      stepSize - Number of pages to combine into each group
      type - Tag type to consider (person, corporation, event or location)
      Returns:
      the NER tags for the record, grouped by page range
      Throws:
      PresentationException
      IndexUnreachableException
    • getPlaintext

      @GET @Path("/plaintext") @Produces("text/plain") public String getPlaintext() throws PresentationException, IndexUnreachableException, IOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the plain-text transcription of every page of the record within a single text file.

      Text is assembled from plaintext files where available, falling back to text extracted from ALTO for pages without one. The aggregate size is capped by a configured maximum; a request whose combined text would exceed it is rejected in favor of getPlaintextAsZip().

      Returns:
      the concatenated plaintext of the record
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException - if the aggregate plaintext size exceeds the configured limit
      PresentationException
      IndexUnreachableException
      IOException
    • getPlaintextAsZip

      @GET @Path("/plaintext.zip") @Produces("application/zip") public StreamingOutput getPlaintextAsZip() throws PresentationException, IndexUnreachableException, IOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the plain-text transcription of the record as a ZIP archive containing one text file per page.

      Unlike getPlaintext(), there is no aggregate size limit here since each page is written to its own file inside the archive.

      Returns:
      a streaming ZIP archive of one text file per page
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ServiceNotAllowedException - if access to the record's fulltext is denied
      PresentationException
      IndexUnreachableException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
    • getAlto

      @GET @Path("/alto") @Produces("text/xml") public String getAlto() throws PresentationException, IndexUnreachableException, IOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the concatenated ALTO XML of every page of the record as a single document.

      The result is not well-formed XML because it repeats the XML declaration and root element once per page; use getAltoAsZip() for parsable per-page files. The aggregate size is capped by a configured maximum, beyond which the request is rejected in favor of that endpoint.

      Returns:
      the concatenated ALTO document
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ServiceNotAllowedException - if access to the record's fulltext is denied
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException - if the aggregate ALTO size exceeds the configured limit
      PresentationException
      IndexUnreachableException
      IOException
    • getAltoAsZip

      @GET @Path("/alto.zip") @Produces("application/zip") public StreamingOutput getAltoAsZip() throws PresentationException, IndexUnreachableException, IOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the ALTO XML of the record as a ZIP archive containing one well-formed file per page.

      Unlike getAlto(), there is no aggregate size limit here since each page is written to its own file in the archive.

      Returns:
      a streaming ZIP archive of one ALTO file per page
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ServiceNotAllowedException - if access to the record's fulltext is denied
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - if no ALTO files exist for the record
      PresentationException
      IndexUnreachableException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
    • getCmdiLanguage

      @GET @Path("/cmdi/{lang}") @Produces("text/xml") public String getCmdiLanguage(@PathParam("lang") String language) throws PresentationException, IndexUnreachableException, IOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Throws:
      PresentationException
      IndexUnreachableException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
    • getTeiLanguage

      @GET @Path("/tei/{lang}") @Produces("text/xml") public String getTeiLanguage(@PathParam("lang") String language) throws PresentationException, IndexUnreachableException, IOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Throws:
      PresentationException
      IndexUnreachableException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
    • getTei

      @GET @Path("/tei") @Produces("text/xml") public String getTei() throws PresentationException, IndexUnreachableException, IOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Throws:
      PresentationException
      IndexUnreachableException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
    • getTeiAsZip

      @GET @Path("/tei.zip") @Produces("application/zip") public StreamingOutput getTeiAsZip(@QueryParam("lang") String language) throws PresentationException, IndexUnreachableException, IOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Throws:
      PresentationException
      IndexUnreachableException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
    • searchInManifest

      @GET @Path("/manifest/search") @Produces("application/json") public de.intranda.api.iiif.search.SearchResult searchInManifest(@QueryParam("q") String query, @QueryParam("motivation") String motivation, @QueryParam("date") String date, @QueryParam("user") String user, @QueryParam("page") Integer page) throws IndexUnreachableException, PresentationException
      Serves the IIIF Search API of the record's manifest.

      Depending on the given motivation parameter, fulltext (motivation=painting) and/or crowdsourcing annotations, indexed metadata and user comments together (motivation=non-painting or motivation=describing) may be searched; omitting the parameter searches everything. Fulltext is only searched if the fulltext view permission is granted for the record.

      Parameters:
      query - The search query; a list of space separated terms. The search is for all complete words which match any of the query terms. Terms may contain the wildcard character '*' to represent an arbitrary number of characters within the word
      motivation - a space separated list of motivations of annotations to search for. Search for the following motivations is implemented:
      • painting: fulltext resources, searched only if the fulltext view permission is granted
      • non-painting or describing: crowdsourcing annotations, indexed metadata and user comments
      date - not supported. If this parameter is given, its name is listed in the 'ignored' property of the 'within' property of the answer
      user - not supported. If this parameter is given, its name is listed in the 'ignored' property of the 'within' property of the answer
      page - the page number for paged result sets. if this is empty, page=1 is assumed
      Returns:
      a SearchResult containing all annotations matching the query in the 'resources' property
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
    • autoCompleteInManifest

      @GET @Path("/manifest/autocomplete") @Produces("application/json") public de.intranda.api.iiif.search.AutoSuggestResult autoCompleteInManifest(@QueryParam("q") String query, @QueryParam("motivation") String motivation, @QueryParam("date") String date, @QueryParam("user") String user, @QueryParam("page") Integer page) throws IndexUnreachableException, PresentationException
      Returns auto-complete suggestions for search terms within a IIIF manifest.
      Parameters:
      query - partial query string for auto-completion
      motivation - space-separated list of annotation motivations to filter
      date - date filter (not supported; passed to 'ignored' property)
      user - user filter (not supported; passed to 'ignored' property)
      page - page number; not supported for auto-completion, the full term list is always returned
      Returns:
      the IIIF AutoSuggest result containing auto-completion candidates for the given query
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
    • getBuildeMode

      public static BuildMode getBuildeMode(String mode)
      Parameters:
      mode - build mode string (e.g. "simple", "thumbs", "iiif")
      Returns:
      BuildMode
    • deleteRecord

      @DELETE @Produces("application/json") @Consumes("application/json") public String deleteRecord(@QueryParam("trace") Boolean createTraceDocument)
      deleteRecord.
      Parameters:
      createTraceDocument - if true, a trace document is written after deletion
      Returns:
      Short summary of files deleted
    • getRecordMetadataAsJson

      @GET @Path("/json/{template}") @Produces("application/json") public Response getRecordMetadataAsJson(@PathParam("template") String template) throws IndexUnreachableException, PresentationException
      Returns selected metadata of the record as a JSON object, mapped according to a named configuration template.

      The template must match a <template> configured under webapi.json.template in the configuration, which defines the Solr-field-to-JSON-field mapping applied to this record; the template's own query restriction, if any, is not used here since only the record's own Solr document is queried. A syntactically valid template name for which no such configuration exists is reported as not found, the same as when the record itself does not exist.

      Parameters:
      template - JSON configuration template name
      Returns:
      Response
      Throws:
      IndexUnreachableException
      PresentationException