I have an application where I am using Spring Data Rest to expose my entities in one service, and then use FeignClient from another service to access and update those resources.
In examples I've seen POSTing a @OneToMany sub-resource association in Spring Data REST, the way to establish these relationships is as follows:
- Create the entity
- Get the "self" href of the newly created entity
- Create a list of existing entities of the owning entity for that type and then add that newly created link to the list
- Do a "PUT" with the list of URIs to the association URI (with a Content-Type of "text/uri-list") to create the association.
I have done this using AngularJs and it works fine. However, I really do not want my javascript controller to have such an intimate knowledge of my domain objects, I would prefer to have Spring HATEOAS do that work for me.
So what I've done is to create a service in my client application that uses the Spring Cloud FeignClient access those endpoints and do the work that the Angular is presently doing.
The problem that I am running into is that when I get my reference to my associations (e.g. "http://myapp/myobjects/3/myassociation") and then do a "GET" to that URI, it returns "Resources<MyAssociation>" which has no way of getting at the list of URIs of the association objects. All I get for "Links" is the reference to the associations from the owning entity (e.g. "http://myapp/myobjects/3/myassociation").
Is there a way that I can find that list of associations without having to make several other GETs so that I can add the newly added one to it?
Thanks in advance,
CS