Page History
...
Responses to DSpace 7 REST API requests are HAL documents which, in accordance with the specification, contain the following two reserved properties:
_links:
contains link links to other resources_embedded:
contains embedded resources
There are multiple ways to add links and embeds within the DSpace 7 server webapp.
The purpose of this guide is to help developers decide which way method is appropriate for a given scenario. (TBD: provide links/examples of each).
Before following this guide as a developer, you should already have a Rest Model object in mind (usually a subclass of RestAddressableModel
, with a name ending with Rest, by convention). That object should already have a few properties, and you should have an idea of what link you want to create from it. You should also have a Resource
subclass in mind (usually a subclass of HalResource
).
Determining the recommended approach
...
When subresource embedding is optional or pageable, the recommended approach is to create a LinkRestRepository with a method to fulfill provide the requestdata.
Then you can refer to the repository and method to get the content (or first page of the content) via the @LinkRest annotation in the @LinkRest class annotation (inside a @LinksRest annotation)in your Rest Model class. This allow the resource to be exposed as a subresource and permit the optional embedding of it.
This makes it possible to avoid the work of a) querying the database unnecessarily in certain cases, via the entity class used by the Converter, and b) reading in all possible values of a potentially long list into memory.
...