Commit Graph

533 Commits

Author SHA1 Message Date
Oliver Gierke
ea2c13ac45 DATAREST-1056 - Release version 2.6.3 (Ingalls SR3). 2017-04-19 19:32:39 +02:00
Oliver Gierke
1f8857be95 DATAREST-1016 - Prepare next development iteration. 2017-04-19 11:48:43 +02:00
Oliver Gierke
41130ec142 DATAREST-1016 - Release version 2.6.2 (Ingalls SR2). 2017-04-19 10:11:29 +02:00
Mark Paluch
ef508ed6dc 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:35:06 +02:00
Oliver Gierke
2b63e4bcdb 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 08:26:47 +02:00
Oliver Gierke
4354d35c9c 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:16 +02:00
Oliver Gierke
f6708109ca DATAREST-990 - Prepare next development iteration. 2017-03-02 10:21:39 +01:00
Oliver Gierke
d75254d1ac DATAREST-990 - Release version 2.6.1 (Ingalls SR1). 2017-03-02 09:41:28 +01:00
Oliver Gierke
941408daff 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:30:37 +01:00
Oliver Gierke
f4b8ee3be2 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 20:00:03 +01:00
Jens Schauder
e94ba4a1fa 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:06:59 +01:00
Mark Paluch
d2386dc64e 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:23:59 +01:00
Oliver Gierke
17d08d2830 DATAREST-967 - Prepare next development iteration. 2017-01-26 10:57:45 +01:00
Oliver Gierke
93a2c589c5 DATAREST-967 - Release version 2.6 GA (Ingalls). 2017-01-26 10:27:10 +01:00
Oliver Gierke
fe75811812 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:39:54 +01:00
Oliver Gierke
8e1af29bf2 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:10:37 +01:00
Oliver Gierke
2738982576 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:21:47 +01:00
Oliver Gierke
132807cbf1 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 15:34:52 +01:00
Oliver Gierke
294db99e63 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:24:14 +01:00
Mark Paluch
ffe96e4079 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:30:30 +01:00
Mark Paluch
4837ba83b1 DATAREST-978 - Polishing.
Convert @see http://… links to valid format using @see <a href=…>…</a>.
2017-01-13 10:09:17 +01:00
Mark Paluch
636956944c DATAREST-978 - Migrate ticket references in test code to Spring Framework style. 2017-01-13 10:07:40 +01:00
Oliver Gierke
187b3451fc DATAREST-862 - Prepare next development iteration. 2016-12-21 16:33:11 +01:00
Oliver Gierke
d7da7e107e DATAREST-862 - Release version 2.6 RC1 (Ingalls). 2016-12-21 16:19:34 +01:00
Oliver Gierke
4eeef2fee1 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:51:01 +01:00
Oliver Gierke
839682d619 DATAREST-964 - Removed deprecated configuration methods in RepositoryRestMvcConfiguration. 2016-12-20 12:06:06 +01:00
Oliver Gierke
7a473658ae 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 09:54:26 +01:00
Milos Cubrilo
a3873a90df DATAREST-959 - Fix adding elements to empty array in DomainObjectReader.
Original pull request: #246.
2016-12-13 09:25:02 +01:00
Oliver Gierke
50c2197a37 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:32:58 +01:00
Oliver Gierke
a254e1adae 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:01 +01:00
Oliver Gierke
29345d3e49 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:44:36 +01:00
Mathias Düsterhöft
59c7bae518 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:36:22 +01:00
Oliver Gierke
a1c538c31e 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:46:29 +01:00
Oliver Gierke
69fcd395f6 DATAREST-938 - Polishing.
Formatting and author.

Original pull request: #241.
2016-12-07 18:35:14 +01:00
Craig Andrews
b17c8bc19b DATAREST-938 - Update nested entities instead of replacing them with new instances.
Original pull request: #241.
2016-12-07 18:34:49 +01:00
Oliver Gierke
9fbdd03b0a DATAREST-910 - Polishing.
Minor code reorganizations. Eagerly create SortTranslator to avoid repeated instantiation.

