Commit Graph

839 Commits

Author SHA1 Message Date
Oliver Gierke
7d44b1ecab 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 14:41:58 +02:00
Oliver Gierke
1bb228df17 DATAREST-502 - Prepare request parameters to enable URI-to-entity resolution for executing searches.
RepositorySearchController now takes all request parameters as MultiValueMap to execute query methods. For parameters mapping to a managed resource we try to interpret the given parameter value as URI to actually trigger the URI-to-entity resolution through the newly registered UriToEntityConverter.

The latter is now registered with the default ConversionService registered so that it's

A lot of cleanups in RepositorySearchController. Removed some obsolete prints to the console to reduce log output during test execution.

Related ticket: DATACMNS-678.
2015-04-07 17:02:16 +02:00
Oliver Gierke
2697c6a2fa 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 16:15:39 +02:00
Oliver Gierke
3b55dceef7 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:02 +02:00
Oliver Gierke
a446527da3 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:42:40 +02:00
Spring Buildmaster
829bbdd221 DATAREST-493 - Prepare next development iteration. 2015-03-23 05:36:59 -07: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
Spring Buildmaster
c52b72047f DATAREST-487 - Release version 2.3.0.RC1. 2015-03-05 10:28:07 -08:00
Oliver Gierke
def74e6618 DATAREST-354 - General rewrite of the JSONSchema support.
Significant overhaul of the JSONSchema support. This currently adds the following features:

- Complex nested types are exposed as descriptors with the properties pointing to them whenever necessary.
- Sets are treated as unique collections.
- Enums are handled as expected (enum values are listed).
- Renamings via @JsonProperty are considered.
- @JsonProperty(required = true) is considered and added to required properties.
- Date/time types (legacy Date, JSR-310, ThreeTenBP and Joda Time) are exposed with format "date-time".
- Objects with @JsonValue methods are considered to be rendered as String value.
- Formats and patterns can be manually configured on MetadataConfiguration.

TODOs:

- Implementation polish, JavaDoc
- Automatically inspect ObjectMapper to detect customizations made through Mixins and custom Serializers.
2015-03-05 10:13:47 +01:00
Oliver Gierke
c532bb0d51 DATAREST-485 - Fixed handling of empty requests for RepositoryPropertyReferenceController.createPropertyReference(…).
The test case introduced for DATAREST-482 failed when running against Spring 4.1 generation as the handling of empty request payload changed slightly in 4.1. We now explicitly use required = false to get null handed into the controller and manually default the Resources<Object> in it.

Related tickets: DATAREST-482, SPR-12778.
2015-03-03 09:49:38 +01:00
Oliver Gierke
8cbd952d88 DATAREST-483 - Upgrade to JSONPath 0.9.1 and Spring HATEOAS 0.17.0 snapshots. 2015-03-02 17:41:02 +01:00
Oliver Gierke
8b3b7bac98 DATAREST-482 - Added test cases for MongoDB association handling on PUTs.
Added a test case that verifies associations to stay intact if someone updates the item resource using a PUT. Added a second test case that shows PUTting an empty String with media type text/uri-list results in the associations wiped.
2015-02-26 11:48:08 +01:00
Oliver Gierke
0a542564bc DATAREST-463 - Polishing.
Collapsed if clauses leading to the very same return in RootResourceinformationToAlpsDescriptorConverter. Renamed isExportableProperty(…) to isExportable(…) in JacksonMetadata. Removed commented out code in AssociationLinks. Cleanups in test code.

Original pull request: #160.
2015-02-22 15:23:46 +01:00
Greg Turnquist
8d47fab92c DATAREST-463 - Hide ignored attributes from ALPS metadata.
If @JsonIgnore is applied to either a field or a getter method for an association, then do not expose that property's metadata down from ALPS.

Original pull request: #160.
2015-02-22 15:21:24 +01:00
Oliver Gierke
98fd079b21 DATAREST-469 - Added dedicated resource type for search links.
RepositorySearchController now returns a RepositorySearchesResources so that users can implement a custom ResourceProcessor to augment the list of links exposed for Spring Data repository query methods.
2015-02-09 10:52:37 +01:00
Oliver Gierke
ec2bd0145d DATAREST-471 - Populate Last-Modified headers from auditing information.
We now populate the Last-Modified header for requests to the item resource and search resource invocations that return a single item.
2015-02-04 21:03:57 +01:00
Oliver Gierke
14cee9c94f DATAREST-467 - RepositoryEntityLinks now exposes methods to create links to search resources.
RepositoryEntityLinks now exposes methods to obtain links to all search resources and individual ones, including overloads to pre-expand Pageable and Sort parameters potentially contained in the method signature.

