Commit Graph

445 Commits

Author SHA1 Message Date
Oliver Drotbohm
f7f2ae03fc #1430 - Update license headers for 2021. 2021-01-13 09:55:24 +01:00
Oliver Drotbohm
7a86ea4b31 #1424 - More syntactic sugar for MvcLink. 2020-12-22 14:46:44 +01:00
Oliver Drotbohm
0cfbd7b414 #1423 - Undeprecate HalFormsConfiguration.withPattern(…).
It's the replacement method for registerPattern(…) returning a fresh instance.
2020-12-22 14:35:46 +01:00
Oliver Drotbohm
93dfe16800 #1412 - Discovered mappings now get regex matchers removed.
We now remove potentially used regular expression matchers from template variables to avoid the to show up in links generated for the templates.
2020-12-12 17:43:28 +01:00
Oliver Drotbohm
fc9d2a6777 #1399 - Make sure curie information is rendered for pre-curied links.
We previously didn't render the curie information if the process of curying didn't actually change the link relation if it was already given in a curied form. We now check preprocessed link relation for a curie and include the curie information if we find a curie.
2020-11-23 13:48:15 +01:00
Oliver Drotbohm
e2aa9126fa #1379 - Proper type resolution for CollectionModel post-processing.
CollectionModelProcessorWrapper erroneously returned a raw type in case a CollectionModel type assignment check failed which rendered the element type verification to always match as it's effectively compared against Object.

We're now returning null to rather proceed with the next candidate type.
2020-10-28 22:41:36 +01:00
Oliver Drotbohm
03abd3f169 #1382 - Polishing.
Let HalForms register a custom ObjectMapper customizer to allow separate customizations. If HAL and HAL Forms are supposed to be customized the same way, the same customizer can be registered on both instances. Tweak the application of the customizer to happen inside the configuration classes, not on the outside.

Prepare HalFormsConfiguration to become a fully immutable type in 1.3. Javadoc and assertion polish.

Original pull request: #1383.
2020-10-27 20:34:34 +01:00
Greg L. Turnquist
89fade21c2 #1382 - Add ability to customize the ObjectMapper for HAL and HAL-FORMS.
Use HalConfiguration to allow applying customizations to the ObjectMapper.

Original pull request: #1383.
2020-10-27 20:34:34 +01:00
Oliver Drotbohm
0643624e7c #1379 - Test cases to show that what's described is generally working. 2020-10-27 19:55:15 +01:00
Oliver Drotbohm
1607994fd2 #1352 - Change in implementation strategy for Maps in EntityModel.
We now use a custom serializer for EntityModel.getContent() as we need that to still return the Map content for programmatic clients. The serializer skips maps entirely and programmatically unwraps all other content.

A simple Converter (@JsonSerialize(convert = …)) to filter Maps unfortunately didn't do the trick as that causes a a delegating serializer to be registered for the property and @JsonUnwrapped stops working as it's designed to work with bean serializers only.

Adapted test cases accordingly.

Original pull request: #1353.
2020-08-12 09:31:45 +02:00
Greg L. Turnquist
69c81f24e4 #1352 - Render Map entries once.
Maps, when wrapped inside an EntityModel, were getting double-rendered. Fix it so that they are only rendered once.
2020-08-11 23:28:34 +02:00
Oliver Drotbohm
9b8971a1df #1341 - Added Links.addIf(boolean, Link...).
Additional unit tests to increase coverage.
2020-07-29 21:42:34 +02:00
Oliver Drotbohm
e6262825b3 #1340 - Added Links.and(Stream<Link>).
Added equivalent overloads of merge(…) as well.
2020-07-29 14:52:09 +02:00
Oliver Drotbohm
a14e592bfa #1322 - Rename Links.and(boolean, …) to ….andIf(boolean, …). 2020-07-29 09:48:50 +02:00
Oliver Drotbohm
6453d25263 #1335 - Support for Supplier<Stream<?> expansion in EmbeddedWrappers.
This allows types like Spring Data's Streamable to be piped into the ….wrap(…) methods and immediately resolved into a collection.
2020-07-28 22:28:40 +02:00
Greg L. Turnquist
4720e563f0 #1304 - Update ref docs to properly show how to register custom media types.
Custom media types do NOT require registering a MediaTypeConfigurationProvider implementation with spring.factories. The reference docs must be updated to illustrate this. Also add to the javadocs so users are properly warned.
2020-07-28 14:58:51 -05:00
Oliver Drotbohm
035b742a1f #1335 - Added HalModelBuilder.embed(Stream<?> …).
HalModelBuilder is now able to take Stream instances directly immediately resolving them so that clients don't have to call ….collect(Collectors.toList()) all the time. Some internal rearrangements and stricter null guarantees in EmbeddedWrappers.
2020-07-28 16:42:26 +02:00
Oliver Drotbohm
646e73c8c5 #1329 - Removed APIs deprecated in 1.0.
* ControllerLinkBuilder(Factory)
* IanaRels
2020-07-27 18:23:06 +02:00
Oliver Drotbohm
5ea48dd332 #361 - Rearrange PropertyResolvingMappingDiscoverer.
Moved PropertyResolvingMappingDiscoverer into server.core package. Unified MappingDiscoverer arrangement in WebHandler and use it from there. Deprecated AnnotationBasedMappingDiscoverer to be able to make it package protected in 1.3.
2020-07-27 18:16:46 +02:00
Oliver Drotbohm
ffa1dc3539 #361 - Polishing.
Made implementation class package protected to not expose it. Avoid the use of Optional for hot code paths. Removed factory method as we only use the type internally anyway.

