spring-projects / spring-projects/spring-data-rest
Custom ResourceProcessor is not called for an empty Resources [DATAREST-462]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Bert Duerinck opened DATAREST-462 and commented
I want to add links to a Collection Resources object even when the collection Resource is empty.
The following class is created for doing this:
@Component
public class OrderResourcesProcessor implements ResourceProcessor<Resources<Resource<Order>>> {
@Autowired
private EntityLinks entityLinks;
@Override
public Resources<Resource<Order>> process(Resources<Resource<Order>> resources) {
resources.add(entityLinks.linkFor(Order.class).withRel("createOrder"));
resources.add(entityLinks.linkFor(Order.class).withSelfRel());
return resources;
}
}
This ResourceProcessor is called when my Order collection Resource is not empty, but it's not called when it's empty. I should also have the possibility to add links when the collection is empty. According to the HAL specification, at least the self rel should be available in a resource, even if the resource is empty
Affects: 2.2.1 (Evans SR1)
1 votes, 4 watchers
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.