Commit Graph

839 Commits

Author SHA1 Message Date
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
Mark Paluch
793c09270d DATAREST-1052 - Prepare next development iteration. 2017-05-09 11:34:41 +02:00
Mark Paluch
edaf6197e2 DATAREST-1052 - Release version 3.0 M3 (Kay). 2017-05-09 11:23:00 +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
680d84fe4e DATAREST-946 - Prepare next development iteration. 2017-04-04 22:08:15 +02:00
Oliver Gierke
fceb36ff71 DATAREST-946 - Release version 3.0 M2 (Kay). 2017-04-04 21:12:35 +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
Oliver Gierke
8ad81978b0 DATAREST-995 - Removed support for ~ to reference a last collection element in JSON Patch.
Completely removed the support for ~ in favor of the previously introduced support for the correct indicator -.
2017-02-08 19:59:08 +01:00
Oliver Gierke
4e2edd2d37 DATAREST-995 - Fixed detection of collection append operations for JSON Patch requests.
We previously erroneously looked for a ~ in a JSON Pointer to indicate collection append in e.g. an add operation. We now also support the actually correct - keeping the original behavior for now to not break clients that currently make use of it.
2017-02-08 19:59:08 +01:00
Jens Schauder
ea482e0577 DATAREST-994 - Fixed two argument constructor of RepositoryRestHandlerMapping.
Repositories in RepositoryCorsConfigurationAccessor may be null now. findCorsConfiguration returns null when no repositories are provided.

Original pull request: #257.
2017-02-03 09:07:20 +01:00
Mark Paluch
b06f8664f1 DATAREST-992 - Remove references to Assert single-arg methods.
Replace references to Assert single-arg methods with references to methods accepting the test object and message.

Related ticket: SPR-15196.
2017-02-01 13:25:13 +01:00
Oliver Gierke
7c3bf750b3 DATAREST-944 - DomainObjectMerger now also merges associations for PUT.
We now explicitly merge associations skipping the linkable ones. We also try to reuse the existing collections and maps if they're mutable falling back to a completely new one if not.

Extracted PropertyHandler and AssociationHandler implementations.
2017-01-26 07:45:25 +01:00
Oliver Gierke
ca9d7f7b1d DATAREST-977 - Fixed reading of complex enums on collection expansion for PATCH.
When merging collections on PATCH we now don't use the first collection item's type for all elements but inspect the values for each existing element found. When it comes to appending elements to the collection, wen now just stick to the declared component type as type hint for reading the provided value.
2017-01-24 16:15:15 +01:00
Oliver Gierke
fe1c4b1e1c DATAREST-957 - Improved PUT handling for transient properties not backed by a field.
When copying the transient properties of an aggregate, we now try field based access first and fall back to accessor based copying in case both a setter and getter are exposed on the type.

Previously we always expected a field to be present which doesn't necessarily has to be the case.

Related ticket: DATAREST-986.
2017-01-24 13:22:04 +01:00
Oliver Gierke
08f012d4aa DATAREST-965 - Switched to property based application of PUT requests.
Jacksons ObjectMapper.readerForUpdate(…) unfortunately doesn't handle nested objects properly. We already have a manual merge process in place for PATCH requests but tweaking that to also handle PUT requests gracefully caused more complexity than anticipated.

We now switched to an object based merge so that we can read in the source JSON structure into a new object and then merge the objects.

Related pull request: #247.
2017-01-23 16:42:41 +01:00
Oliver Gierke
96ff0cb465 DATAREST-986 - DomainObjectReader now merges complex nested maps correctly.
We now use a Map property's generic type information to make sure we convert both the key and the value into the declared types. Previously we just used Object if the source value to map was null. Object is still used as fallback for raw maps though.
2017-01-23 09:30:49 +01:00
Oliver Gierke
2ad00c0dd7 DATAREST-982 - Adapt to changes in Jackson default time rendering in test case.
We now configure a more explicit pattern to verify the ISO date rendering of Jackson.
2017-01-16 17:27:42 +01:00
Mark Paluch
69c39377ec DATAREST-976 - Embedded properties are now considered in sort property paths.
We now allow sorting by properties of embedded objects. An embedded object is not linkable to a root object but embedded in the resource itself. If any part of the sort property path points to a linkable association, the whole sort property path is discarded silently and not used for sorting any further.

Original pull request: #251.
2017-01-16 13:36:15 +01:00
Mark Paluch
e2f88141ca DATAREST-978 - Polishing.
Convert @see http://… links to valid format using @see <a href=…>…</a>.
2017-01-13 10:09:53 +01:00
Mark Paluch
6bb989018c DATAREST-978 - Migrate ticket references in test code to Spring Framework style. 2017-01-13 10:09:53 +01:00
Oliver Gierke
4eea46aa09 DATAREST-899 - Prefer user registered modules over default ones.
We now issue the user registration of Jackson modules before any of the default modules Spring Data registers get applied. Testing module registration seems to be rather difficult as Jackson doesn't actually expose API to do so. An issue [0] was filed for Jackson to improve on this.

[0] https://github.com/FasterXML/jackson-databind/issues/1478
2016-12-20 12:53:19 +01:00
Oliver Gierke
8c1ee5608b DATAREST-964 - Removed deprecated configuration methods in RepositoryRestMvcConfiguration. 2016-12-20 12:10:43 +01:00
Oliver Gierke
c03653b7e9 DATAREST-959 - Polishing.
Skip all merge logic if the source value is null. That frees all nested logic from handling with that case and us falling back to plain Jackson reading.

