Commit Graph

525 Commits

Author SHA1 Message Date
Oliver Gierke
88b73de3b7 DATAREST-1274 - JsonPatch paths now properly verify multi-digit indexes. 2018-08-08 08:44:43 +02:00
Oliver Gierke
5635479dd1 DATAREST-1248 - SortTranslator now considers read-only properties sortable.
MappedProperties now exposes a factory method that uses the Jackson introspector for serialization (instead of deserialization) which now also includes read-only properties. Previously, read-only ones were not considered as they are excluded from the metadata if it is looked up for deserialization.
2018-08-07 15:43:50 +02:00
Oliver Gierke
501ddda59f DATAREST-1273 - Properly support adding to collections via indexes in JsonPatch expressions.
We now support adding a to a collection via JsonPatch expressions by using the collection's size as target index. Contrary to paths pointing to existing collection elements we cannot determine the type of the object to be created. Thus, we fall back to the common element type of all existing collection elements. We also reject indexes pointing to elements with an index greater than the current collection's size.
2018-08-07 10:47:41 +02:00
Oliver Gierke
429706a77e DATAREST-1260 - Tweaked DomainObjectReader to support immutable entities.
DomainObjectReader now aborts the recursive merges in case it encounters an entity that's described as @Immutable (just introduced in Spring Data Commons).

Fixed some generics and removed DomainObjectMerger as it's unused.

Related ticket: DATACMNS-1322.
2018-07-12 10:30:54 +02:00
Oliver Gierke
c644eb979f DATAREST-1259 - Removed obsolete bean definition for HttpRequestHandlerAdapter. 2018-07-10 12:33:28 +02:00
Florian Lüdiger
10dedaefa3 DATAREST-810 - Fix minor typo in Javadoc.
Original pull request: #295.
2018-07-04 16:34:58 +02:00
Oliver Gierke
6ee2b1374a DATAREST-1256 - Upgraded to Spring HATEOAS 0.25.0.BUILD-SNAPSHOT.
Adapted RepositoryRestMvcConfiguration to now create a shared fallback ObjectMapper and avoid to register it as Spring Bean. Adapted test cases that previously were relying on such a bean being present.