Original pull request: #232.
2016-12-06 11:57:52 +01:00
Mark Paluch
357bb7a28b 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 11:57:49 +01:00
Mark Paluch
7880bef68c DATAREST-910 - Adopt interfaces for Pageable and Sort method argument resolvers.
Original pull request: #232.
2016-12-06 11:57:33 +01:00
Oliver Gierke
a928dc0e20 DATAREST-937 - Polishing.
Moved the newly added test case to the end of the list. Formatting.

Original pull request: #240.
2016-12-06 09:28:59 +01:00
Craig Andrews
30d173315a 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:28:15 +01:00
Oliver Gierke
bb26b39e81 DATAREST-925 - Polishing.
Original pull request: #238.
2016-12-02 20:16:51 +01:00
Craig Andrews
b66c8272ee 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:16:48 +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
Oliver Gierke
50d2678d01 DATAREST-931 - DomainObjectMerger now handles arrays with complex objects correctly.
We now explicitly manually merge array nodes that contain complex objects. Previously arrays would've been skipped and the subsequent Jackson update would wipe out all properties not contained in the original document even on PATCH requests.
2016-11-02 13:40:54 +01:00
Oliver Gierke
40bb8e8e6c DATAREST-573 - Polishing.
Removed RepositoryRestConfiguration.addCorsMapping(…) as we currently don't have any other shortcut methods for configuration like this.

Tweaked the setup of (now Repository)CorsConfigurationAccessor to be created earlier so that we avoid recreation for every lookup. Introduced a NoOpStringValueResolver to be used by default so that we don't need to deal with the case of the resolver being null at the end of the call chain. Replaced constructor of RepositoryCorsConfigurationAccessor with corresponding Lombok annotation.

Updated reference documentation accordingly.

Original pull request: #233.
2016-10-28 14:19:26 +02:00
Mark Paluch
a3870ca528 DATAREST-573 - Add support for new CORS configuration mechanisms introduced in Spring 4.2.
We now support CORS configuration mechanisms introduced in Spring 4.2. CORS can be configured on multiple levels: Repository interface, Repository REST controller and global level. Spring Data REST CORS configuration is isolated so Spring Web MVC'S CORS configuration does not apply to Spring Data REST resources.

 Multiple configuration sources are merged so different aspects of CORS can be configured in separate locations.

@CrossOrigin
interface PersonRepository extends CrudRepository<Person, Long> {}

@RepositoryRestController
@RequestMapping("/person")
public class PersonController {

	@CrossOrigin(maxAge = 3600)
	@RequestMapping(method = RequestMethod.GET, "/xml/{id}", produces = MediaType.APPLICATION_XML_VALUE)
	public Person retrieve(@PathVariable Long id) {
		// ...
	}
}

@Component
public class SpringDataRestCustomization extends RepositoryRestConfigurerAdapter {

  @Override
  public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {

    config.addCorsMapping("/person/**")
        .allowedOrigins("http://domain2.com")
        .allowedMethods("PUT", "DELETE")
        .allowedHeaders("header1", "header2", "header3")
        .exposedHeaders("header1", "header2")
        .allowCredentials(false).maxAge(3600);
  }
}
2016-10-28 14:19:26 +02:00
Oliver Gierke
19aa41926a DATAREST-929 - Polishing.
Some formatting.
2016-10-26 11:50:30 +02:00
Oliver Gierke
b4f99b83a0 DATAREST-929 - EnumTranslatingDeserializers now handles container types correctly.
When translating enumerations, we now inspect the property and use a container type's value type as translation target.
2016-10-26 11:50:27 +02:00
Oliver Gierke
a516d8e61f DATAREST-575 - Fixed property lookup in MappedProperties.
Previously, MappedProperties didn't handle Jackson properties correctly, that do not expose a PersistentProperty, e.g. transient ones. That led to potential nullPointerExceptions in clients as the guarding hasPersistentPropertyForField(…) still answered true, as the backing cache contained an entry with a null value. We now skip those properties completely.
2016-10-23 20:36:59 +02:00