Class BookmarkResource

java.lang.Object
io.goobi.viewer.api.rest.v1.bookmarks.BookmarkResource

@Path("/bookmarks") public class BookmarkResource extends Object
REST resource for managing user bookmark lists including creation, sharing, and export in multiple formats.
Author:
Florian Alpers
  • Constructor Details

  • Method Details

    • getOwnedBookmarkLists

      @GET @Produces("application/json") public List<BookmarkList> getOwnedBookmarkLists() throws DAOException, IOException, RestApiException
      Returns the bookmark lists of the current user, or the single session list of an anonymous request.

      Which lists exist depends on the request: for a logged-in user all persisted lists are returned, for an anonymous request a single list is created in the HTTP session on first access. That session list has neither an id nor a share key, so it cannot be addressed or shared like a stored list; if it is not empty when the same session logs in, it is taken over into that account as a regular bookmark list.

      Returns:
      the bookmark lists visible to the current request
      Throws:
      DAOException - if the lists of a logged-in user cannot be read from the database
      IOException
      RestApiException
    • addBookmarkList

      @POST @Consumes("application/json") @Produces("application/json") public Response addBookmarkList(BookmarkListCreateDto dto) throws DAOException, IOException, RestApiException, de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
      Creates a new bookmark list for the current user.

      Anonymous session requests always fail with 409, since a session can hold only a single bookmark list. Logged-in users get a new persisted list; if no name is given in the request body, one is generated automatically, and a name already used by one of the user's lists is rejected with 400.

      Parameters:
      dto - the bookmark list to create; only the optional name field is used
      Returns:
      the created bookmark list, with a Location header pointing to it if it has an id
      Throws:
      BadRequestException - if the request body is null
      RestApiException - if the requested name is already used by one of the user's bookmark lists
      DAOException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
    • getBookmarkList

      @GET @Path("/{listId}") @Produces("application/json") public BookmarkList getBookmarkList(@PathParam("listId") Long id) throws DAOException, IOException, RestApiException
      Returns the bookmark list with the given id.

      For a logged-in user, the list is returned if it is public or owned by the requesting user; a private list owned by someone else results in 403, a non-existent id in 404. For an anonymous request the id is ignored and the session's single bookmark list is returned, creating it if needed.

      Parameters:
      id - the id of the bookmark list
      Returns:
      the bookmark list with the given id
      Throws:
      RestApiException - if the bookmark list does not exist, or exists but is neither public nor owned by the current user
      DAOException
      IOException
    • patchBookmarkList

      @PATCH @Path("/{listId}") @Consumes("application/json") @Produces("application/json") public BookmarkList patchBookmarkList(@PathParam("listId") Long id, BookmarkListPatchDto patch) throws DAOException, IOException, RestApiException, de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
      Applies a partial update to the bookmark list with the given id.

      Only a non-blank name or description and a present isPublic are applied; the share key and ownership cannot be patched here. A blank name or description in the request body is silently ignored rather than clearing the field. Anonymous session requests always fail with 409, since the session bookmark list cannot be updated.

      Parameters:
      id - the id of the bookmark list
      patch - the attributes to change; a blank name/description or an absent isPublic is left unchanged
      Returns:
      the updated bookmark list
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException - if the request body is missing, or a logged-in user does not own the list
      DAOException
      IOException
      RestApiException
    • deleteBookmarkList

      @DELETE @Path("/{listId}") @Produces("application/json") public SuccessMessage deleteBookmarkList(@PathParam("listId") Long id) throws DAOException, IOException, RestApiException, de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
      Deletes the bookmark list with the given id.

      For a logged-in user this removes their persisted list with the given id, or fails with 404 if no such list is owned by the user. For an anonymous request the id is ignored and the session's bookmark list is always cleared and immediately replaced with a new empty one.

      Parameters:
      id - the id of the bookmark list
      Returns:
      a success message confirming the deletion
      Throws:
      RestApiException - if a logged-in user owns no bookmark list with the given id
      DAOException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
    • addItemToBookmarkList

      @POST @Path("/{listId}") @Consumes("application/json") @Produces("application/json") public Response addItemToBookmarkList(@PathParam("listId") Long id, Bookmark item) throws DAOException, IOException, RestApiException, de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
      Adds a bookmark for the given record to the bookmark list with the given id.

      A logId of "-" is treated as "no structural element". Adding an item already present in the list fails with 409. Whether an unresolvable pi results in 404 or 400 depends on the builder: a logged-in user's list reports 404, the anonymous session list reports 400.

      Parameters:
      id - the id of the bookmark list
      item - the bookmark to add; only pi, logId and order are used
      Returns:
      the created bookmark, with a Location header pointing to it if it has an id
      Throws:
      BadRequestException - if the request body is null
      RestApiException - if the item already exists in the list, or the record cannot be resolved
      DAOException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
    • getBookmarkItem

      @GET @Path("/{listId}/items/{bookmarkId}") @Produces("application/json") public Bookmark getBookmarkItem(@PathParam("listId") Long listId, @PathParam("bookmarkId") Long bookmarkId) throws RestApiException, DAOException, IOException
      Returns the bookmark with the given id from the bookmark list with the given id.

      Access to the containing list follows the same rules as the plain bookmark-list lookup. The bookmark is then looked up among the list's items by id; if none matches, the request fails with 404.

      Parameters:
      listId - the id of the bookmark list
      bookmarkId - the id of the bookmark
      Returns:
      the bookmark with the given id
      Throws:
      RestApiException - if no bookmark with the given id exists in the list
      DAOException
      IOException
    • deleteBookmarkItem

      @DELETE @Path("/{listId}/items/{bookmarkId}") @Produces("application/json") public SuccessMessage deleteBookmarkItem(@PathParam("listId") Long listId, @PathParam("bookmarkId") Long bookmarkId) throws RestApiException, DAOException, IOException
      Deletes the bookmark with the given id from the bookmark list with the given id.

      Access to the containing list follows the same rules as the plain bookmark-list lookup. The bookmark is first located within the list by id (404 if absent), then removed by matching its record, structural element and page rather than by its own id.

      Parameters:
      listId - the id of the bookmark list
      bookmarkId - the id of the bookmark
      Returns:
      a success message confirming the removal
      Throws:
      RestApiException - if no bookmark with the given id exists in the list
      DAOException
      IOException
    • getBookmarkListAsIIIFCollection

      @GET @Path("/{listId}/collection.json") @Produces("application/json") public de.intranda.api.iiif.presentation.v2.Collection2 getBookmarkListAsIIIFCollection(@PathParam("listId") Long id) throws DAOException, IOException, RestApiException
      Returns the bookmark list with the given id as a IIIF Presentation 2.1.1 collection.

      For a logged-in user, only lists owned by that user are considered here; unlike the plain bookmark-list endpoint, a public list owned by someone else is not accessible through this operation and results in 404. For an anonymous request the id is ignored and the session's bookmark list is returned as a collection.

      Parameters:
      id - the id of the bookmark list
      Returns:
      the bookmark list as a IIIF Presentation 2.1.1 collection
      Throws:
      RestApiException - if no bookmark list with the given id is owned by the current user
      DAOException
      IOException
    • getBookmarkListForMirador

      @GET @Path("/{listId}/mirador.json") @Produces("application/json") public String getBookmarkListForMirador(@PathParam("listId") Long id) throws DAOException, IOException, RestApiException, ViewerConfigurationException, IndexUnreachableException, PresentationException
      Returns the bookmark list with the given id as a Mirador viewer configuration.

      For a logged-in user, only lists owned by that user are considered here; unlike the plain bookmark-list endpoint, a public list owned by someone else is not accessible through this operation and results in 404. For an anonymous request the id is ignored and the session's bookmark list is returned.

      Parameters:
      id - the id of the bookmark list
      Returns:
      the Mirador-compatible JSON configuration for the bookmark list
      Throws:
      RestApiException - if no bookmark list with the given id is owned by the current user
      DAOException
      IOException
      ViewerConfigurationException
      IndexUnreachableException
      PresentationException
    • getBookmarkListAsRSS

      @GET @Path("/{listId}/rss.xml") @Produces("text/xml") public String getBookmarkListAsRSS(@PathParam("listId") Long id, @QueryParam("lang") String language, @QueryParam("max") String maxStr) throws DAOException, IOException, RestApiException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the bookmark list with the given id as an RSS feed in XML format.

      Access to the list follows the same rules as the plain bookmark-list lookup, so a public list owned by another user is accessible here. The feed is generated from a Solr query matching the list's items, so entries reflect the current index state of those records rather than a snapshot of the list.

      Parameters:
      id - the id of the bookmark list
      language - language for RSS metadata
      maxStr - limit for results to return
      Returns:
      the RSS feed for the bookmark list as XML
      Throws:
      RestApiException - if the bookmark list does not exist, or exists but is neither public nor owned by the current user
      DAOException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
    • getBookmarkListAsRSSJson

      @GET @Path("/{listId}/rss.json") @Produces("application/json") public Channel getBookmarkListAsRSSJson(@PathParam("listId") Long id, @QueryParam("lang") String language, @QueryParam("max") String maxStr) throws DAOException, IOException, RestApiException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the bookmark list with the given id as an RSS feed in JSON format.

      Access to the list follows the same rules as the plain bookmark-list lookup, so a public list owned by another user is accessible here. The feed is generated from a Solr query matching the list's items, so entries reflect the current index state of those records rather than a snapshot of the list.

      Parameters:
      id - the id of the bookmark list
      language - language for RSS metadata
      maxStr - limit for results to return
      Returns:
      the RSS channel for the bookmark list
      Throws:
      RestApiException - if the bookmark list does not exist, or exists but is neither public nor owned by the current user
      DAOException
      IOException
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
    • getPublicBookmarkLists

      @GET @Path("/public") @Produces("application/json") public List<BookmarkList> getPublicBookmarkLists() throws DAOException, IOException, RestApiException
      Returns all bookmark lists marked as public, regardless of the requesting user.

      The result is returned in the order the database provides it in and is not sorted by update date, unlike getOwnedBookmarkLists() which sorts the current user's lists by most recent update descending.

      Returns:
      all publicly visible bookmark lists stored in the database
      Throws:
      DAOException - if the lists cannot be read from the database
      IOException
      RestApiException
    • getSharedBookmarkListByKey

      @GET @Path("/shared/{key}") @Produces("application/json") public BookmarkList getSharedBookmarkListByKey(@PathParam("key") String key) throws DAOException, RestApiException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the bookmark list identified by the given share key, independent of the current user or session.

      The list is looked up solely by its share key, independent of the current user or session; a key matching no list at all results in 404.

      Parameters:
      key - the share key assigned to the bookmark list
      Returns:
      the bookmark list matching the share key
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException - if no bookmark list with the given key exists
      DAOException
      RestApiException
    • getSharedBookmarkListForMirador

      @GET @Path("/shared/{key}/mirador.json") @Produces("application/json") public String getSharedBookmarkListForMirador(@PathParam("key") String key) throws DAOException, ViewerConfigurationException, IndexUnreachableException, PresentationException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the bookmark list identified by the given share key as a Mirador viewer configuration.

      The list is looked up solely by its share key, independent of the current user or session; a key matching no list at all results in 404.

      Parameters:
      key - the share key assigned to the bookmark list
      Returns:
      the Mirador-compatible JSON configuration for the shared bookmark list
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException - if no accessible bookmark list matches the given key
      DAOException
      ViewerConfigurationException
      IndexUnreachableException
      PresentationException
    • getSharedBookmarkListAsCollection

      @GET @Path("/shared/{key}/collection.json") @Produces("application/json") public de.intranda.api.iiif.presentation.v2.Collection2 getSharedBookmarkListAsCollection(@PathParam("key") String key) throws DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the bookmark list identified by the given share key as a IIIF Presentation 2.1.1 collection.

      The list is looked up solely by its share key, independent of the current user or session; a key matching no list at all results in 404.

      Parameters:
      key - the share key assigned to the bookmark list
      Returns:
      the bookmark list as a IIIF Presentation 2.1.1 collection
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException - if no accessible bookmark list matches the given key
      DAOException
    • getSharedBookmarkListAsRSSJson

      @GET @Path("/shared/{key}/rss.json") @Produces("application/json") public Channel getSharedBookmarkListAsRSSJson(@PathParam("key") String key, @QueryParam("lang") String language, @QueryParam("max") String maxStr) throws DAOException, RestApiException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the bookmark list identified by the given share key as an RSS feed in JSON format.

      The list is looked up solely by its share key, independent of the current user or session; a key matching no list at all results in 404. The feed itself is generated from a Solr query matching the list's items, so entries reflect the current index state of those records rather than a snapshot of the list.

      Parameters:
      key - the share key assigned to the bookmark list
      language - language for RSS metadata
      maxStr - limit for results to return
      Returns:
      the RSS channel for the shared bookmark list
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException - if no bookmark list with the given key exists
      DAOException
      RestApiException
    • getSharedBookmarkListAsRSS

      @GET @Path("/shared/{key}/rss.xml") @Produces("text/xml") public String getSharedBookmarkListAsRSS(@PathParam("key") String key, @QueryParam("lang") String language, @QueryParam("max") String maxStr) throws DAOException, RestApiException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
      Returns the bookmark list identified by the given share key as an RSS feed in XML format.

      The list is looked up solely by its share key, independent of the current user or session; a key matching no list at all results in 404. The feed itself is generated from a Solr query matching the list's items, so entries reflect the current index state of those records rather than a snapshot of the list.

      Parameters:
      key - the share key assigned to the bookmark list
      language - language for RSS metadata
      maxStr - limit for results to return
      Returns:
      the RSS feed for the shared bookmark list as XML
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException - if no bookmark list with the given key exists
      DAOException
      RestApiException