Commit Graph

846 Commits

Author SHA1 Message Date
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
Oliver Gierke
6a3a7131ac DATAREST-970 - AnnotationEventHandlerInvoker now considers order of event handler methods.
We now make sure that an @Order annotation on annotated event handler methods are considered and the methods are invoked in the defined order.

Non-annotation-based event handlers don't suffer from the same problem as they're ApplicationListener instances directly so that the container will enforce the correct ordering in case @Order is used or Ordered is implemented.

Some cleanup in EventHandlerMethod.

Original pull request: #248.
2017-01-19 15:05:43 +01:00
Oliver Gierke
99f49532b6 DATAREST-976 - Polishing.
Extracted test for the newly supported sorting scenario so that we now.

Original pull request: #251.
2017-01-16 13:31:45 +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
629ca4e33d DATAREST-979 - Update project documentation with the CLA tool integration. 2017-01-13 11:56:15 +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
130582a263 DATAREST-932 - Updated changelog. 2016-12-21 19:35:32 +01:00
Oliver Gierke
c5cbb25bea DATAREST-862 - After release cleanups. 2016-12-21 16:33:13 +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
729e6476ec DATAREST-862 - Prepare 2.6 RC1 (Ingalls). 2016-12-21 16:19:34 +01:00
Oliver Gierke
9bd5cc878a DATAREST-862 - Updated changelog. 2016-12-21 16:19:31 +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
5269a7d175 DATAREST-793 - RepositoryRestConfiguration's setters return this consistently.
Adapted the return type of setter methods in RepositoryRestConfiguration to consistently return the current instance to allow call chaining.
2016-12-12 16:50:38 +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
cea8c122d3 DATAREST-862 - Fix Querydsl APT setup after compiler plugin update. 2016-12-08 16:04:58 +01:00
Oliver Gierke
f4e4dcb281 DATAREST-862 - Disable manifest lookup after plugin changes in build parent. 2016-12-08 15:07:59 +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
Ken Dombeck
76ddc30533 DATAREST-951 - Fixed example in sample in reference documentation.
Original pull request: #244.
2016-12-06 08:31:39 +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
Lukasz Kryger
080d1b0dab DATAREST-960 - Fixed typos in reference documentation.
Fix typo "returnBodyOnupdate" -> "returnBodyOnUpdate".

Original pull request: #242.
2016-12-02 19:40:45 +01:00
Oliver Gierke
aea766b596 DATAREST-941 - Polishing.
Minor formatting in pom.xml of the HAL Browser module.
2016-11-30 18:19:46 +01:00
Greg Turnquist
9d579532b5 DATAREST-941 - Modify existing browser.html
Instead of replacing the HAL Browser's browser.html, take the existing one and alter it inside the build job. This ensures that future updates don't break so horribly.

Related to https://github.com/mikekelly/hal-browser/pull/89 which will provide an explicit token to match, instead of using the closing `</body>` tag.
2016-11-30 18:04:16 +01:00
Oliver Gierke
262a2a1e1a DATAREST-934 - Updated changelog. 2016-11-23 13:52:47 +01:00
Oliver Gierke
f4705c8197 DATAREST-941 - Upgraded to latest version of the HAL Browser. 2016-11-17 00:03:35 +01:00
Oliver Gierke
63bc492140 DATAREST-915 - Updated changelog. 2016-11-03 18:56:47 +01:00
Oliver Gierke
8fd259dd32 DATAREST-906 - Polishing. 2016-11-03 16:28:33 +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