Class AnnotationResource
- 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.Only annotations the current session is permitted to view are counted towards the collection; annotations restricted by an access condition are excluded unless the requester holds the required view privilege. The collection references the endpoint used to retrieve the individual, paginated annotation pages.
- Returns:
- the global annotation collection
- Throws:
IndexUnreachableException- if the Solr index holding the annotations is unavailablePresentationException- if the annotation count cannot be computed
-
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.Pages hold up to 100 annotations each, sorted by database identifier; annotations restricted by an access condition are excluded from the page unless the current session holds the required view privilege. A page number beyond the last page is not rejected — it yields a page with an empty item list.
- Parameters:
page- 1-based page number within the annotation collection- Returns:
- the requested annotation page
- Throws:
de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException- if the page number is less than 1DAOException- if the annotations cannot be read from the database
-
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).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:
DAOException- if the annotation cannot be read from the databasede.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException- if no annotation exists for the given id
-
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- if the comment cannot be read from the databasede.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException- if no comment exists for the given id
-
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.Only annotations whose target resolves to a IIIF Presentation 2 manifest, a canvas, or a specific region of a canvas can be persisted; annotations on any other target type — including IIIF Presentation 3 resources — are not created. If the request is made by a logged-in user, that user is recorded as the annotation's creator.
- Parameters:
anno- incoming annotation to persist- Returns:
- the created annotation as a web annotation, or an empty response if its target type is not supported
- Throws:
DAOException- if the annotation cannot be written to the database
-
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.An annotation with no recorded creator is not deleted at all; it is returned unchanged, as if the deletion had succeeded.
- Parameters:
id- database identifier of the annotation to delete- Returns:
- the deleted annotation, or the unchanged annotation if it has no recorded creator
- Throws:
DAOException- if the annotation cannot be read from or removed from the databasede.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException- if no annotation exists for the given id, or the current session is not allowed to delete it
-
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 bearer token or session
-