Class AnnotationResource
java.lang.Object
io.goobi.viewer.api.rest.v1.annotations.AnnotationResource
REST resource managing W3C Web Annotations for records and canvas elements, supporting creation, retrieval, and deletion.
- Author:
- Florian Alpers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAnnotation(de.intranda.api.annotation.IncomingAnnotation anno) Persists a new W3C Web Annotation targeting a manifest, canvas, or canvas region.createPersistentAnnotation(de.intranda.api.annotation.IAnnotation anno) Converts an incoming W3C Web Annotation to a persistableCrowdsourcingAnnotation.de.intranda.api.annotation.IAnnotationdeleteAnnotation(Long id) Deletes an annotation by its database identifier.de.intranda.api.annotation.IAnnotationgetAltoAnnotation(String pi, Integer pageNo, String elementId, String format) Resolves an ALTO text element annotation by its composite identifier (pi, pageNo, elementId).de.intranda.api.annotation.IAnnotationgetAnnotation(Long id) Returns a single W3C Web Annotation by its database identifier.de.intranda.api.annotation.wa.collection.AnnotationCollectionReturns the complete W3C Web Annotation collection covering all annotations stored in the database.de.intranda.api.annotation.wa.collection.AnnotationPageReturns a single page of the global W3C Web Annotation collection.de.intranda.api.annotation.IAnnotationgetComment(Long id) Returns a comment annotation by its database identifier.getUser()
-
Constructor Details
-
AnnotationResource
public AnnotationResource()
-
-
Method Details
-
getAnnotationCollection
@GET @Produces("application/json") public de.intranda.api.annotation.wa.collection.AnnotationCollection getAnnotationCollection() throws PresentationException, IndexUnreachableExceptionReturns the complete W3C Web Annotation collection covering all annotations stored in the database.- Returns:
- the global annotation collection
- Throws:
DAOExceptionIndexUnreachableExceptionPresentationException
-
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:
DAOExceptionde.unigoettingen.sub.commons.contentlib.exceptions.ContentLibExceptionIndexUnreachableExceptionPresentationException
-
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
AltoAnnotationBuilderfor ALTO TextLines, Words, and Blocks.- Parameters:
pi- persistent identifier of the recordpageNo- 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 foundPresentationException- if the ALTO document cannot be parsedIndexUnreachableException- 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:
DAOExceptionde.unigoettingen.sub.commons.contentlib.exceptions.ContentLibExceptionIndexUnreachableExceptionPresentationException
-
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:
DAOExceptionde.unigoettingen.sub.commons.contentlib.exceptions.ContentLibExceptionIndexUnreachableExceptionPresentationException
-
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:
DAOExceptionNotImplementedException
-
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:
DAOExceptionde.unigoettingen.sub.commons.contentlib.exceptions.ContentLibExceptionViewerConfigurationException
-
createPersistentAnnotation
public CrowdsourcingAnnotation createPersistentAnnotation(de.intranda.api.annotation.IAnnotation anno) Converts an incoming W3C Web Annotation to a persistableCrowdsourcingAnnotation.- Parameters:
anno- incoming annotation to convert- Returns:
- the converted annotation ready for persistence, or null if the target type is unsupported
-
getUser
- Returns:
- User from session
-