Commit Graph

375 Commits

Author SHA1 Message Date
Oliver Gierke
ea70ba51f4 DATAREST-661 - Fixed non-existant resource detection for PATCH requests.
PATCH requests to non existing resource now correctly return 404 Not Found as PersistentEntityResourceHandlerMethodArgumentResolver.read(…) now correctly throws the ResourceNotFoundException.
2015-08-28 11:03:37 +02:00
Oliver Gierke
006c8b777a DATAREST-647 - Removed unnecessary lookup of the entity to update.
RepositoryEntityController.patchItemResource(…) triggered an additional, unnecessary lookup of the original entity to be updated. However the resolution algorithm for PersistentEntityResource already checks the presence and rejects an invalid identifier with a ResourceNotFoundException.

PersistentEntityResource now carries a boolean flag to expose whether the entity is about to be created. That allows us to avoid the additional lookup in the method handling PUT requests, too.

Related tickets: DATAREST-441.
2015-08-18 17:35:28 +02:00
Greg Turnquist
1bd4e6c7cc DATAREST-632 - Fixed gap in JSON Schema unit tests.
Consolidated constraint tests for JSON Schema test for User and Profile.

Original pull request: #192.
2015-08-04 02:02:32 +02:00
Oliver Gierke
f020127ad7 DATAREST-631 - Polishing.
Moved just introduced test case into PersistentEntityToJsonSchemaConverterUnitTests. Added ticket reference. Removed obsolete test case.

Original pull request: #190.
2015-07-31 16:10:26 +02:00
Greg Turnquist
658c9ff0d8 DATAREST-631 - Expose id attributes with JSON Schema metadata if configured.
The JSON Schema we expose now considers the owning type for configuration to expose the identifier. Previously, we erroneously checked the property type.

Original pull request: #190.
2015-07-31 16:09:42 +02:00
Oliver Gierke
a1d6b6db62 DATAREST-630 - Polishing.
Simplified implementation change. Integrated new test case into the existing one. Cleaned up existing test case to always use TestMvcClient.

Original pull request: #189.
2015-07-31 15:03:30 +02:00
Greg Turnquist
1f9dc1a646 DATAREST-630 - ALPS metadata now only exposes identifier property if explicitly configured to.
The ALPS metadata exposed now considers the id exposure configuration to decide whether to skip the identifier property or not.

Original pull request: #189.
2015-07-31 14:55:57 +02:00
Spring Buildmaster
90fe5f7007 DATAREST-628 - Prepare next development iteration. 2015-07-28 07:25:01 -07:00
Spring Buildmaster
bd70e6e133 DATAREST-628 - Release version 2.3.2.RELEASE (Fowler SR2). 2015-07-28 07:24:54 -07:00
Fabian Trampusch
480bd60a79 DATAREST-619 - Fixed HTTP method mentioned in Javadoc of RepositoryEntityController.patchItemResource(…).
Previously the Javadoc for said method mentioned PUT as the mapped HTTP method while it's actually PATCH.

Original pull request: #188.
2015-07-27 16:05:47 +02:00
Oliver Gierke
436a1fb9b9 DATAREST-605 - Fixed processing of Maps in DomainObjectReader.
We now post-process Map values recursively to make sure they get merged correctly if they're complex objects in turn.

