spring-hateoas

Deserialize JSON containing (_links and _embedded) using spring-hateoas

最后都变了- 提交于 2019-12-03 06:04:38
问题 I am trying to invoque very simple json webservices that return data of this form: { "_embedded": { "users": [{ "identifier": "1", "firstName": "John", "lastName": "Doe", "_links": { "self": { "href": "http://localhost:8080/test/users/1" } } }, { "identifier": "2", "firstName": "Paul", "lastName": "Smith", "_links": { "self": { "href": "http://localhost:8080/test/users/2" } } }] }, "_links": { "self": { "href": "http://localhost:8080/test/users" } }, "page": { "size": 20, "totalElements": 2,

Spring HATEOAS ControllerLinkBuilder methodOn increasing response times significantly

安稳与你 提交于 2019-12-03 00:48:08
The setup: So I have a RESTfull API written in java, using spring-boot and spring-hates for adding links to the resource (Hypermedia-Driven RESTful Web Service). Everything I have is standard and no additional settings or changes are made The problem Case: no links on resource - Chrome TTFB avg. (10 runs) 400ms for 1000 items Case: 1 self reference link on resource - Chrome TTFB avg. (10 runs) 1500ms for 1000 items I am using this official guide The question Why adding only 1 link to my resource adds additional 1 second for the processing the request. I will need around 5 - 7 links on each

Filling entity links in custom @RepositoryRestController methods

天涯浪子 提交于 2019-12-02 22:54:09
I am using Spring-data-rest to provide read APIs over some JPA entities. For writes I need to issue Command objects rather than directly write to the DB, so I added a custom controller using @RepositoryRestController and various command handling methods: @RequestMapping(method = RequestMethod.POST) public @ResponseBody MyEntity post(@RequestBody MyEntity entity) { String createdId = commands.sendAndWait(new MyCreateCommand(entity)); return repo.findOne(createdId); } I would like the output to be enriched just like any other response by the spring-data-rest controller, in particular I want it

Deserialize JSON containing (_links and _embedded) using spring-hateoas

时光怂恿深爱的人放手 提交于 2019-12-02 20:59:15
I am trying to invoque very simple json webservices that return data of this form: { "_embedded": { "users": [{ "identifier": "1", "firstName": "John", "lastName": "Doe", "_links": { "self": { "href": "http://localhost:8080/test/users/1" } } }, { "identifier": "2", "firstName": "Paul", "lastName": "Smith", "_links": { "self": { "href": "http://localhost:8080/test/users/2" } } }] }, "_links": { "self": { "href": "http://localhost:8080/test/users" } }, "page": { "size": 20, "totalElements": 2, "totalPages": 1, "number": 0 } } As you can see, it is pretty straight forward. I have no problems

How to loop and retrieve value from HATEOAS _link attribute (e.g. retrieve a description)?

瘦欲@ 提交于 2019-12-02 11:19:33
tl;dr My code gets an array of javascript/json objects from a Restful GET. How do I write code to loop and retrieve, for display, a description (or any value) from a HATEOAS "_link" attribute? Context I've inherited a small Spring-based project --it tracks servers, software installations, etc for our team's internal use. It uses Angular front end and Spring/java/mysql back end for a restful back end. I'm in the process of converting the hand-coded SQL to JPA and 'spring starter data rest' Current API Does The current handcoded SQL joins tables to give "display friendly results". Product ------

Calling spring data rest repository method doesn't return links

大兔子大兔子 提交于 2019-12-02 02:41:49
问题 I have the repository "ClientRepository": public interface ClientRepository extends PagingAndSortingRepository<Client, Long> { } When i request http://localhost:8080/clients/1 then server responds { "algorithmId" : 1, "lastNameTxt" : "***", "firstNameTxt" : "**", "middleNameTxt" : "**", "_links" : { "self" : { "href" : "http://localhost:8080/clients/1121495168" }, "client" : { "href" : "http://localhost:8080/clients/1121495168" } } } Response has links as expected. When i call repository

Calling spring data rest repository method doesn't return links

↘锁芯ラ 提交于 2019-12-02 01:08:41
I have the repository "ClientRepository": public interface ClientRepository extends PagingAndSortingRepository<Client, Long> { } When i request http://localhost:8080/clients/1 then server responds { "algorithmId" : 1, "lastNameTxt" : "***", "firstNameTxt" : "**", "middleNameTxt" : "**", "_links" : { "self" : { "href" : "http://localhost:8080/clients/1121495168" }, "client" : { "href" : "http://localhost:8080/clients/1121495168" } } } Response has links as expected. When i call repository inherited method findOne in another controller @RestController public class SearchRestController {

How to have PersistentEntityResourceAssembler injected into request methods of custom @RepositoryRestController in a @WebMvcTest unit test

流过昼夜 提交于 2019-12-02 01:00:17
问题 Overview How can I have a PersistentEntityResourceAssembler properly injected into my custom REST controller's request methods during a @WebMvcTest unit test? First SO question. Apologies in advance, probably just missing something stupid. Sample code available on GitHub. Oliver Gierke, where you at? :P Details I have a custom REST controller annotated with @RepositoryRestController . Some of its request methods have a PersistentEntityResourceAssembler injected as an argument so I can return

How do I avoid content fields in Joda objects?

狂风中的少年 提交于 2019-12-01 22:38:21
I'm using Joda objects (DateTime and DateTimeZone) in a document and whenever I access it via the REST interface I get entries with fields like this lastAggregationDate: { content: "2016-07-12T17:58:43.643Z" } instead of lastAggregationDate: "2016-07-12T17:58:43.643Z" I have the Joda Jackson dependencies declared and I see the de/serializers for these types so I'm puzzled as to what's at work here. I've duplicated this behavior in a slightly modified Spring sample project but using Java's native date types rather than Joda's. I've added a date of birth property to the Person object and

How to have PersistentEntityResourceAssembler injected into request methods of custom @RepositoryRestController in a @WebMvcTest unit test

你离开我真会死。 提交于 2019-12-01 22:16:22
Overview How can I have a PersistentEntityResourceAssembler properly injected into my custom REST controller's request methods during a @WebMvcTest unit test? First SO question. Apologies in advance, probably just missing something stupid. Sample code available on GitHub . Oliver Gierke, where you at? :P Details I have a custom REST controller annotated with @RepositoryRestController . Some of its request methods have a PersistentEntityResourceAssembler injected as an argument so I can return HAL resources. @RepositoryRestController @RestController @RequestMapping(produces = MediaTypes.HAL