Commit Graph

618 Commits

Author SHA1 Message Date
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
Oliver Drotbohm
1e78de5eac DATAREST-1590 - Avoid need for eager access to components in RepositoryRestMvcConfiguration.
Switch to ObjectProvider for all component dependencies in the constructor of RepositoryRestMvcConfiguration. Made the bean definition of AnnotatedEventHandlerInvoker a static bean as it's an application listener and it being an instance method causes extend initialization of the configuration class trickling down into unnecessary bean lookups that early in the lifecycle.
2020-12-14 19:14:13 +01:00
Oliver Drotbohm
38f2bc4598 DATAREST-1581 - Fixed CORS defaults to include all HTTP methods exposed by Spring Data REST.
The fix for DATAREST-1535 has changed the default allowed methods for CORS requests to a smaller set than we originally returned. This commit reinstantiates the default to be set to all HTTP methods, Spring Data repositories support by default.

Related tickets: DATAREST-1535.
2020-12-01 22:35:25 +01:00
Oliver Drotbohm
328ea26244 DATAREST-1542 - Remove dependency to Spring WebMVC from core module.
Finally remove the dependency to Spring WebMVC from Spring Data REST's core module. Removed previously deprecated methods and update test configuration applying customizations.

Related tickets: DATAREST-1543.
2020-11-30 13:55:52 +01:00
Oliver Drotbohm
f00451dc7e DATAREST-1213 - Polishing.
Simplified tests and domain code. Reinstantiated accidentally removed method in PersistentEntityResource.

Original pull request: #355.
2020-10-26 22:36:01 +01:00
Dario Seidl
055c4528e8 DATAREST-1213 - ETag creation now uses proxy target for projections.
Original pull request: #355.
2020-10-26 22:36:01 +01:00
Oliver Drotbohm
25cfb6ecb9 DATAREST-1567 - Polishing.
Tweaked test setups to work without the explicit component scanning.

Original pull request: #382.
2020-09-25 10:57:15 +02:00
Christoph Strobl
8ff438678d DATAREST-1567 - Replace component scan with explicit bean methods.
We replaced the component scan in RespositoryRestMvcConfiguration with dedicated bean methods. This allows us to be more explicit in resolving required components, which is required for better support of GraalVM native image.

Original pull request: #382.
2020-09-25 10:57:15 +02:00
Oliver Drotbohm
0392103371 DATAREST-1545 - Polishing. 2020-09-15 17:13:53 +02:00
Greg L. Turnquist
9737366174 DATAREST-1545 - Migrate away from proxy-based configuration. 2020-09-15 17:13:53 +02:00
Oliver Drotbohm
bf401f7476 DATAREST-1553 - Removed deprecations introduced prior to 3.4.
Removed Java8PluginRegistry not in use anymore anyway. Same for RepositoryRestConfigurerAdapter. Deprecated legacy ResourceMappingUtils and its client code exposed in RepositoryRestConfiguration as it's also not considered anymore.
2020-08-11 17:44:36 +02:00
Oliver Drotbohm
b17fed5fa6 DATAREST-1523 - Delombok production sources.
Hacking.
2020-08-11 16:53:15 +02:00
Mark Paluch
c73a1c1576 DATAREST-1549 - Polishing.
Move off deprecated API.
2020-08-04 15:33:16 +02:00
Oliver Drotbohm
15b8d598bd DATAREST-1540 - Tweak HandlerMapping setup to retain compatibility with 5.3.
Turns out that Spring Boot references DelegatingHandlerMapping from its metrics integration to pick up the HandlerMappings delegated to. Reintroduced the relevant type in deprecated form and also let it implement Iterable<HandlerMapping> so that client code can be moved to generally check for HandlerMappings implementing that and pick up the delegates that way.
2020-07-29 12:27:31 +02:00
Oliver Drotbohm
9f62237dd3 DATAREST-1543 - Deprecate RepositoryRestConfiguration.getCorsRegistry().
Slightly tweaked the configuration model to rather handle the CorsRegistry via RepositoryRestConfigurer.configureRepositoryRestConfiguration(…) rather than RepositoryRestConfiguration itself. That allows moving of Spring WebMVC as a dependency in the core module.

The original methods exposing access to the CorsRegistry are now still available in deprecated form to not break existing clients.

Follow-up ticket: DATAREST-1542.
2020-07-03 15:06:41 +02:00
Oliver Drotbohm
d7f36b1180 DATAREST-1540 - Improvements in HandlerMapping implementation for Spring 5.3.
We now use Spring's path prefix capabilities to apply Spring Data REST's base path to its mappings. This was previously implemented by tweaking the matching conditions.

We now also pick up Spring 5.3's PathPatternParser and apply that to the custom HandlerMapping implementations we register.

Moved DelegatingHandlerMapping into the configuration package to be able to keep it around in package scope.