Removed test customizations as the discoverer is now just leniently opting out if not ApplicationContext can be found.

Original pull request: #1328.
2020-07-27 17:50:25 +02:00
Michele
c5f4bfa0b5 #361 - Implemented property resolving in link creation.
We now pipe the detected mapping through the PropertyResolver exposed by the ApplicationContext's Environment.

Original pull request: #1328.
2020-07-27 17:50:25 +02:00
Oliver Drotbohm
3a7798a912 #1291 - Polishing. 2020-07-27 13:06:24 +02:00
Greg Turnquist
5f625ede2d #1291 - Support alphanumeric logref for VndError.
According to https://github.com/blongden/vnd.error, logref is for "expressing a (numeric/alpha/alphanumeric) identifier". This patches `VndError` to support both strings and integers, ensuring each serializes properly.

NOTE: `VndErrors` has been deprecated due to the spec itself being dead since 2014. However, it must be supported until fully removed from Spring HATEOAS.

Original pull request: #1293.
2020-07-27 13:06:24 +02:00
Oliver Drotbohm
43528523eb #1314 - Polishing. 2020-07-24 08:48:32 +02:00
Oliver Drotbohm
2504ae3fac #1314 - HalLinkRelations now properly parses link relations with more than one colon.
Previously the parsing of link relations had assumed that a curie relation only consists of a single colon, thus, that a split by colon would always end up in two elements and only re-assembled these two elements. In case a URI that contains multiple colons handed into the parsing method, further segments had been dropped. We now remain everything following the first colon as local part of the URI.

Also, we now detect IANA registered URI schemes [0] and consider source relations starting with those as uncuried ones.

[0] https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
2020-07-24 08:46:28 +02:00
Oliver Drotbohm
f23f2399a3 #1287 - Polishing. 2020-07-23 22:50:32 +02:00
Oliver Drotbohm
348d6e4514 #1287 - Remove cache from UriTemplate in favor of better handling in Link.
We now avoid creating the UriTemplate instance for a Link if the Link does not contain curly braces in the first place. That allows us to remove the cache within UriTemplate in the first place.
2020-07-23 22:50:15 +02:00
vachillo
f1407b253e #1320 - Update Javadoc and toString() methods in renamed representation model classes. 2020-07-23 09:29:53 +02:00
Oliver Drotbohm
200ef443de #1323 - Polishing. 2020-07-23 09:27:27 +02:00
Oliver Drotbohm
e05d904fe1 #1323 - HalModelBuilder.build() now picks up call side generics. 2020-07-23 09:27:09 +02:00
Oliver Drotbohm
b560e5228a #1287 - Fixed potential memory leak when creating many links.
We now use a copy of Spring Framework's MimeTypeUtil's ConcurrentLruCache implementation to strictly only LRU cache 1024 instances of UriTemplate and fall back to creation if that size is exceeded.

