Commit Graph

649 Commits

Author SHA1 Message Date
Oliver Drotbohm
0db1adadd0 Register StdValueInstantiator._constructorArguments for reflection.
The field is looked up by reflection in ValueInstantiatorCustomizer.

Fixes #2213.
2023-01-20 16:35:30 +01:00
Oliver Drotbohm
1bfa83cb73 Register per-repository pattern for observability purposes.
The standard Spring MVC observability integration registers the plain request pattern for observations. For our repository controllers that would result in one pattern registered for all individual repository resources (e.g. /{repository}/{id} etc.). However, the insights users would like to gain rather follows the individual repositories exposed. That's why we have so far exposed repository specific path pattern (/myrepo/{id}) via a custom request attribute. To adhere to the new observability integration of Spring Framework 6, we need to expose that particular pattern on the ServerRequestObservationContext, too.

Fixes #2212.
2023-01-09 15:31:57 +01:00
Mark Paluch
f0e86b9a17 Extend license header copyright years to 2023.
See #2211
2023-01-02 09:53:37 +01:00
Christoph Strobl
6f68fe814f Add Nullable annotation to parameter of overridden equals method.
Closes: #2196
Original pull request: #2197
2022-12-02 11:16:15 +01:00
Christoph Strobl
b3e8489085 Added AOT metadata.
We now register @BasePathAwareController instances for class proxy generation. Also, we scan the packages of repository definitions for projection interfaces to register reflective access for them.

Fixes #2183.
2022-10-27 11:50:57 +02:00
Oliver Drotbohm
5d0687d1a1 Improve JSON Patch implementation.
Refactor JSON Patch application implementation to improve the property detection for which values are supposed to be set.

Fixes #2177.
2022-09-19 10:21:19 +02:00
Oliver Drotbohm
23dfeafee4 Add explicit qualifier names to references to RepositoryInvokerFactory in RepositoryRestMvcConfiguration.
Fixes #2161.
2022-07-15 14:01:11 +02:00
Oliver Drotbohm
1205ef1eb8 Polish annotation attribute aliasing in RepositoryRestController.
Related ticket: #2157.
2022-07-14 17:45:26 +02:00
Oliver Drotbohm
753886fa2c Forward StringValueResolver to DelegatingHandlerMappings targets.
RepositoryRestMvcConfiguration now implements EmbeddedValueResolver to forward the StringValueResolver given to both BasePathAwareHandlerMapping and RepositoryRestHandlerMapping.

Related ticket: #2157.
2022-07-13 23:47:36 +02:00
Mark Paluch
070d284e69 Upgrade to Hibernate 6.
Introduce bytebuddy exclusions to avoid clashes with Mockito-provided byte buddy versions. Extend version range in Jackson Hibernate module registrar.

Closes #2158
2022-07-13 08:54:26 +02:00
Oliver Drotbohm
07ebc501cd Polishing.
Added test case and re-enabled the base URI to be prepended even in case a controller path prefix is configured. That functionality had been lost with the originally submitted changes.

Related ticket: #2157
Original pull request: #2088.
2022-07-06 17:26:07 +02:00
Yves Galante
8daacadb1e Add support for controller base path on BasePathAwareController / RepositoryRestController.
This commit introduces support for a common base path shared amongst all handler methods of a controller annotated with @BasePathAwareController / @RepositoryRestController.