The array handling now also opts out if the source value is not a collection or array in the first place as it means we need to let Jackson override the value with the collection given to be deserialized.

Original pull request: #246.
2016-12-13 10:09:02 +01:00
Milos Cubrilo
0b1bbbab31 DATAREST-959 - Fix adding elements to empty array in DomainObjectReader.
Original pull request: #246.
2016-12-13 10:09:00 +01:00
Oliver Gierke
aa7eec4683 DATAREST-835 - Search resources returning a single resource now get and consider ETag and Last-Modified headers.
We now interpret If-None-Match and If-Modified-Since headers on requests to resources backed by query methods returning a single instance only. This allows clients to optimize GET requests to those resources to save bandwidth.
2016-12-08 21:35:37 +01:00
Oliver Gierke
42378ab34d DATAREST-957 - Polish most critical Sonar warnings.
Fixed broken equals(…) in ProjectionDefinition. Switched to iterating over Map's entry set instead of the keys. Made UriAwareHttpServletRequest static.
2016-12-08 10:12:31 +01:00
Oliver Gierke
c0df12d9fa DATAREST-956 - Polishing.
Some tiny refactorings in DomainObjectReader. We're now using TypeInformation instead of Class to preserve more generics information when it comes to deeper nesting.

Moved some code around in the unit tests.

Original pull request: #245.
2016-12-08 09:49:17 +01:00
Mathias Düsterhöft
667576c661 DATAREST-956 - Fixed handling of collection element addition and removal for PUT requests.
DomainObjectMerger now properly adds and removes elements to and from collections.

Original pull request: #245.
2016-12-08 09:48:20 +01:00
Oliver Gierke
6c99760621 DATAREST-953 - Added test case to verify this is fixed.
Seems the change for DATAREST-938 has also fixed this one. Added a test case similar to what was provided in the example for the original ticket.
2016-12-07 18:50:44 +01:00
Oliver Gierke
e7c4b2176e DATAREST-938 - Polishing.
Formatting and author.

Original pull request: #241.
2016-12-07 18:50:42 +01:00
Craig Andrews
b859b8b91f DATAREST-938 - Update nested entities instead of replacing them with new instances.
Original pull request: #241.
2016-12-07 18:50:38 +01:00
Oliver Gierke
a4f88fe1ac DATAREST-910 - Polishing.
Minor code reorganizations. Eagerly create SortTranslator to avoid repeated instantiation.

Original pull request: #232.
2016-12-06 12:00:39 +01:00
Mark Paluch
0dc97dcc56 DATAREST-910 - Support nested Sort properties.
We now support nested Sort properties considering Jackson mapping. Sort translation is optional and skipped if the domain class is not resolvable. Translation in the scope of a domain class maps property paths to apply sorting using embedded properties.

A sort string `nested-name` resolves to a property path `anotherWrap.embedded.name`.

class Aggregate {

	@JsonUnwrapped
	public UnwrapEmbedded anotherWrap;
}

class UnwrapEmbedded {

	@JsonUnwrapped(prefix = "nested-")
	public Embedded embedded;
}

class Embedded {
	public String name;
}

Original pull request: #232.
2016-12-06 12:00:38 +01:00
Mark Paluch
24d26943af DATAREST-910 - Adopt interfaces for Pageable and Sort method argument resolvers.
Original pull request: #232.
2016-12-06 12:00:38 +01:00
Oliver Gierke
7855613415 DATAREST-937 - Polishing.
Moved the newly added test case to the end of the list. Formatting.

Original pull request: #240.
2016-12-06 09:38:19 +01:00
Craig Andrews
4150688851 DATAREST-937 - Transient properties in JSON are now included in merge.
We now don't prematurely drop fields that don't have a persistent property exposed in DomainObjectReader. Doing so dropped values for transient fields as the latter are not exposed as persistent property in the first place. We still skip any nested merging though.

Original pull request: #240.
2016-12-06 09:38:19 +01:00
Oliver Gierke
21b7d7cbed DATAREST-925 - Polishing.
Original pull request: #238.
2016-12-02 20:17:08 +01:00
Craig Andrews
8149a02820 DATAREST-925 - Invoke ResourceProcessors for ProjectionResources.
The serializer for projection resources now also invokes ResourceProcessor instances registered for that particular projection.

Original pull request: #238.
2016-12-02 20:17:08 +01:00
Oliver Gierke
03aa65890e DATAREST-934 - Prepare next development iteration. 2016-11-23 10:59:09 +01:00
Oliver Gierke
4e8771eee8 DATAREST-934 - Release version 3.0 M1 (Kay). 2016-11-23 10:35:48 +01:00
Oliver Gierke
8327b6f4ab DATAREST-935 - Prepare 3.0 development.
Upgraded version numbers and dependencies to Spring Data build parent, Commons and store modules. Fixed a compiler issue in DomainObjectReader.
2016-11-18 16:13:54 +01:00
Oliver Gierke
7329e20fa8 DATAREST-919 - Merging of nested maps for PUT/PATCH requests now handles nested arrays and simple types. 2016-11-03 16:19:46 +01:00
Oliver Gierke
68d0a1aa6a DATAREST-931 - Polishing.
Switched to non-deprecated property naming strategy in test case.
2016-11-03 09:13:52 +01:00