This should solve the memory leak for now but should still be revisited across the Spring ecosystem.
2020-07-22 23:32:42 +02:00
Oliver Drotbohm
8af6b4c099 #1322 - Added Links.and(boolean, Supplier<Link>) to conditionally add links. 2020-07-19 18:32:31 +02:00
Oliver Drotbohm
d64d3d308c #1321 - Introduced MvcLink to ease Link creation from MvcUriComponentsBuilders.
We now ease Link creation from MvcUriComponentsBuilder controller method references via MvcLink.of(…).
2020-07-19 18:25:59 +02:00
Greg L. Turnquist
5972fd3f35 #1294 - Delombok production code.
Production code will no longer use Lombok. It's confined to test scope.
2020-07-01 09:47:59 -05:00
Greg L. Turnquist
153caeab18 #1313 - Polishing. 2020-06-26 11:17:44 -05:00
Greg L. Turnquist
27fe7de1c9 #1313 - Override Problem.withStatus in ExtendedProblem to preserve payload.
When you use the withStatus() method on an ExtendedProblem, it hands back a Problem, which drops the payload. This commit adds the same sort of override already provided for the other attributes in ExtendedProblem.
2020-06-26 11:17:36 -05:00
Oliver Drotbohm
5d1136ee12 #968 - Polishing.
Original pull request: #1269.
2020-05-07 22:19:28 +02:00
Réda Housni Alaoui
08c5f564b3 #968 - Consider @JsonUnwrapped properties with (embedded) CollectionModel and HAL Forms.
Original pull request: #1269.
2020-05-07 22:19:01 +02:00
Oliver Drotbohm
2cab91a332 #864 - Introduced HalModelBuilder.
HalModelBuilder expose HAL-idiomatic API to set up representations. That includes embeds, previews and syntactic sugar around the inclusion of potentially empty collections as embeds.

Related tickets: #175, #193, #270, #920.
Original pull request: #1273.
2020-05-07 21:32:57 +02:00
Oliver Drotbohm
36ddb281f9 #1280 - Fix in invocation of generic RepresentationModelProcessor. 2020-04-29 17:04:44 +02:00
Oliver Drotbohm
1f8c0a4230 #1252 - Polishing.
We now make sure that BeanPostProcessors that are exposed consume their dependencies via ObjectFactory instances to avoid the need to prematurely trigger bean instantiation in the BeanPostProcessor detection phase. Marked the direct dependencies of the post processors as lazy, as the post processor only do actual work if beans of a particular type are available in the ApplicationContext. In case they aren't we don't even need to instantiate the downstream dependencies of the processors.

Avoid proxying of configuration classes where possible.

Related pull request: #1251.
2020-04-03 18:26:09 +02:00
Greg Turnquist
de38b9e200 #1252 - Make sure HypermediaWebTestClientConfigurer is only included with spring-test on the classpath.
HypermediaConfigurationImportSelector is now ResourceLoaderAware to make sure it uses the class loader used to bootstrap the application context. This is important for both testing as well as custom classloader arrangements like Boot's DevTools. We now only include WebTestHateoasConfiguration if WebTestClient is on the classpath.

The configuration class has been extracted to not leak references to code tied to spring-test into production deployments. Added test cases to check both the inclusion and exclusion of the configuration classes based on the classpath arrangement.

Original pull request: #1251.
2020-04-03 17:48:29 +02:00
Greg Turnquist
6a6cd31113 #1223 - Polishing. 2020-04-02 12:17:26 -05:00
Greg Turnquist
600a975732 #1224 - Polishing. 2020-04-02 12:12:37 -05:00
Oliver Drotbohm
14f6375234 #1244 - Polishing.
Added missing license headers and a bit of formatting. Nullability annotations in HypermediaWebTestClientConfigurer.
2020-03-31 13:52:05 +02:00
Greg Turnquist
904a03a241 #1224 - Provide API for users to easily configure WebClient instances.
Introduce `HypermediaWebClientConfigurer` with a simple API that registers hypermedia types via `WebClient.Builder`.

Deprecate `WebClientConfigurer`, leveraging the new solution.

Update reference documentation showing how to use it, with and without Spring Boot.
2020-03-30 23:00:20 -05:00
Greg Turnquist
dea0001da2 #1223 - Provide API to configure RestTemplate with hypermedia.
Create a HypermediaRestTemplateConfigurer bean registered as a Spring HATEOAS bean.

Update reference documentation to show how to use it directly and with Spring Boot via RestTemplateCustomizer.
2020-03-30 22:20:27 -05:00
Greg Turnquist
4e697b899b #1225 - Polishing.
Appears one test case exerted a false positive. Fixing it exposed a gap and how to properly configure an existing WebTestClient (which is now in the reference docs).
2020-03-30 16:13:42 -05:00
Greg Turnquist
898752f0d5 #1225 - Provide implementation of WebTestClientConfigurer to support hypermedia registration.
Expand reference documentation to show ways to use it directly or via Spring Boot.
2020-03-30 12:23:07 -05:00
Oliver Drotbohm
6c09839cca #1241 - Additional factory methods for CollectionModel and PagedModel.
Added overloads of ….empty() to allow adding links right on construction.
2020-03-27 14:52:19 +01:00