Improved the exception message for invalid payloads for JSON Patch requests to indicate the expected payload as the root Jackson exception does not contain any hints to what's actually expected.
2015-07-22 17:47:12 +02:00
Oliver Gierke
4d8ba0bdae DATAREST-622 - Removed unnecessary wrapping of embeddeds.
We now use a plain collection of EmbeddedWrapper instead of a Resources to avoid the links contained in the Resources to potentially cause issues on rendering.
2015-07-21 11:59:04 +02:00
Oliver Gierke
da5237538f DATAREST-617 - Fixed content negotiation for requests with Accept: application/*+json.
We now tweak the ProducesRequestConditions for repository controllers to implicitly declare a produces clause of application/*+json to make sure the more concrete produces declarations on methods creating the compact representation are only used as fallbacks.
2015-07-19 13:13:07 +02:00
Oliver Gierke
47693ba5b5 DATAREST-377 - UriStringDeserializer now falls back to null in case of an empty or null source.
UriStringDeserializer now explicitly checks the source JSON value to be null or empty and returns null right away. Previously it handed the value to UriTemplate without any further validation which caused assertion errors in case of an empty or null source.

We now also explicitly catch the IllegalArgumentException thrown from the UriTemplate to make sure that any failure creating a URI (usually from piping a JSON object into the serializer where a URI is expected) is rejected with an appropriate error message.
2015-07-13 08:29:24 +02:00
Antoine Vandecreme
4b3d4dce8b DATAREST-539 - Log exception even if it has no message. 2015-07-09 18:56:17 +02:00
Spring Buildmaster
14a2e9f464 DATAREST-603 - Prepare next development iteration. 2015-06-30 05:17:46 -07:00
Spring Buildmaster
f6142d9400 DATAREST-603 - Release version 2.3.1.RELEASE (Fowler SR1). 2015-06-30 05:17:44 -07:00
Oliver Gierke
a21a1f3fd2 DATAREST-454 - Reverted to usage of plain Strings for HTTP headers.
Spring 4.0.9 does not include the constants for HTTP headers whose usage was introduced in 46b08. Reverted to use the String equivalents.

Original pull request: #184.
2015-06-30 14:11:46 +02:00
Oliver Gierke
1ebc47dba0 DATAREST-454 - Polishing.
Improved example headers to not expose we're referring to test code. Used inline code instead of bold for technical terms (HTTP methods, HTML attributes etc.).

Original pull request: #184.
2015-06-25 11:47:52 +02:00
Greg Turnquist
46b08b9fe5 DATAREST-454 - Document conditional operations.
Added documentation of ETag and Last-Modified header handling with Spring Data managed domain types.

Original pull request: #184.
2015-06-25 09:54:14 +02:00
Oliver Gierke
4294e9ec9a DATAREST-588 - Tweak ResourceSupportHttpMessageConverter to really reject all non-configured types.
We now override canRead(Type, Class<?>, MediaType) and tweak some of the delegate to reflect the patch in Spring HATEOAS spring-hateoas/#360 but without having to upgrade to the new version.
2015-06-24 17:26:15 +02:00
Oliver Gierke
fcb55865bf DATAREST-577 - Removed obsolete dependency to configuration from RepositoryResourceMappings.
This avoids a cyclic dependency between the configuration and the mappings that caused bootstrap issues.
2015-06-19 12:40:42 +02:00
Oliver Gierke
e6f5d9bbd8 DATAREST-584 - Polished dependency setup to mitigate differing dependency versions.
Declare Commons IO explicitly to make sure we use a version matching both Neo4j and Solr. Extracted Guava version into property.
2015-06-19 12:37:42 +02:00
Oliver Gierke
1417287b2b DATAREST-581 - Fixed ETag calculation for projected item resources.
Instead of using the PersistentEntityResource to obtain the ETag we now calculate headers based on the domain object and PersistentEntity upfront. This prevents the failure of trying to read the ETag from a potentially projected proxy.
2015-06-18 19:06:21 +02:00
Oliver Gierke
3e0402b70b DATAREST-577 - Excerpt projections are now configured automatically.
Excerpt projections defined in @RepositoryRestResource had to be discoverable (i.e. located in a sub-package of the domain type). RepositoryRestMvcConfiguration now uses an newly introduced constructor of ProjectionDefinitionConfiguration that automatically registers all projects in the given ResourceMappings.
2015-06-16 15:24:44 +02:00
Oliver Gierke
a07697ef34 DATAREST-556 - Fixed JsonNode handling for PUT/PATCH with a custom field naming strategy.
The preparation of the JsonNode that we map onto the domain object now correctly looks up fields by their mapped names. Previously we accidentally checked the incoming JSON for fields with raw unmapped property names with caused fields invalid detected or not detected if a custom Jackson naming strategy was in place.
2015-05-26 18:03:38 +02:00
Oliver Gierke
08bb44133a DATAREST-523 - Re-enabled POST for collection based association resources.
We now support augmenting elements of a collection resource by using POST which previously only worked with PATCH requests. Took the chance to clean up RepositoryPropertyReferenceController by quite a bit and refactor functionality to discover the supported HTTP methods for a PersistentProperty into RootResourceInformation.
2015-05-19 15:36:31 +02:00
Andy Wilkinson
11c8220377 DATAREST-538 - Expose Jackson converter beans as being TypeConstrained…Converters.
Previously, RepositoryRestMvcConfiguration exposed its two ResourceSupportHttpMessageConverter beans as MappingJackson2HttpMessageConverters. This made it impossible for Spring Boot support for conditional beans to identify that they were type-constrained and, therefore, were not a suitable replacement for a general-purpose Mapping Jackson2HttpMessageConverter bean.

This commit updates RepositoryRestMvcConfiguration to expose both of its Jackson message converters as TypeConstrinaedMappingJackson2HttpMessageConverter instances. This will also Spring Boot to identify that their converters are type-constrained so that it can continue to auto-configure its general purpose converter. This is important as it allows Boot to provide a converter that honors the user’s configuration rather than Spring MVC’s default converter which does not. See spring-projects/spring-boot#2914 for details.

Original pull request: #174.
2015-05-14 17:21:12 +02:00
Oliver Gierke
aecc0aa26a DATAREST-537 - Fixed removing array elements in JSON Patch operations.
Before replacing the remove operation with a custom one that nulls out the object, we check whether the JSON Pointer points to an array element. If that's the case we skip the replacement and proceed.
2015-05-09 16:43:45 +02:00
Oliver Gierke
f05a6baf11 DATAREST-531 - JSON Schema now exposes read-only fields.
Properties considered read-only are now explicitly marked as such in the JSON Schema output we render.

Related tickets: DATAREST-530.
2015-05-07 19:19:31 +02:00
Oliver Gierke
9cc609af97 DATAREST-522 - Improved exception handling in DelegatingHandlerMapping.
We now also handle HttpRequestMethodNotSupportedException and UnsatisfiedServletRequestParameterException and traverse the chain before eventually rejecting the mapping attempt with the last exception found.

Related tickets: DATAREST-409.
2015-04-17 14:52:24 +02:00
Oliver Gierke
bc04809bcf DATAREST-519 - RepositoryEntityLinks now adds existing Pageable and Sort. 2015-04-14 22:23:12 +02:00
Oliver Gierke
28e0ef76d1 DATAREST-516 - Fixed link to ALPS representation descriptors of associations.
Previously the link pointing to representation descriptors of associations neither pointed to the ALPS controller nor to the representation descriptor.
2015-04-13 13:30:33 +02:00
Oliver Gierke
d70851cda8 DATAREST-511 - Support for executing repository methods returning Optionals.
Added an UnwrappingRepositoryInvokerFactory that transparently unwraps JDK 8 and Guava Optionals to make sure the consuming code works with values or plain nulls correctly.
2015-04-13 09:29:33 +02:00
Oliver Gierke
49bad45b5f DATAREST-506 - NotModified responses now return headers, too.
Responses for item resources that result in 304 Not Modifier now also return the headers they'd return if a 200 Ok would've been returned.
2015-04-12 18:44:26 +02:00
Oliver Gierke
ba9f1b36ab DATAREST-515 - RepositorySearchesResource now exposes domain type.
RepositorySearchesResource now exposes the domain type for whom the searches are listed to allow implementations of ResourceProcessor add links by type more easily.
2015-04-11 16:48:42 +02:00
Oliver Gierke
3831479aca DATAREST-507 - Fixed IllegalArgumentException in RepositoryRestExceptionHandler.
A lot of cleanups in RepositoryRestExceptionHandler: prefer static methods where possible. Removed delegates where only one client was calling the method. Consistent argument ordering with optional (nullable) parameters last.

Silenced logging in unit tests for RepositoryRestExceptionHandler.
2015-04-08 17:39:48 +02:00
Oliver Gierke
3d1ac0c461 DATAREST-506 - Support for conditional GETs on item resources.
We now inspect If-None-Match and If-Modified-Since headers on GET requests to item resources and return 304 Not Modified if appropriate.

Disable rendering of version property in Jackson serializer as it's reflected in the ETag.

Related tickets: DATAREST-160, DATAREST-471.
2015-04-08 15:11:13 +02:00
Oliver Gierke
5895b5e692 DATAREST-302 - Rendering projections includes/keeps links.
We now treat embedded projections as Resource instances and equip them with a self link. This should also allow to register ResourceProcessor instances for projection types to even add projection specific links if necessary.

Also removed the explicit removal of the association link in case a projection is rendered for an association.
2015-04-02 17:03:11 +02:00
Oliver Gierke
1da9808edb DATAREST-500 - Enable lazy-loading proxy resolution on Hibernate 4 module.
We now explicitly activate the resolution of lazy-loading proxies on Hibernate 4 to make sure not already populated lazy-loading proxies are actively resolved.
2015-03-30 21:31:16 +02:00
Oliver Gierke
977ccb1a36 DATAREST-498 - IncomingRequest now correctly evaluates parameterized media types.
IncomingRequest.isJsonPatchRequest()/….isJsonMergePatchRequest() previously did a hard equals comparison to the media type discovered in the request. This fails if the request's media type contains parameters (e.g. the charset).

We now rather use MediaType.isCompatibleWith(…) to compare the media types more leniently.

Renamed test case to match conventions so that the Maven build actually executes them.
2015-03-30 10:50:46 +02:00
Spring Buildmaster
b65c4de7af DATAREST-493 - Prepare next development iteration. 2015-03-30 10:49:31 +02:00
Spring Buildmaster
338047fd62 DATAREST-493 - Release version 2.3.0.RELEASE (Fowler GA). 2015-03-23 05:36:57 -07:00
Oliver Gierke
c12009337b DATAREST-494 - ALPS metadata now links to JSON Schema.
The ALPS document rendered now links to the JSON Schema document from within the core representation descriptor to allow clients to obtain more detailed information about the payloads to send and receive.
2015-03-23 08:49:48 +01:00
Oliver Gierke
e5ce6156f9 DATAREST-492 - Fixed JSON Schema type detection for primitive numbers.
We now correctly detect primitive numbers in domain objects so that the JSON Schema type of the property is number as expected.
2015-03-22 20:06:43 +01:00
Oliver Gierke
f80bebf04b DATAREST-491 - Fixed handling of non-entity maps in JSON processing.
During our custom JSON handling on PUT requests, we previously piped all JSON objects through code that expected that one to be mapped to a PersistentEntity. This fails for JSON objects that basically represent maps.

We now skip that code paths for non-entity properties.
2015-03-20 09:42:36 +01:00
Oliver Gierke
5486712b1b DATAREST-34 - Polishing.
Moved decision logic on whether to return response bodies int RepositoryRestConfig to ease testability of the controller. Added more unit tests and simplified the controller integration tests accordingly. Had to deactivate some Cassandra related tests as they don't seem to handle nulling of properties correctly.

Changed configuration to rely on the presence of the Accept header by default. Deprecated parameterless isReturnBodyFor…(…) methods in favor of the ones taking the Accept header to avoid the null checks on the calling side.

Polished JavaDoc for the isReturnBodyOn(Create|Update) methods. Polished formatting in RepositoryEntityController.

Original pull request: #167.
2015-03-20 08:50:47 +01:00
Jeremy Rickard
f3c74ac9db DATAREST-34 - PUT and POST request now consider Accept header by default.
By default, whether to return response bodies for PUT and POST is determined by the presence of an Accept header, unless explicitly activated or deactivated in RepositoryRestConfiguration.

Original pull request: #167.
2015-03-20 08:50:30 +01:00
Oliver Gierke
4f8298c711 DATAREST-490 - Makes sure content negotiation works for manual resource overrides with dedicated media type.
In case a manually implemented controller is registered to add a dedicated media type for a Spring Data REST resource (e.g. an HTML representation for item resources) we now continue to serve JSON in case the request indicates it wants to see it.

Previously this didn't work as the manually implemented controller method was detected to partially match (only the produces-clause not matching) and thus an exception being thrown from the HandlerMapping lookup. This caused the HandlerMapping registered for repositories not being considered at all.

This is now fixed by hiding the HandlerMapping instances we register behind a DelegatingHandlerMapping that continues to try delegates even in a case of an exception being caused in a particular resolution attempt. Should all resolution attempts fail, we then throw the original exception if one occurred in the first place.
2015-03-11 15:14:00 +01:00
Spring Buildmaster
7b53546236 DATAREST-487 - Prepare next development iteration. 2015-03-05 10:28:08 -08:00