Commit Graph

282 Commits

Author SHA1 Message Date
Oliver Drotbohm
aea4c4c91f #811 - Added ability to override single link render mode per link relation.
HalConfiguration now exposes a withSingleLinkRenderModeFor(…) taking a path pattern to be rendered in the also given RenderSingleLinks mode. It takes patterns as link relations are either plain strings or valid URIs.

Simplified HAL link list rendering in Jackson2HalModule avoiding double nesting of collections before rendering.
2019-02-21 16:46:53 +01:00
Oliver Drotbohm
e82d42f45a #728 - Polishing. 2019-02-21 12:27:51 +01:00
Oliver Drotbohm
1d9703abbe #728 - API polishing.
Renamed LinkBuilder implementations for the different web stacks Web(MVC|Flux)LinkBuilder for symmetry. Introduced dedicated builder types to be used from WebFluxLinkBuilder to more conveniently integrate with reactive flows (see the changes in WebFluxEmployeeController).

Deprecated ControllerLinkBuilder(Factory) in favor of WebMvcLinkBuilder(Factory).

Generally untangled the use of WebMvcLinkBuilder from the reactive examples.
2019-02-21 12:27:51 +01:00
Oliver Drotbohm
576274c1b2 #728 - Fix dependency cycles in WebFlux / WebMVC code
WebHandler is now independent of a particular web stack as the final LinkBuilder creation is externalized through a SAM type that client code now uses to pass a constructor. Refactored the ReactiveLinkBuilder to avoid a dependency on ControllerLinkBuilder (read: the WebMVC stack). With that change, WebHandler is now moved back to the core package.

Refactored LinkBuilderSupport to keep a UriComponentsBuilder instance around instead of UriComponents. It creates a defensive copy of the builder instance on state modifying invocations and returns a new LinkBuilderSupport instance.

Moved SpringMvcAffordanceBuilder to the core package and removed Mvc segment from its name to make obvious it's not tied to SpringMVC. Introduced TemplateVariableAwareLinkBuilderSupport as common base class between ControllerLinkBuilder and ReactiveLinkBuilder. It extracts the TemplateVariable behavior from ControllerLinkBuilder.

Extracted import of web stack specific configuration into dedicated ImportSelector and make use of String based class names to avoid cyclic dependencies between the config packages.

Removed BasicLinkBuilder.
2019-02-21 12:27:51 +01:00
Oliver Drotbohm
68c605c7ff #728 - Polishing.
Adapt to API changes in master branch. Fixed formatting.
2019-02-21 12:27:51 +01:00
Greg Turnquist
3f0dcc7cb4 #728 - Add support for Spring WebFlux.
* Render hypermedia from WebFlux controllers.
* Support consuming hypermedia through WebClient.
* Support link creation reactively with a custom filter and explicitly with a user-provided ServerWebExchange.
* Add a ReactiveResourceAssembler and SimpleReactiveResourceAssembler.
* Upgrade to Spring Framework 5.2 to align with Spring Data Moore, removing specialized Forwarded header handling.
2019-02-21 12:27:51 +01:00
Oliver Drotbohm
544d7cd9ff #749 - Polishing. 2019-02-20 22:55:56 +01:00
Oliver Drotbohm
112479c499 #749 - Improve performance in Link building.
Introduced more aggressive caching of request mappings and UriTemplates based on the contribution on 0.25.x.
2019-02-20 22:55:48 +01:00
Oliver Drotbohm
926bf55339 #825 - Polishing.
Added StringLinkRelation.hashCode() to be consistent with ….equals(…).

Original pull request: #826.
2019-02-20 17:33:36 +01:00
Greg Turnquist
19036880b4 #825 - Comply with RFC8288 for LinkRelation matching.
Added several tests to ensure compliance with RFC8288.

Original pull request: #826.
2019-02-20 17:33:02 +01:00
Greg Turnquist
e74d1098cc #808 - Remove Forwarded handling.
In light of upgrading to Spring Framework 5.1, no longer need custom handling of Forwarded headers.

Original pull request: #818.
2019-02-15 11:21:39 +01:00
Oliver Drotbohm
9e5db1874e #812 - General overhaul and refactorings.
Cleanups in Affordance API and implementations of hypermedia type (de)serializers. Added a lot more domain methods and types to Link, ResourceSupport etc. to be able to move a lot of representation building logic into those.

AffordanceModelFactory is not a Spring Plugin anymore as that functionality is not needed currently as we statically look up all factories via the SpringFactoriesLoader mechanism.

Redesigned LinkRelation to become a first class abstraction in the codebase. IanaLinkRelations is now a collection of constants. Link now keeps a LinkRelation instance around instead of a plain String.