Search links now also contain a projection template variable if the type returned by the query method backing the search resource has projections registered.
2015-01-30 20:46:03 +01:00
Oliver Gierke
ec6ee8e291 DATAREST-470 - Moved to EclipseLink JPA API JAR instead of Hibernate. 2015-01-27 22:21:30 +01:00
Oliver Gierke
fbd803f32a DATAREST-414 - Added retry logic to connect to embedded Cassandra.
The Cassandra tests sometimes cannot to the embedded instance on the CI server. Added a triple retry with a delay of 200ms to work around a potentially slow Cassandra bootstrap.
2015-01-21 15:24:13 +01:00
Oliver Gierke
c67b3e749d DATAREST-461 - Ignore unmapped properties when applying PUT requests.
We now make sure that unmapped properties (e.g. by using @JsonIgnore) are ignored when applying PUT request payloads. To do so we now basically use the merging algorithm used for PATCH requests but make sure we fill up the request payload with explicit null values for all mapped but not contained properties.
2015-01-21 14:44:48 +01:00
Oliver Gierke
1755a82fe2 DATAREST-460 - Polished RepositoryRestMvcConfiguration to fix CGLib proxying.
Made private methods that call @Bean methods protected so that they can become subject to CGLib proxying. Inlined getDefaultedRelProvider().
2015-01-20 10:39:21 +01:00
Neeme Praks
f755987a02 DATAREST-457 - Fixed typo in JavaDoc of BaseUri.
Original pull request: #159.
2015-01-20 08:00:50 +01:00
Oliver Gierke
65f45d6433 DATAREST-448 - RepositoryRestHandlerMapping is now checking for a repository mapping again.
Re-introduced the accidentally removed checks that the resolved handler method actually points to a repository resource.
2015-01-16 14:43:21 +01:00
Oliver Gierke
a2ba4224fb DATAREST-414 - Polishing.
Extracted groups of dependencies into auto-activated profiles to make more visible which dependencies belong to which store. Simplified dependency setup where possible.

General polishing in the test cases added.
2015-01-11 17:53:10 +01:00
Greg Turnquist
a31588cabc DATAREST-414 - Added integration tests for Cassandra.
Original pull request: #158.
2015-01-11 17:52:17 +01:00
Oliver Gierke
f09880ff16 DATAREST-437 - Moved to projections API of Spring Data Commons.
Related tickets: DATACMNS-630, DATACMNS-618.
2015-01-11 16:45:41 +01:00
Oliver Gierke
368b36951a DATAREST-434 - Forward root exception in PersistentEntityResourceHandlerMethodArgumentResolver. 2015-01-08 10:54:38 +01:00
Oliver Gierke
e39d624832 DATAREST-427 - Refactorings in UriToEntityConverter.
Instead of using a DomainClassConverter directly we now use a raw ConversionService in UriToEntityConverter. This allos us to get rid off the bean definitions for UriToEntityConverter and DomainClassConverter. The population of the ConversionService is now taken care of by calling SpringDataWebConfiguration's addFormatter(…) in defaultConversionService().

Added unit tests for UriToEntityConverter.
2015-01-05 13:55:07 +01:00
Oliver Gierke
ca8399316f DATAREST-431 - Switched to Formatters for Point and Distance of Spring Data Commons.
Dropped our Converter implementations for Point and Distance and rather use the ones provided through Spring Data Commons, the addFormatters(…) method of SpringDataWebConfiguration in particular.

Related ticket: DATACMNS-626.
2015-01-05 13:12:52 +01:00
Oliver Gierke
1c2201faa1 DATAREST-427 - Fixed NullPointerException in RepositoryRestExceptionHandler.
Handling HttpMessageNotReadableException in RepositoryRestExceptionHandler previously handed null to the badRequest(…) method resulting in an assertion failure in response(…) eventually. This is now fixed by handing in an HttpHeaders instance.
2015-01-05 12:17:35 +01:00
Oliver Gierke
55cf4cd9e0 DATAREST-429 - Improved handling of custom base paths.
Introduced a new property basePath on RepositoryRestConfiguration to allow a smooth migration to a new non-absolute base path configuration model to customize the URIs under which repository resources are exposed.

