Commit Graph

180 Commits

Author SHA1 Message Date
Oliver Drotbohm
b678ce6bc9 PersistentEntitiesResourceMapping.hasMappingFor(…) should lookup metadata on cache miss. 2021-07-13 09:27:03 +02:00
Oliver Drotbohm
940a676e6d RepositoryResourceMappings now processes all entities to detect repository mappings.
We now consider all registered PersistentEntity instances and try to detect repository metadata for them. A case we didn't cover before was that a repository was declared for an aggregate super type but the actual child aggregate class didn't have a dedicated repository declared. While this is a perfectly valid scenario, the mapping information was broken as it fell back on the plain domain type information and produced paths and relation names derived from that, even if there's a super type repository available.

Thus, solely traversing the aggregate types we have repositories registered for is not enough. We now traverse all known PersistentEntity types and also register repository metadata for all types that are assignable to a known domain type. The latter is actually implemented in Spring Data Commons' Repositories via spring-projects/spring-data-commons#2406.
2021-07-07 16:20:09 +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
20cb33512e Fixed potential NullPointerException in PersistentPropertyResourceMapping.isExported().
Fixes GH-1994.
2021-04-07 20:07:53 +02:00
Oliver Drotbohm
cb75eaee90 #1974 - Polishing.
Deprecated configuration methods on RepositoryRestConfiguration for better naming.
2021-02-18 14:04:34 +01:00
Oliver Drotbohm
517bb5f202 #1974 - Improve default LinkRelationProvider setup to also consider @Relation.
RepositoryRestConfiguration now defaults the LinkRelationProvider instance to a delegating one considering both AnnotationLinkRelationProvider and EvoLinkRelationProvider so that @Relation annotations on entity types.
2021-02-18 14:04:34 +01:00
Mark Paluch
7afe7f1a9c Update copyright year to 2021.
Closes #1952
2021-01-12 11:45:16 +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
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
69c3491861 DATAREST-1549 - Adopt to changed MappingException thrown by PersistentEntities. 2020-08-04 15:30:37 +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
Mark Paluch
c485d612a7 DATAREST-1502 - Polishing.
Use diamond syntax where possible. Fix Javadoc.
2020-04-02 15:31:07 +02:00
Mark Paluch
34ab20e8d7 DATAREST-1502 - Use ConcurrentHashMap in PersistentEntitiesResourceMappings instead of ConcurrentReferenceHashMap.
We use now consistently ConcurrentHashMap instead of ConcurrentReferenceHashMap to avoid object eviction by GC runs as some caches are accessed in a way that does not allow for lazy recomputation of values.
2020-04-02 15:29:43 +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
Oliver Drotbohm
b74089cc3b DATAREST-1489 - Fixed caches in PersistentEntitiesResourceMappings.
We now consistently use ConcurrentReferenceHashMap for all caches to make PersistentEntitiesResourceMappings thread-safe.
2020-03-12 14:33:30 +01:00
Oliver Drotbohm
ac95b17acd DATAREST-582 - Add unit test to makes sure method is invoked on proxy.
See this Twitter thread for details: https://twitter.com/PreAuthorize/status/1227865219264741376
2020-02-13 17:13:35 +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
205e487317 DATAREST-1460 - PersistentEntityResourceMappings now uses thread-safe caches. 2019-12-09 18:04:50 +01:00
Mark Paluch
19c261d7d0 DATAREST-1410 - Migrate remaining tests to AssertJ. 2019-07-31 10:06:03 +02:00
Oliver Drotbohm
4a48be3ff7 DATAREST-1404 - TypeBasedCollectionResourceMapping now avoids repeated annotation lookups.
We're now making use of Lazy to avoid recomputation of annotation based functionality.
2019-06-26 17:46:43 +02:00
Oliver Drotbohm
556e918ef7 DATAREST-1403 - CollectionResourceMapping.getExcerptProjection() now returns Optional. 2019-06-26 17:46:43 +02:00
Oliver Drotbohm
2d994c7076 DATAREST-1401 - RepositoryCollectionResourceMapping now rejects multi-segment path configurations.
Tweaked implementation of lookups to use Lazy to avoid repeated annotation inspections.
2019-06-26 17:46:43 +02:00
Oliver Drotbohm
82b928848b DATAREST-1373 - Upgrade to API changes in Spring HATEOAS 1.0 M2. 2019-05-08 19:49:58 +02:00
Spring Operator
3a0cba94a2 DATAREST-1351 - URL Cleanup.
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/ with 1 occurrences migrated to:
  https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200).
* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 395 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).
* [ ] http://www.apache.org/licenses/LICENSE-2.0.html with 1 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0.html ([https](https://www.apache.org/licenses/LICENSE-2.0.html) result 200).

Original Pull Request: #352
2019-03-22 10:51:57 +01:00
Oliver Drotbohm
dc10166679 DATAREST-1304 - EntityLookupConfiguration is now used in PUT for creation.
Previously the backend identifier derived from the URI was set as identifier on the object to be created in a PUT request. However, in case a custom entity lookup is used, this is not the identifier but an arbitrary property pointed to through user defined code, mostly a method reference.

We now use the newly introduced MethodInvocationRecorder API in Spring Data Commons to be able to obtain the property that is supposed to be used and set that to the value calculated. This requires the entity type for which the custom lookup is configured to be non-final as the invocation recording is build on top of proxies.

Related tickets: DATACMNS-1449.
2019-03-06 14:34:58 +01:00
Oliver Drotbohm
d714d10675 DATAREST-1341 - Upgrade to latest API changes in Spring HATEOAS. 2019-03-04 11:42:58 +01:00
Oliver Drotbohm
47a759e3c3 DATAREST-1341 - Upgrade to latest API changes in Spring HATEOAS. 2019-03-01 00:26:06 +01:00
Oliver Drotbohm
1bf08180db DATAREST-1341 - Adapt to package refactorings in Spring HATEOAS. 2019-02-27 20:31:59 +01:00
Oliver Drotbohm
554d6cb27b DATAREST-1341 - Further API adaption for Spring HATEOAS 1.0. 2019-02-15 11:10:59 +01:00
Oliver Drotbohm
93b8e68bbf DATAREST-1341 - Move off of Java8PluginRegistry in favor of Spring Plugin's update one. 2019-02-07 20:55:42 +01:00
Greg Turnquist
af6f55a92c DATAREST-1341 - Upgrade to Spring HATEOAS 1.0. 2019-02-07 20:55:42 +01:00
Mark Paluch
68bfd55982 DATAREST-1330 - Update copyright years to 2019. 2019-01-08 11:47:37 +01:00
Oliver Drotbohm
3ea48a6223 DATAREST-1320 - Polishing. 2018-12-21 15:04:52 +01:00
Oliver Drotbohm
39b897e6d1 DATAREST-1320 - Fixed lookup of cached values in PersistentEntitiesResourceMappings.
We now properly only answer PersistentEntitiesResourceMappings.hasMappingsFor(…) with true if we find a non-null value in the cache. Previously, even a failed attempt to create some ResourceMapping would've caused ….hasMappingsFor(…) to indicate it PersistentEntitiesResourceMappings contains a mapping.

This lead to downstream NullPointerExceptions as ….getMetadataFor(…) was accessed without a null guard after ….hasMappingFor(…) returned true.
2018-12-21 15:04:44 +01:00
Oliver Drotbohm
8c0348f41b DATAREST-1324 - Polishing.
Removed trailing whitespace from Javadoc comments.
2018-12-21 14:32:26 +01:00
Oliver Drotbohm
7900ca8657 DATAREST-1324 - Fixed return type of ConfigurableHttpMethods.enable(…).
We now also return ConfigurableHttpMethods from its ….enable(…) method to make sure it can be chained properly.
2018-12-21 14:32:02 +01:00
Oliver Drotbohm
13370f8e2f DATAREST-1322 - Fix proxy detection for Hibernate 5+ compatibility.
Switched to Spring Data Commons' ProxyUtils for a proxy detection mechanism that supports Hibernate 5 proxies.
2018-12-20 17:16:49 +01:00
Oliver Gierke
781e1affe2 DATAREST-1261 - Fixed invalid fallback to default delegate in UnwrappingRepositoryInvoker.invokeFindById(…).
Previously we fell back to the default by-id lookup even if a custom entity lookup was defined but returned an empty result.
2018-07-12 22:36:56 +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
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
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
9c9d125d78 DATAREST-1177 - DefaultExposureAwareCrudMethods now caches results. 2018-01-24 11:06: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
Oliver Gierke
6b61d2b026 DATAREST-1176 - Polishing.
Moved the flag to decide whether to expose repository methods by default to the RepositoryDetectionStrategy interface, so that it can be directly accessed and the test on the particular enum value is not needed anymore and thus also not duplicated into different parts of the codebase.

Added more tests to actually verify behavior on CrudMethodsSupportedHttpMethods. DefaultExposureAwareCrudMethods uses @RequiredArgumentConstructor again.
2018-01-18 18:41:07 +01:00
Tobias Weiß
5172f89281 DATAREST-1176 - Add explicitly method annotated detection strategy 2018-01-18 18:41:07 +01:00