Tweaked LinkDiscoverer API to return Optional and Links instead of nullable Link and List<Link>.

Tweaked API of CurieProvider to make use of the newly introduced HalLinkRelation based on the general LinkRelation.

Additional fixes for the Kotlin extension functions. Make Kotlin build setup compile with JDK 8. Removed Objects helper class in favor of Spring's already existing Assert and it's usage in ResourceAssemblerSupport.
2019-02-15 10:57:23 +01:00
Oliver Drotbohm
38b98af786 #819 - Polishing.
Original pull request: #820.
2019-02-15 10:53:20 +01:00
Greg Turnquist
14f0012aef #819 - Migrate off deprecated OrderAwarePluginRegistry APIs.
Original pull request: #820.
2019-02-15 10:52:50 +01:00
Oliver Drotbohm
f830d3d641 #806 - Polishing. 2019-02-11 14:57:31 +01:00
Oliver Drotbohm
aca2cc578a #806 - Fixed package cycle between hateoas and hateoas.core packages.
Moved AffordanceModelFactory to the library's root package. Moved Kotlin extensions to hateoas.mvc package.

Added an ArchUnit based test for package cycles.
2019-02-11 14:57:25 +01:00
Oliver Drotbohm
e794bf873a #805 - Polishing.
Whitespace.
2019-02-11 10:41:49 +01:00
Oliver Drotbohm
1dea5f61b9 #805 - Added Links.getRequiredLink(…). 2019-02-11 10:41:49 +01:00
Greg Turnquist
a9bae74dcf #793 - Switch from @Order to Ordered. 2019-02-07 16:44:42 -06:00
Oliver Drotbohm
c0903cb33e #803 - Polishing.
Method reordering. Whitespace.
2019-02-07 20:13:23 +01:00
Oliver Drotbohm
df6e1e5989 #803 - Removed reflective bridging between JSONPath 0.9 and 1.0.
We're on JSONPath 2.2 already.
2019-02-07 20:12:21 +01:00
Greg Turnquist
9e8e57a74b #787 - Return all Link attributes on discovery. 2019-02-07 11:42:08 -06:00
Greg Turnquist
9518a2db9a #791 - Add 'name' property to Link. (#801) 2019-02-07 08:13:49 -06:00
Jens Schauder
9f4f1ad79b #788 - Fixed obvious warning in all touched files.
* Fixed assertions.
* Removed superfluous code.
* Simplified generics.
* Formatting.
2019-01-23 13:59:21 -06:00
Greg Turnquist
4081e58a1f #788 - Switch to IanaLinkRelations internally. 2019-01-18 12:19:25 -06:00
Greg Turnquist
0f696dd637 #788 - Remove redundant generics. 2019-01-18 12:03:45 -06:00
Greg Turnquist
74647cb5b1 #788 - Unify line endings. 2019-01-18 11:38:28 -06:00
Greg Turnquist
5725794a8e #788 - Remove redundant constructs, pre-Java 8 cruft, and superfluous exceptions. 2019-01-18 11:38:19 -06:00
Greg Turnquist
e9074c5d52 #784 - Polishing.
* Formatting.
* Copyright headers.
* Unused/unneeded methods.
2019-01-15 12:12:05 -06:00
Jens Schauder
b7a1c06f79 #784 - Polishing.
* Formatting.
* Extracted conversion methods.
* Tested and fixed NPE with empty pojo.
* Tested and fixed NPE with empty page meta data.
2019-01-15 12:10:47 -06:00
Greg Turnquist
8da3a851ce #784 - Introduce UBER+JSON mediatype.
Based on https://rawgit.com/uber-hypermedia/specification/master/uber-hypermedia.html.
2019-01-09 14:33:41 -06:00
Greg Turnquist
820f66179f #707 - Refactor Affordances to better support Spring Data REST.
* Move Spring MVC method scanning out of the core Affordances API and into SpringMvcAffordanceBuilder to make it easy to use in Spring Data REST (where method scanning isn't needed).
* Also push attributes from Affordance into AffordanceModel to centralize the details.
* Certain serializers must be registered differently due to Jackson's rules of precedence given Spring Data REST needs to override them.
2019-01-07 14:08:42 -06:00
Greg Turnquist
2e7eabdc1a #778 - Introduce LinkRelation and enumerated IANA types.
Include IANA registry text and link to related standard for each link relation.
2019-01-04 12:42:32 -06:00
Greg Turnquist
26c9a3d71e #483 - Polishing.
Since we can't guarantee the incoming Map is <String,Object>, should only cast as <Object,Object> and use `.toString()` for maximum flexibility.
2018-12-21 08:43:21 -06:00
JamesE Richardson
8ced6c5154 #483 - Add composite field support to UriTemplate.
* Added Tests to demonstrate required functionality.
* Expanding variables correctly to meet RFC spec.  Composite values can be expanded either as a list or as an associative array

Also see https://tools.ietf.org/html/rfc6570#section-2.4.2
2018-12-20 20:27:56 -06:00
Greg Turnquist
a56392ac7c #572 - Create SimpleResourceAssembler for Resource<T>.
Implement a ResourceAssembler based solely on a domain type, returning Resource<T> for the `toResource(obj)` method.

Related issues: #416
2018-12-19 11:36:40 -06:00
Greg Turnquist
a597960711 #416 - Alter ResourceAssemblerSupport.toResources to return Resources.
To avoid confusion about what to return on a Spring MVC endpoint, change toResources to not return `List<D>`, but instead `Resources<D>`. This clearly ensures when used to construct Spring MVC endpoints, will return a type Spring HATEOAS will properly marshal.

To support people that have already built apps on top of Lists, include a `toList<D>` method that honors the old contract.

Related issues: #493
Related pull requests: #572
2018-12-18 10:28:03 -06:00
Greg Turnquist
8bf01c3ee5 #667 - Ignore unknown properties in LinkMixin.
In HAL-based documents (HAL and HAL-FORMS), the "templated" property must be ignored in LinkMixin, because that's where it is applied. Removes the need for a no-op `setTemplated` method in Link.

* Test cases drafted for both HAL an HAL-FORMS to verify proper behavior.
* Jackson2HalFormsIntegrationTest migrated from Hamcrest to AssertJ assertions.

Related pull requests: #668
2018-12-10 08:04:14 -06:00
Jens Schauder
4ce73154df #678 - Polishing.
* Moved compilation of Regexp patterns out of methods in order to not repeat it over and over again.
* Applied soft assertions where multiple assertions where used where one failure didn't guarantee the failure of all other assertions.
* Minor formatting.
2018-12-07 12:26:25 -06:00
Greg Turnquist
6f27ff0379 #678 - Add 'profile' to Link.
Fully support HAL spec by adding "profile" as another optional attribute to `Link`.

See: https://tools.ietf.org/html/draft-kelly-json-hal-08, https://tools.ietf.org/html/rfc5988
2018-12-07 12:26:25 -06:00
Johnny Lim
ca0263fc5a #751 - Align Hop header assertions with HttpHeaders and javadocs.
Spring Framework accepts `null` for header values in HttpHeaders. This is already reflected in the javadocs.
2018-12-07 11:41:10 -06:00
Greg Turnquist
d5649c0de1 #667 - Fix Link to ignore setting "templated" properties.
Deserializing a Link with a templated URI will cause Jackson to break due to there being no "templated" property. This adds a private, no-op `setTemplated` method to allow deserialization to occur yet not alter the Link..
2018-12-06 12:54:28 -06:00
Jens Schauder
367f560745 #695 - Polishing.
* Removed Jaxb annotations from packaga-info.java.
* Simplified Test code by removing unused code a debug output.
* Formatting.
* Updated copyright headers.
2018-12-06 12:25:22 -06:00
Greg Turnquist
dca65e15f8 #695 - Remove Jaxb annotations.
By removing all Jaxb annotations, requesting data from a hypermedia-enabled endpoint inside a browser (which defaults to accept:application/xhtml+xml,*/*), Spring HATEOAS will yield HAL.
2018-12-06 12:00:44 -06:00
Oliver Drotbohm
eff893fcf8 #758 - Polishing.
Original pull request: #717.
2018-12-06 14:21:10 +01:00
Greg Turnquist
bb4a4a615c #758 - Centralize all Forward header handling.
Spring 5.1 is centralizing all Forward header handling. This moves critical bits into one location, making it easy to completely remove once we rebaseline against this version.

Also adds a test profile to ensure Spring 5.1 doesn't break anything.

Original pull request: #717.
2018-12-06 14:20:54 +01:00
Greg Turnquist
df618efd12 #743 - Polishing. 2018-10-25 11:54:25 -05:00
Manish Misra
b60799d7fa #743 - Allow custom headers on each hop. 2018-10-25 11:39:15 -05:00
Oliver Gierke
8cfbfc1b89 #719 - Simplified configuration setup.
We now avoid to register ObjectMapper instances as Spring beans and rather use one already existing in the ApplicationContext and copying the setup before registering the individual HttpMessageConverters for the individual media types.

Replaced a lot of the programmatic component setup via BeanDefinitions with their corresponding JavaConfig alternatives.

Removed obsolete media type specific HttpMessageConverters and configuration classes registering them.
2018-06-22 11:30:16 +02:00
Greg Turnquist
ef3e3c48fe #711 - Polishing. 2018-05-15 15:08:35 -05:00