Deprecated RepositoryRestConfiguration.getBaseUri() as we have only supported paths for quite a while now. Moved all client code to ….getBasePath() instead.
2020-07-01 18:55:11 +02:00
Oliver Drotbohm
a9576991fe DATAREST-1535 - Adapt to changes in Spring Framework 5.3.
We now implement getPatternParser() in DelegatingHandlerMapping introduced in Spring 5.3. Adapt to changes in CORS handling.
2020-06-24 23:52:45 +02:00
Mark Paluch
ef7617cb6f DATAREST-1509 - Polishing.
Reduce Jenkins build to Java 8 + 14 for jackson-next profile. Simplify assertion style. Convert space indents to tabs.

Original pull request: #374.
2020-04-28 11:01:00 +02:00
Greg Turnquist
eaa70cdc77 DATAREST-1509 - Test against all ISO-8601 TZ formats.
Verify that Jackson properly serializes to ISO-8601 format, which includes three potential timezone endings. Expand CI testing against both Jackson 2.10 and 2.11. Also test these profiles against JDK 8, 11, and 14.

Related: spring-projects/spring-data-build#1075
Original pull request: #374.
2020-04-28 11:00:53 +02:00
Oliver Drotbohm
7c10768501 DATAREST-1513 - Avoid superflous instantiations of EmbeddedResourcesAssembler. 2020-04-28 00:31:29 +02:00
Oliver Drotbohm
399c846378 DATAREST-1479 - Patching collections now also works for nested collections.
We now properly use the PropertyPath's leaf property to check whether we need to deal with a collection in JSON Patch pointers.
2020-04-27 23:52:55 +02:00
Oliver Drotbohm
db5995eee0 DATAREST-762 - Collection resource's base link now forwards parameters.
We now use the current request's URI as base link for all links created for a collection resource. This especially has effect in the creation of pagination links as we now carry potentially applied critierias (induced by our Querydsl based filtering support) forward to the navigation links generated.
2020-03-30 22:50:21 +02:00
Oliver Drotbohm
4c17d54e9a DATAREST-1499, DATAREST-1500 - Cleanups.
Moved off Spring Framework deprecations for HttpMessageNotReadableException. This required some rearrangements of method signatures for types (hopefully) exclusively used by internal abstractions (some public, but not very friendly for user extension in the first place).

Switched to consistent use of Pageable.unpaged() instead of null. Switched to the use of new factory methods in Spring HATEOAS. Some Java 8 based improvements in request handling to simplify the implementation code. Deprecation of code that got obsolete due to the use of the factory methods.

Moved off some deprecations in Jackson APIs.

Removed a couple of unused imports. General avoidance of common warnings. Suppression where needed. Removed dead code in configuration.
2020-03-27 14:16:47 +01:00
Mark Paluch
abedcd130a DATAREST-1491 - Adapt to Mockito 3.3 changes. 2020-03-11 09:34:57 +01:00
Thomas Mrozinski
07039a2838 DATAREST-1068 - Resize array during merge.
When merging new data into a PersistentEntity, JsonNodes of array types were deserialized into immutable Lists, but the list is later mutated if the source and target arrays are of different sizes. This commit ensures that an array is deserialized into a mutable list.

Original pull request: #371.
2020-02-26 09:59:21 +01:00
Oliver Drotbohm
d8c3394cd7 DATAREST-1470 - Switched to use factory methods of RepresentationModel types. 2020-01-14 14:51:18 +01:00
Mark Paluch
88f49da22f DATAREST-1467 - Update copyright years to 2020. 2020-01-07 09:02:59 +01:00
Oliver Drotbohm
2b8e7afbf3 DATAREST-1463 - Adapt to API changes in LinkBuilderSupport. 2019-12-09 10:21:13 +01:00
Oliver Drotbohm
9010a9d132 DATAREST-1458 - Fixed rendering of compact view to association resources.
The usage of text/uri-list as media type was entirely broken and not even advertised in the reference docs anymore. It's now again supported for both to-one and to-many associations via Collections. Maps are rejected as they cannot be rendered as list of URIs correctly. Updated reference documentation accordingly.

Added a custom MapModel implementation of RepresentationModel as apparently using Maps with EntityModel does not unwrap the content properly due to [0].

[0] https://github.com/FasterXML/jackson-databind/issues/171
2019-11-29 17:17:35 +01:00
Oliver Drotbohm
28f8e0d397 DATAREST-1440 - Revisited removal of fields in incoming payloads.
We now only remove fields from the payload in case there's no @JsonAnySetter on the target entity.
2019-11-04 09:09:59 +01:00
Oliver Drotbohm
8689c1bb5b DATAREST-1446 - Polishing.
Test cases.

Original pull request: #366.
2019-10-28 15:00:54 +01:00
Javier Grande Pérez
694079df04 DATAREST-1446 - DefaultExcerptProjector now declines presence of projection if metadata returns Optional.empty().
If no excerpt projection is exposed by the underlying ResourceMetadata, DefaultExcerptProjector now also properly declines its existence in ….hasExcerptProjection(…). Previously, it always indicated a presence as it improperly used a null check rather than calling Optional.isPresent().

Original pull request: #366.
2019-10-28 14:57:57 +01:00