Class AnnotationResource

java.lang.Object
io.goobi.viewer.api.rest.v1.annotations.AnnotationResource

@Path("/annotations") public class AnnotationResource extends Object
REST resource managing W3C Web Annotations for records and canvas elements, supporting creation, retrieval, and deletion.
Author:
Florian Alpers
  • Constructor Details

    • AnnotationResource

      public AnnotationResource()
  • Method Details

    • getAnnotationCollection

      @GET @Produces("application/json") public de.intranda.api.annotation.wa.collection.AnnotationCollection getAnnotationCollection() throws PresentationException, IndexUnreachableException
      Returns the complete W3C Web Annotation collection covering all annotations stored in the database.
      Returns:
      the global annotation collection
      Throws:
      DAOException
      IndexUnreachableException
      PresentationException
    • getAnnotationCollectionPage

      @GET @Path("/{page}") @Produces("application/json") public de.intranda.api.annotation.wa.collection.AnnotationPage getAnnotationCollectionPage(@PathParam("page") Integer page) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException, DAOException
      Returns a single page of the global W3C Web Annotation collection.
      Parameters:
      page - 1-based page number within the annotation collection
      Returns:
      the requested annotation page
      Throws:
      DAOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      IndexUnreachableException
      PresentationException
    • getAltoAnnotation

      @GET @Path("/alto_{pi}_{pageNo:[0-9]+}_{elementId}") @Produces("application/json") public de.intranda.api.annotation.IAnnotation getAltoAnnotation(@PathParam("pi") String pi, @PathParam("pageNo") Integer pageNo, @PathParam("elementId") String elementId, @QueryParam("format") String format) throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException, PresentationException, IndexUnreachableException
      Resolves an ALTO text element annotation by its composite identifier (pi, pageNo, elementId).

      This endpoint handles URLs generated by AltoAnnotationBuilder for ALTO TextLines, Words, and Blocks.

      Parameters:
      pi - persistent identifier of the record
      pageNo - page order number (1-based)
      elementId - ID attribute of the ALTO element (e.g. "TextLine_26")
      format - annotation format: "oa" for OpenAnnotation, "wa" or omitted for WebAnnotation
      Returns:
      the annotation matching the ALTO element
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException - if the page, ALTO file, or element is not found
      PresentationException - if the ALTO document cannot be parsed
      IndexUnreachableException - if Solr is unavailable
    • getAnnotation

      @GET @Path("/annotation_{id}") @Produces("application/json") public de.intranda.api.annotation.IAnnotation getAnnotation(@PathParam("id") Long id) throws DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns a single W3C Web Annotation by its database identifier.
      Parameters:
      id - database identifier of the annotation
      Returns:
      the matching annotation, never null (throws 404 if not found)
      Throws:
      DAOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      IndexUnreachableException
      PresentationException
    • getComment

      @GET @Path("/comment_{id}") @Produces("application/json") public de.intranda.api.annotation.IAnnotation getComment(@PathParam("id") Long id) throws DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns a comment annotation by its database identifier.
      Parameters:
      id - database identifier of the comment annotation
      Returns:
      the matching comment annotation, never null (throws 404 if not found)
      Throws:
      DAOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      IndexUnreachableException
      PresentationException
    • addAnnotation

      @POST @Consumes("application/json") @Produces("application/json") public Response addAnnotation(de.intranda.api.annotation.IncomingAnnotation anno) throws DAOException
      Persists a new W3C Web Annotation targeting a manifest, canvas, or canvas region.
      Parameters:
      anno - incoming annotation to persist
      Returns:
      201 Created with the saved annotation, or 404 if the target is not found or the type is unsupported
      Throws:
      DAOException
      NotImplementedException
    • deleteAnnotation

      @DELETE @Path("/annotation_{id}") @Produces("application/json") public de.intranda.api.annotation.IAnnotation deleteAnnotation(@PathParam("id") Long id) throws DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Deletes an annotation by its database identifier. Only the annotation creator or a superuser may delete.
      Parameters:
      id - database identifier of the annotation to delete
      Returns:
      the deleted annotation
      Throws:
      DAOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      ViewerConfigurationException
    • createPersistentAnnotation

      public CrowdsourcingAnnotation createPersistentAnnotation(de.intranda.api.annotation.IAnnotation anno)
      Converts an incoming W3C Web Annotation to a persistable CrowdsourcingAnnotation.
      Parameters:
      anno - incoming annotation to convert
      Returns:
      the converted annotation ready for persistence, or null if the target type is unsupported
    • getUser

      public User getUser()
      Returns:
      User from session