Adapted test cases to verify on the correct ALPS document structure (see spring-projects/spring-hateoas#665).
2018-06-20 20:01:57 +02:00
Oliver Gierke
9f3443cde9 DATAREST-1251 - PersistentEntityProjector now uses lambdas instead of anonymous inner classes. 2018-06-13 14:44:10 +02:00
Oliver Gierke
7323b950b6 DATAREST-1198 - Polishing.
Fixed @since tag in new converter implementation as we're going to backport the fix to Kay. Simplified converter setup in RepositoryRestMvcConfiguration to expose less API until someone actually requests access.

Original pull request: #290.
2018-06-13 10:14:44 +02:00
Mark Paluch
65ad7cd3e1 DATAREST-1198 - Add Converter to convert String to javax.naming.ldap.LdapName.
We now provide and configure a converter for String to LdapName conversion so Spring Data LDAP can be used with Spring Data REST without further configuration.

Original pull request: #290.
2018-06-13 10:14:44 +02:00
Oliver Gierke
843540b746 DATAREST-1250 - Polishing.
Added unit test to verify new behavior and prevent regressions. Fixed author capitalization.
2018-06-05 10:11:37 +02:00
tigger
0cc1f22741 DATAREST-296 - ResourceMetadataHandlerMethodArgumentResolver now properly implements ….supports(…).
ResourceMetadataHandlerMethodArgumentResolver.supports(…) now properly checks for ResourceMetadata. It previously checked for RepositoryInformation which is probably a left-over from a previous state of the codebase and has been unnoticed so far as the class is only used as a direct dependency of other HandlerMethodArgumentResolvers.
2018-06-05 10:04:08 +02:00
Oliver Gierke
17c8c7ee2c DATAREST-1249 - Polishing. 2018-05-30 11:04:37 +02:00
Oliver Gierke
b61cb9ab28 DATAREST-1249 - DomainObjectMerger now properly binds to uninitialized target collections. 2018-05-30 10:40:34 +02:00
Oliver Gierke
a1454058d9 DATAREST-948 - Introduced ExposureConfiguration to allow customizing the exposure of HTTP methods of repositories.
ExposureConfiguration exposes methods to register AggregateResourceHttpMethodsFilter and AssociationResourceHttpMethodsFilter (both applied by type or globally) to customize the supported HTTP methods by collection, item and association resources. It also provides shortcuts for common use cases like disabling PUT for item resources etc.
2018-05-30 10:40:28 +02:00
Oliver Gierke
7eaf50d997 DATAREST-1222 - Switched to SimpleEvaluationContext for SpEL-based PATCH handling. 2018-03-28 09:56:50 +02:00
Oliver Gierke
e79b73664a DATAREST-1212 - Deprecated RepositoryRestConfigurerAdapter.
We now recommend to implement RepositoryRestConfigurer directly as its declared methods are now default methods. We also introduced a static factory method to easily create a configurer to customize RepositoryRestConfiguration via a Lambda expression.

Moved test case setups that use that deprecated API to the new one.
2018-03-12 13:21:14 +01:00
Oliver Gierke
622cf07720 DATAREST-1193 - DelegatingHandlerMapping is now a MatchableHandlerMapping.
DelegatingHandlerMapping now implements MatchableHandlerMapping by selecting the a delegate based on the already implemented algorithm and then invoking the ….match(…) method in case the selected one is a MatchableHandlerMapping in turn.

Refactored the internals a bit to be able to reuse the selection algorithm from both ….getHandler(…) and ….match(…).
2018-02-19 18:04:25 +01:00
Oliver Gierke
a10aa934b7 DATAREST-1176 - Repository method exposure can now be controlled via RepositoryRestConfiguration.
The default exposure of repository methods is now controlled via RepositoryRestConfiguration.setExposeRepositoryMethodsByDefault(…). That allows us to remove the additional API from RepositoryDetectionStrategy as the mere detection is an orthogonal topic.

Also added RepositoryRestConfiguration.disableDefaultExposure() to set the RepositoryDetectionStategy to ANNOTATED and disables default method exposure in one go. That can be exposed via a Spring Boot configuration property downstream.
2018-01-18 18:41:07 +01:00
Simon Allegraud
d4a3ba1195 DATAREST-1181 - Prevent NullPointerException during JsonLateObjectEvaluator.evaluate(…).
Original pull request: #287.
2018-01-18 13:49:53 +01:00
Oliver Gierke
7edfc75472 DATAREST-1174 - Enable constructor properties to make sure WrappedPropertiesUnitTests continue to work.
Removed Lombok constructor and accessor generation to avoid having to deal with the changed default in Lombok 1.16.20 not generating @ConstructorProperties by default anymore.
2018-01-10 12:51:29 +01:00
Mark Paluch
5d9dbf1823 DATAREST-1170 - Update copyright years to 2018. 2018-01-09 08:44:14 +01:00
Oliver Gierke
d3c5e339db DATAREST-1160 - Adapt tests to new CORS defaults in Spring Framework.
Spring Framework 5.0.2 changes the default for the Allow-Credentials header to false. We now adapted our test case to that and also drop the expectation to see the request URL in the Allow-Origin header as that is only returned if Allow-Credentials is true, which it now isn't by default.
2017-11-27 09:57:30 +01:00
Oliver Gierke
d48499ad8d DATAREST-1152 - Overhaul of patch expression handling.
Significantly refactored the way that patch path expressions are handled and evaluated. The new design is centered around SpelPath that is aware of the original path as well as the derived SpEL expression. That SpelPath then requires clients to bind it to a type so that the original path can be validated (and rejected if invalid) and provide API to read, set, copy and move values backed by the original path. Both SpelPath and TypedSpelPath instances are cached to avoid repeated creation.

PatchOperation implementations now provide more fluent factory methods, in some cases via intermediate builders. Removed a lot of obsolete code that created JsonNodes from a list of PatchOperations as we don't actually use that functionality anywhere. Removed obsolete generics where possible.
2017-10-25 17:34:46 +02:00
Simmo Saan
74e12a55b7 DATAREST-1148 - Fix eager toString() call on domain object in ResourceStatus.
Originl pull request: #282.
2017-10-12 23:12:34 +02:00
Oliver Gierke
33c551014d DATAREST-1006 - Polishing.
Added unit test on MappingProperties directly.

Original pull request: #258.
2017-10-04 11:37:02 +02:00
Mathias Düsterhöft
4207be4243 DATAREST-1006 - MappedProperties now skips all ignored properties.
Original pull request: #258.
2017-10-04 11:36:54 +02:00
Oliver Gierke
973f932a39 DATAREST-1137 - All patch operations now verify path expressions.
We now make sure that all patch operations now get the path they're supposed to be applied to verified before execution.
2017-09-27 09:47:18 +02:00
Oliver Gierke
d56a1068ea DATAREST-1132 - Fixed @BasePathAwareController annotation lookup from CGLib proxies.
We now inspect the user class of the given bean type in BasePathAwareHandlerMapping.isHandler(…). We can't use AnnotationUtils as @RepositoryRestController is also annotated with @BasePathAwareController but must not be handled by this mapping.
2017-09-25 11:54:05 +02:00
Oliver Gierke
c0a3fb5678 DATAREST-1136 - DelegatingHandlerMapping now exposes its delegates. 2017-09-25 09:34:33 +02:00
Oliver Gierke
8f269e28fe DATAREST-1127 - Patch operations now always verify paths before operation application.
Previously the SpEL expresssion created from JSON Patch path expressions were executed without double checking whether these paths actually exist on the target object in the first place. This is now in place.
2017-09-08 12:20:44 +02:00
Oliver Gierke
530e7c773e DATAREST-1121 - Skip last modified detection for query methods that project.
For an execution of a projecting query method we now skip the last modified detection as it actually doesn't make sense if applied to non-aggregates.
2017-08-24 22:19:18 +02:00
Oliver Gierke
5836baaabf DATAREST-1105 - Polishing.
Simplified code a bit. Formatting. Adapted integration tests to make sure URI templates are always expanded.

Original pull request: #273.
2017-07-19 16:05:27 +02:00
Haroun Pacquee
0d7d84571f DATAREST-1105 - Association links now advertise projections.
Association links now explicitly indicate projections are available in case there are projection types registered for the association target type.

Original pull request: #273.
2017-07-13 17:24:43 +02:00
Oliver Gierke
c922ba38d2 DATAREST-1106 - Moved off deprecated methods to setup a ProjectionFactory in configuration.
Switched from ProxyProjectionFactory.setResourceLoader(…) to ….setBeanClassLoader(…). Some generics polishing and removal of obsolete warnings supression.
2017-07-11 11:00:33 +02:00
Oliver Gierke
2ad963074c DATAREST-1104 - Adapt to API changes in mapping subsystem. 2017-07-04 15:27:54 +02:00
Oliver Gierke
069869a69b DATAREST-540 - Renamed RepositoryRestConfiguration bean config to repositoryRestConfiguration. 2017-06-20 13:03:17 +02:00
Oliver Gierke
585072a1b7 DATAREST-1060 - Improve AssociationOmittingSerializerModifier to not break on Jackson 2.9.
According to this upstream ticket [0] we need to override BeanSerializerModifier.changeProperties(…) rather than ….updateBuilder(…). The commit just does that.

[0] https://github.com/FasterXML/jackson-databind/issues/1664

Related ticket: FasterXML/jackson-databind#1664
2017-06-19 17:39:23 +02:00
Oliver Gierke
51812ccc97 DATAREST-1092 - Removed Spring 4.3 style handling of non-nullability in PatchOperations. 2017-06-14 15:32:40 +02:00
Oliver Gierke
37b0dc2dff DATAREST-1092 - Improve exception handling in PatchOperation for Spring 5 compatibility.
We now also catch SpelEvaluationException in the attempt to set a null value for an expression as Spring 5 now reports a failed attempt (e.g. if the target type is not nullable) using that type whereas Spring 4.3 threw a NullPointerException.
2017-06-14 11:26:37 +02:00
Oliver Gierke
bc5a265ff9 DATAREST-1031 - Fixed setup of ExceptionHandlerExceptionResolver.
Fixed the setup of our custom ExceptionHandlerExceptionResolver to conclude with a call to afterPropertiesSet() to make sure it's properly initialized.
2017-06-09 10:04:41 +02:00
Oliver Gierke
e4f34aaa67 DATAREST-1076 - Expose constructor that takes RelProvider of RepositoryResourceMappings.
We now expose the constructor that takes a RelProvider in RepositoryResourceMappings so that clients can tweak the default relation names. Changed the order of constructor parameters of (previously) non-public constructors for consistency.

The RelProvider to be used with the mappings can now be configured via RepositoryRestConfiguration and defaults to the EvoInflector based one.
2017-05-18 14:49:44 +02:00
Oliver Gierke
9a9512767e DATAREST-1039 - Fix appending a complex value appended to a collection via JSON Patch.
When a PATCH call using JSON Patch tried to append an item to an empty collection, it previously failed to look up the type to unmarshal the incoming payload to. We now inspect the declared types on the wrapped object's property to determine that type for append operations.

Also, an uninitialized collection is now initialized using Spring's CollectionFactory.
2017-05-12 14:54:24 +02:00
Oliver Gierke
f906695e7a DATAREST-1064 - Adapt to API changes in repository interfaces.
Additional cleanups in QuerydslAwareRootResourceInformationHandlerMethodArgumentResolver to make sure a QuerydslRepositoryInvokerAdapter is only applied if the QuerydslPredicateBuilder actually exposes a predicate. Extracted a couple of methods to make sure the mapping pipeline reads nicely.
2017-05-03 18:10:27 +02:00
Mark Paluch
f94a534fac DATAREST-1019 - Consider base URI when resolving cross-origin configuration on repositories.
We now consider the base URI when resolving CORS configuration from repository interfaces. The base URI is now stripped from the request. Previously the base URI was not stripped from the request and was used to determine an exported resource.
2017-04-18 19:55:29 +02:00
Oliver Gierke
2ebc688631 DATAREST-1055 - Move to Optional for base link handling in repository controllers. 2017-04-18 13:20:18 +02:00
Oliver Gierke
2b347daaab DATAREST-1050 - PUT for create now makes sure the resource id is set on the instance to create.
So far, we handed the plain instance deserialized from the request body to the repository to persist it. That caused issues in PUT for create scenarios where the URI contains the identifier to be used for the aggregate to create and identifier generation being used in the backend. In that case the identifier submitted was never considered and subsequent requests would've created new instances, effectively breaking the idempotent nature of PUT.

We now make sure the backend identifier derived from the resource is set on the aggregate instance about to be created, so that backend can either accept that situation (new entity + manually defined identifier) or reject it (in case it insists on identifier generation).
2017-04-11 09:10:04 +02:00
Oliver Gierke
359513fe9b DATAREST-1030 - Reinstantiate PATCH behaviour for associations.
We now completely opt out of merging values if the property is a linkable association.
2017-04-10 19:08:03 +02:00
Oliver Gierke
b9957d1a6c DATAREST-1008 - Adapt to API changes in Spring Data Commons, Java 8 upgrades and Mockito 2.7. 2017-03-24 11:02:54 +01:00
Oliver Gierke
a13f51b49e DATAREST-1003 - Entity resources don't answer arbitrary JSON requests.
Previously, when a request was sending an Accept header of some arbitrary *+json, the request was routed through the controllers and might have ended up producing a PersistentEntityResource that was then mapped using an uncustomized Jackson ObjectMapper. That has caused a huge JSON object to be unfolded which is highly undesirable.

We now only answer JSON requests to repository resources that contain an Accept header with any of the explicit JSON media types we got registered.

Tweaked the setup of the ExceptionHandlerExceptionResolver to not expose a bean in the first place but rather use the Spring MVC provided callbacks to register custom ones. We also now make sure MVC is bootstrapped property for integration tests through the inclusion of DelegatingWebMvcConfiguration.
2017-03-01 21:39:51 +01:00