Class BookmarkResource
- Author:
- Florian Alpers
-
Constructor Summary
ConstructorsConstructorDescriptionBookmarkResource(HttpServletRequest servletRequest, HttpServletResponse servletResponse) -
Method Summary
Modifier and TypeMethodDescriptionCreates a new bookmark list for the current user.addItemToBookmarkList(Long id, Bookmark item) Adds a bookmark for the given record to the bookmark list with the given id.deleteBookmarkItem(Long listId, Long bookmarkId) Deletes the bookmark with the given id from the bookmark list with the given id.Deletes the bookmark list with the given id.getBookmarkItem(Long listId, Long bookmarkId) Returns the bookmark with the given id from the bookmark list with the given id.getBookmarkList(Long id) Returns the bookmark list with the given id.de.intranda.api.iiif.presentation.v2.Collection2Returns the bookmark list with the given id as a IIIF Presentation 2.1.1 collection.getBookmarkListAsRSS(Long id, String language, String maxStr) Returns the bookmark list with the given id as an RSS feed in XML format.getBookmarkListAsRSSJson(Long id, String language, String maxStr) Returns the bookmark list with the given id as an RSS feed in JSON format.Returns the bookmark list with the given id as a Mirador viewer configuration.Returns the bookmark lists of the current user, or the single session list of an anonymous request.Returns all bookmark lists marked as public, regardless of the requesting user.de.intranda.api.iiif.presentation.v2.Collection2Returns the bookmark list identified by the given share key as a IIIF Presentation 2.1.1 collection.getSharedBookmarkListAsRSS(String key, String language, String maxStr) Returns the bookmark list identified by the given share key as an RSS feed in XML format.getSharedBookmarkListAsRSSJson(String key, String language, String maxStr) Returns the bookmark list identified by the given share key as an RSS feed in JSON format.Returns the bookmark list identified by the given share key, independent of the current user or session.Returns the bookmark list identified by the given share key as a Mirador viewer configuration.patchBookmarkList(Long id, BookmarkListPatchDto patch) Applies a partial update to the bookmark list with the given id.
-
Constructor Details
-
BookmarkResource
public BookmarkResource(@Context HttpServletRequest servletRequest, @Context HttpServletResponse servletResponse)
-
-
Method Details
-
getOwnedBookmarkLists
@GET @Produces("application/json") public List<BookmarkList> getOwnedBookmarkLists() throws DAOException, IOException, RestApiExceptionReturns 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 databaseIOExceptionRestApiException
-
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 optionalnamefield is used- Returns:
- the created bookmark list, with a
Locationheader pointing to it if it has an id - Throws:
BadRequestException- if the request body is nullRestApiException- if the requested name is already used by one of the user's bookmark listsDAOExceptionIOExceptionde.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 userDAOExceptionIOException
-
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
nameordescriptionand a presentisPublicare applied; the share key and ownership cannot be patched here. A blanknameordescriptionin 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 listpatch- the attributes to change; a blankname/descriptionor an absentisPublicis 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 listDAOExceptionIOExceptionRestApiException
-
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 idDAOExceptionIOExceptionde.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
logIdof"-"is treated as "no structural element". Adding an item already present in the list fails with 409. Whether an unresolvablepiresults 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 listitem- the bookmark to add; onlypi,logIdandorderare used- Returns:
- the created bookmark, with a
Locationheader pointing to it if it has an id - Throws:
BadRequestException- if the request body is nullRestApiException- if the item already exists in the list, or the record cannot be resolvedDAOExceptionIOExceptionde.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 listbookmarkId- the id of the bookmark- Returns:
- the bookmark with the given id
- Throws:
RestApiException- if no bookmark with the given id exists in the listDAOExceptionIOException
-
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 listbookmarkId- the id of the bookmark- Returns:
- a success message confirming the removal
- Throws:
RestApiException- if no bookmark with the given id exists in the listDAOExceptionIOException
-
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 userDAOExceptionIOException
-
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 userDAOExceptionIOExceptionViewerConfigurationExceptionIndexUnreachableExceptionPresentationException
-
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 listlanguage- language for RSS metadatamaxStr- 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 userDAOExceptionIOExceptionde.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 listlanguage- language for RSS metadatamaxStr- 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 userDAOExceptionIOExceptionde.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException
-
getPublicBookmarkLists
@GET @Path("/public") @Produces("application/json") public List<BookmarkList> getPublicBookmarkLists() throws DAOException, IOException, RestApiExceptionReturns 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 databaseIOExceptionRestApiException
-