Related ticket: #2157
Original pull request: #2088.
2022-07-06 17:26:07 +02:00
Oliver Drotbohm
4bff95a180 Remove obsolete test case from RepositoryRestHandlerMappingUnitTests.
The test started to fail when Spring Framework 6 disabled trailing slash path matching (see spring-projects/spring-framework#28552 for details). If adapted to the non-trailing version, it basically duplicates another test already present in the test class.
2022-07-06 17:26:07 +02:00
John Blum
29b7305d71 Remove punctuation in Exception messages.
Closes #2152.
2022-06-08 16:08:03 -07:00
Oliver Drotbohm
adcd7e74ef Fix PUT merge handling for polymorphic properties.
We now replace the original value of polymorphic properties with the newly deserialized one if the type of the new one is different from the old one. We still copy all JSON ignored properties to the new instance to make sure that non-exposed, server-side state is retained. We apply the same handling for explicitly immutable source and/or target types.

Fixes #2130.
2022-04-04 14:53:15 +02:00
Oliver Drotbohm
ed822390d8 Fix potential NullPointerException in HalFormsAdaptingResponseBodyAdvice.
Fixes #2123.
2022-03-28 16:50:34 +02:00
Oliver Drotbohm
b7d6b2b78c Update copyright years to 2022. 2022-02-07 10:26:46 +01:00
Jens Schauder
ee317f1b91 Remove Eclipse Non-Javadoc comments.
Closes #2093
2022-01-05 13:40:05 +01:00
Oliver Drotbohm
e912907ec0 Adapt to changes in Spring Framework's HttpMethod. 2021-11-30 18:56:54 +01:00
Oliver Drotbohm
0efd1502d0 Further steps towards JakartaEE.
Remove temporary version placeholders and obsolete version declarations for modules we do not test against anymore.

Tweaked the JPA integration and the Jackson Hibernate 5 one in particular to work with the new Jakarta variants. Re-enabled JPA tests. Removed support for Jackson Hibernate 4 integration and JodaTime.
2021-11-30 18:56:54 +01:00
Oliver Drotbohm
ede294967f Upgrade to Spring Framework 6. 2021-11-30 18:56:53 +01:00
Oliver Drotbohm
a40aec5deb Consider @CrossOrigin(originPatterns = …).
RepositoryRestHandlerMapping's RepositoryCorsConfigurationAccessor now also evaluates @CrossOrigin's originPatterns into the CorsConfiguration.

Fixes #2077.
2021-10-19 10:32:48 +02:00
Patrik Mihalcin
358bd3578a Fix typo in RepositoryRestController's JavaDoc
Fixes #2061.
2021-10-13 16:02:18 +02:00
Oliver Drotbohm
4434d32fae Prevent using NestedEntitySerializer if target serializer does not support unwrapping.
We now verify that the serializer registered for the type that's supposed to be handled by the NestedEntitySerializer actually supports unwrapping as the serialization in EntityModel (MapSuppressingUnwrappingSerializer) requires that to work properly.

Fixes #2056.
2021-10-13 11:59:53 +02:00
Oliver Drotbohm
1828a6a2a7 Switch to JUnit 5.
Issue #2075.
2021-10-12 22:29:45 +02:00
Oliver Drotbohm
18b39cb321 Reduce general runtime exception logging to debug.
Issue #2074.
2021-10-12 16:21:12 +02:00
Oliver Drotbohm
46dc6e03fc Prevent duplicate controller registrations through class-level @RequestMapping.
When we detected @BasePathAwareController and @RepositoryRestController instances, we now reject types that use @RequestMapping on the class level as doing so causes an inevitable registration of the controller with Spring MVC.

Fixes #1342, #1628, #1686, #1946.
2021-10-06 12:13:37 +02:00
Oliver Drotbohm
c6b77e3dd9 Polish Javadoc to prepare builds with JDK 17.
Issue #2068.
2021-09-21 16:36:26 +02:00
Oliver Drotbohm
1dae476040 Adapt Content-Type header for HAL FORMS requests based on affordances.
Whenever HAL FORMS is supposed to be rendered, we now adapt the `Content-Type` header depending on whether affordances (and thus `_templates`) are present. If none can be found, we either adapt the header to either `application/hal+json` or even `application/json` depending on the `Accept` header arrangement given. If none match, we reject the request with `406 Not Acceptable`.

Had to reintroduce a dependency on Lombok to use @SneakyThrows as otherwise we cannot throw HttpMediaTypeNotAcceptableException from a ResponseBodyAdvice. A manual implementation of the pattern does not compile on Java 8 (at least on MacOS).

Fixes #2060.
2021-09-14 22:49:05 +02:00
Oliver Drotbohm
2aca2b24e0 Avoid reflection in RepositoryRestMvcConfiguration.
We now completely avoid reflection in RepositoryRestMvcConfiguration by delaying all bean lookups that were previously declared through autowired fields.

Fixes #2057.
2021-08-26 15:38:47 +02:00
Oliver Drotbohm
9cd9e1cef9 Avoid eager reference to BackendIdConverter beans.
Switched to bean method parameter reference to all BackendIdConverter instances.

Fixes #2055.
2021-08-19 23:19:08 +02:00
Oliver Drotbohm
8a1d147009 Remove 3.x deprecations.
Removed all deprecations that have accumulated in the 3.x timeline so far.
2021-07-15 08:20:11 +02:00
Oliver Drotbohm
161a3a9499 Allow customization of LinkCollector.
LinkCollector is now an interface. The actual implementation has been moved to DefaultLinkCollector. RepositoryRestConfigurer now has a customizeLinkCollector(…) callback method to tweak or even completely replace the LinkCollector instance.

Fixes #2042.
2021-07-15 08:15:20 +02:00
Oliver Drotbohm
0c24113484 Dedicated customization callback for AuditableBeanWrapperFactory.
Introduced RepositoryRestConfigurer.customizeAuditableBeanWrapperFactory(…) so that implementations can customize the default instance provided by RepositoryRestMvcConfiguration.

Fixes #2040.
2021-07-14 19:01:11 +02:00
Oliver Drotbohm
e1dd82c927 Prevent NullPointerException in AggregateReferenceDeserializerModifier.
In AggregateReferenceDeserializerModifier we now look up the original property name on the Jackson metadata before trying to resolve the property target type. We also explicitly guard against null values returned from that lookup and opt out of the customization in those cases.
2021-07-13 09:25:57 +02:00
Oliver Drotbohm
e2f8d2f2c4 Avoid using Guava's Charset.
Replaced with Java's StandardCharset. Fixes #2026.
2021-06-17 21:16:14 +02:00
Oliver Drotbohm
0a0d410800 DelegatingHandlerMapping now fully implements MatchingHandlerMapping correctly.
We now also implement MatchableHandlerMapping.getPatternParser() to expose the PathPatternParser we use. This is needed to detect that DelegatingHandlerMapping uses a PathPatternParser from the outside as the Spring MVC request processing pipeline treats those HandlerMappings in a special way. This is especially important in the context of spring-projects/spring-framework#26814 as that makes the HM implementations work properly in CORS preflight requests.

When used with Spring Security in place, CORS preflight requests are inspected through the HandlerMappingIntrospector, that looks up the CORS configuration for the handler to serve the actual request. That lookup previously failed as Spring MVC was unable to detect that Spring Data REST's DelegatingHandlerMapping works with a PathPatternParser and didn't properly set up the processing pipeline to eventually end up in an invalid state, produce an exception that caused the handler method lookup to fail and cause Spring Security to fail with a 403, claiming the request was invalid.

Fixes #2007.
2021-05-07 22:12:57 +02:00
Oliver Drotbohm
6c007487c7 RepositoryRestConfigurer are again used in declared order.
4b36f79 introduced a regression by consuming registered RepositoryRestConfigurer instances via ApplicationContext.getBeansOfType(…).values() which, unlike the previous consumption via a List<RRC> in an @Bean method, is losing the declared order of the RRC instances as ….getBeansOfType() is a Map.

We now rather use an ObjectProvider and its ….orderedStream() method to consume the registered instances ordered properly.

Fixes #1995.
2021-04-09 12:42:24 +02:00
Oliver Drotbohm
b4b8fdfee0 Support aggregate reference resolution for DTOs.
Introduce AggregateReferenceResolvingModule to be registered with the default ObjectMapper instance that will allow to materialize aggregate instances from URIs for incoming web requests. We do not apply this for aggregate roots themselves as they're already handled by the AssociationUriResolvingDeserializerModifier.
2021-04-07 20:07:54 +02:00
Oliver Drotbohm
21ed68262f Properly handle associations in nested entities.
Nested entities that contain a reference to an aggregate root get a link to that attached to their representation. Previously, the creation of those links assumed that the reference is a materialized instance of the remote aggregate. That's now altered to be able to deal with associations, use identifiers directly or materialize to an intermediate aggregate instance to potentially use a custom lookup.
2021-04-07 20:07:53 +02:00
Oliver Drotbohm
9f8071a0d7 Remove legacy support for well-known XML configuration file import.
We now don't import XML configuration located in classpath*:META-INF/spring-data-rest/**/*.xml anymore. This is primarily to not trigger the XML subsystem in Spring Framework which we don't need at all actually. Users still relying on that import can just declare the import themselves.
2021-03-26 13:54:13 +01:00
Oliver Drotbohm
4b36f794dc Avoid RepositoryRestConfigurerDelegate exposed as bean.
Improving the configuration situation for RRCD, whose bean declaration required access to all RepositoryRestConfigurer instances while implementing the interface itself, too.  We now rather hide the creation of that instance in a Lazy as it doesn't need any kind of lifecycle management.
2021-03-26 13:48:38 +01:00
Oliver Drotbohm
17538c65d7 Enable rendering as HAL FORMS.
We're now registering an HttpMessageConverter to render requests for HAL FORMS using the HalFormsConfiguration present in the application.

We're currently not adding any affordances yet. The change solely enables user code to add affordances explicitly, e.g. via RepresentationModelProcessor implementations.

Fixes: #1991.
2021-03-25 18:01:54 +01:00
Oliver Drotbohm
65d4d71895 Support for jMolecules Identifier types.
We now properly handle jMolecules Identifier instances by integration with the corresponding Converter implementations provided by the jmolecules-spring integrations library.

Fixes GH-1982.
2021-03-08 20:31:58 +01:00
Oliver Drotbohm
e9bc98a1e9 #1980 - RepositoryEntityLinks now overrides ….linkForItemResource(…). 2021-02-24 17:57:46 +01:00
Oliver Drotbohm
0295573047 Avoid late registration of PathPatternParser on DelegatingHandlerMapping.
Instead of registering the PathPatternParser on DelegatingHandlerMapping via WebMvcConfigurer.configurePathMatch(…) we now consume the bean exposed in context of the fix for spring-projects/spring-framework#26427.

We also use the newly introduced RequestMappingInfo.mutate() to add our customizations of the produces clause for Spring Data REST's mappings.

Fixes GH-1965.
2021-01-26 22:45:33 +01:00
Oliver Drotbohm
5dc7536c2c Adapt to API changes in HalHandlerInstantiator.
Fixes GH-1964.
2021-01-25 23:37:22 +01:00
Oliver Drotbohm
de54531549 GH-1926 - Avoid wrapping nested entities ultimately to represent a value.
NestedEntitySerializer now skips the wrapping into an EntityModel if the target serializer is a JsonValueSerializer as EntityModel requires the value to ultimately resolve into key value pairs as it's only enriching something that's rendered as JSON document with hypermedia elements.
2021-01-18 16:04:46 +01:00
Oliver Drotbohm
4d7daa9f6e Let DelegatingHandlerMapping implement HandlerMapping directly.
We actually do not want to inherit all the functionality implemented in AbstractHandlerMapping. The sole reason we did so before was to override the method to propagate the PathPatternResolver to the downstream HandlerMappings. We now just declare the method on DHM directly.

Fixes GH-1955.
2021-01-14 15:37:37 +01:00
Mark Paluch
7afe7f1a9c Update copyright year to 2021.
Closes #1952
2021-01-12 11:45:16 +01:00