spring-hateoas

Linking between objects on different apps with Spring HATEOAS

﹥>﹥吖頭↗ 提交于 2019-12-14 02:50:19
问题 I'm investigating spring-cloud and I've set up two microservices "offers" and "customers" as eureka clients. The customers app has: @Data public class Customer extends ResourceSupport { private Long customerId; private String name; } @RestController @RequestMapping("/customers") @ExposesResourceFor(Customer.class) public class CustomersController { ... } and the offers app has: @Data public class Offer extends ResourceSupport { private final Long offerId; private final Long priceI; private

How to bind custom Hateoas link class to RestTemplate?

删除回忆录丶 提交于 2019-12-13 04:41:15
问题 I have a common library for a spring rest API of one my application.API exposes rest call with custom HATEOAS link. ex) [ { "bookUid": "5c4ec057e21b840001968d31", "status": "PURCHASED_PENDING", "BookInfo": { .... }, "_links": { "self": { "href": "http://localhost:9992/api/v1/books/5c4ec057e21b840001968d31", "accepts": "application/json" }, "update-book": [ { "href": "http://localhost:9992/api/v1/books/5c4ec057e21b840001968d31", "name": "ACTIVATE", "accepts": "application/json", "method":

Proper place for setting form fields in ResourceSupport which don't exist in Entity

南笙酒味 提交于 2019-12-13 03:37:23
问题 I have a model for logging in user in my REST API, corresponds to User table (email and password as table columns) @Entity public class User { @Id @GeneratedValues private Long id; private String email; private String password; +GET , +SET } Then there is @Controller which is making call to above User Entity using JPAService @Controller @RequestMapping("/rest/auths") public class AuthController { @Autowired private UserService authService; @RequestMapping(value = "/login", method =

Spring Hateoas links and JPA persistence

最后都变了- 提交于 2019-12-12 18:12:17
问题 I have a JPA entity that i am building hateoas links for: @Entity public class PolicyEvent extends ResourceSupport` I want the hateoas links generated to be persisted in the PolicyEvent table . JPA doesn't seem to be creating columns in the PolicyEvent table for the _links member in the resourcesupport. Is there some way to persist the links member via JPA or is my approach itself incorrect (the Hateoas link data should not be persisted). Thank you 回答1: I'd advise not to mix JPA entities and

Spring HATEOAS/Jackson with resources and resource assembler

限于喜欢 提交于 2019-12-12 03:38:07
问题 I got a Jackson error because of a nested loop in a bidirectional relationship of two of my JPA entities (Task and Job). I started researching and partially managed to solve this using the @JsonManagedReference and @JsonBackReference annotations, but this method only works when I use the annotations within my entities, which ends with the JSON serialization jumping over my JobResource/JobResourceAssembler and TaskResource/TaskResourceAssembler, getting a HATEOASless and HALless json response.

Spring Data Rest: ResourceProcessor configuration is not working properly

放肆的年华 提交于 2019-12-12 01:44:56
问题 I have a strange behaviour with a Spring Data Rest implementation (version 2.5.2.RELEASE). I'm trying to register a @Bean of ResourceProcessor<Resource<Entity>> , but there is something strange. I'm trying with two kinds of solutions: 1) Declaring the @Bean in a class: @Bean public ResourceProcessor<Resource<Author>> authorProcessor() { return new ResourceProcessor<Resource<Author>>() { @Override public Resource<Author> process(Resource<Author> resource) { System.out.println("method process

How to access one element of a REST collection through HATEOAS links?

ぐ巨炮叔叔 提交于 2019-12-11 12:18:33
问题 I'm trying to build an architecture of RESTful services, and to build a gateway service for all of those, with Java Spring. In order to make the latter, I need to implement a client for the other services, which me and my colleagues tried to design around the HATEOAS principle, by providing links to related resources through spring-hateoas module. Let's say I have a service running on localhost, listening on 8080 port, which returns a collection of resources with a GET operation on /resources

Missing links in Spring Data Rest projection

可紊 提交于 2019-12-11 11:33:55
问题 I am working with Spring Data Rest and Hibernate in my current project. I just added projections for some entities to reduce the amount of calls to the backend when displaying information. My code looks like this: Component.class @NoArgsConstructor @RequiredArgsConstructor @EqualsAndHashCode @Getter @Setter @Slf4j @Entity @Table(name = "components") public class Component { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "component_id", unique = true) private Long id;

Can i offer an endpoint in parallel to a spring-data-rest GET?

99封情书 提交于 2019-12-11 08:44:52
问题 my project is moving away from a custom json format to json-hal and spring-data-rest. to continue the support for the "old" json i want to run the existing Resource-Controller parallel to the new Spring-Data-Rest provided one. Whenever i configure spring-data-rest to use the same url as our existing controller ONLY the old controller is used and if the accept-header does not match i get an error response. when i use a different url, everything works Is it possible to run a controller in

Using linked Resources in Custom REST Controller with Spring REST JPA

北战南征 提交于 2019-12-11 07:26:01
问题 I am developing a set of rest resources over a database and exposing the core CRUD functionality using Spring Data Rest to directly interact with the Repositories. In my simplified sample I have Users: @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) public long id; public String name; @OneToMany(mappedBy = "user") public Collection<Project> projects; } and users Own Projects: @Entity public class Project { @Id @GeneratedValue(strategy = GenerationType.AUTO)