We're deprecating the current baseUri property as it previously supported absolute URIs. These are still supported but a warning is logged to ping users to move to the new base path based configuration.

We now use the base path to dynamically augment the mappings detected on our controllers with the path configured.
2015-01-03 16:32:16 +01:00
Oliver Gierke
e2a35e7ce9 DATAREST-424 - Registered HttpMessageConverters now implement Ordered.
To be able to control the order of the HttpMessageConverter beans registered by RepositoryRestMvcConfiguration we now use a dedicated subtype of TypeConstrainedMappingJackson2HttpMessageConverter which additionally implements Ordered.
2014-12-10 19:47:54 +01:00
Oliver Gierke
7c43512d1d DATAREST-423 - Fixed HandlerAdapterSetup to consider ConversionService.
The special RepositoryRestHandlerAdapter we set up for repository invocations didn't consider the ConversionService Spring Data REST sets up. This causes binding issues in case someone wants to override resource handling by declaring an @RepositoryRestController and using a domain type as handler method argument.

We now explicitly configure the RepositoryRestHandlerAdapter to use the ConversionService we set up and equip with Spring Data Commons' DomainClassConverter.
2014-12-09 13:03:08 +01:00
Greg Turnquist
11d02e12bc DATAREST-387 - Separated integration tests for individual stores.
Original pull request: #156.
2014-12-07 15:55:33 +01:00
Christoph Strobl
38d1b81a4d DATAREST-387 - Added integration tests for Spring Data Solr repositories.
Added configuration for setting up an EmbeddedSolrServer instance within a temporary directory. We use a temporary test folder created by JUnit where we copy the required configuration to. The directory will also hold all index data and will be deleted afterwards.

Original pull request: #156.
2014-12-07 15:55:33 +01:00
Oliver Gierke
28db79ef42 DATAREST-421 - Polishing of new exception handling infrastructure.
Removed leftovers from AbstractRepositoryRestController. Renamed GlobalExceptionHandler to RepositoryRestExceptionHandler and minimized visibility of exception handler methods. Restricted application of the exception handler to controllers in the Spring Data REST base package.

Relatted pull request: #155.
2014-12-05 10:27:00 +01:00
kakawait
e13be6badc DATAREST-421 - Extracted @ControllerAdvice class in order to allow easy overriding.
Original pull request: #155.
2014-12-05 10:26:56 +01:00
Oliver Gierke
7f990b006b DATAREST-388 - Improved annotation based event handling.
The annotation based event handling now relies on the type of the first method argument to determine the domain type the handler is interested in. Improved method invocation to not unnecessarily wrap exceptions thrown from them. Changed the test cases to throw a dedicated runtime exception to implicitly test that the 

Renamed LinkSaveEvent to LinkedEntityEvent as it's not only used for save-events for entities. Make use of Methods' USER_METHOD filter. Moved the class into the util package. Removed the UUID converter as Spring's DefaultFormattingConversionService provides it out of the box.

Added missing license headers and JavaDoc. Deprecated Class<?> attributes on handling annotations.

Related pull request: #151.
2014-12-04 20:25:20 +01:00
Spring Buildmaster
7f4c97bf0a DATAREST-418 - Prepare next development iteration. 2014-12-01 04:29:46 -08:00
Spring Buildmaster
aa30ac65ec DATAREST-418 - Release version 2.3.0.M1. 2014-12-01 04:29:44 -08:00
Oliver Gierke
a32d1867b4 DATAREST-160 - Polished support for ETag headers based on version properties.
Introduced a dedicated value object for ETags and moved the logic of ETagValidator into it. Switched from an annotation based injection model to a type based one.

The HTTP status code for a non-matching ETag is now 412 Precondition failed as the HTTP specification suggests.

Original pull request: #148.
2014-11-28 22:23:59 +01:00
Pablo Lozano
8fe634cb0d DATAREST-160 - Added support for ETag/If-Match based on entity's version property.
Original pull request: #148.
2014-11-28 22:23:59 +01:00
Oliver Gierke
4b6e5bffc3 DATAREST-417 - Adapt to type reorganization in Spring Data Commons. 2014-11-25 11:37:56 +01:00