Commit Graph

839 Commits

Author SHA1 Message Date
Oliver Gierke
4e0d0e4df1 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:07:25 +02:00
Greg Turnquist
45d1e4d9f4 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:07:25 +02:00
Oliver Gierke
ec0590ff51 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 14:45:24 +02:00
Greg Turnquist
b359aba77a 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:45:24 +02:00
Fabian Trampusch
f180a3ef1a 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:27 +02:00
Oliver Gierke
3ac3c0b828 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:46:01 +02:00
Oliver Gierke
12121f842e DATAREST-621 - Introduced RepositoryRestConfigurer for less invasive customization of Spring Data REST.
We now expose a RepositoryRestConfigurer interface that carries all configure… methods that exist on RepositoryRestMvcConfiguration. The latter are deprecated as of now in favor of implementing and declaring a RepositoryRestConfigurer bean (or extending RepositoryRestConfigurerAdapter for convenience).

Moved extensions of RepositoryRestMvcConfiguration to RepositoryRestConfigurerAdapter where possible.
2015-07-21 17:42:11 +02:00
Oliver Gierke
1e9e3f5635 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:42:14 +02:00
Oliver Gierke
14db3d5f63 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-16 14:16:48 +02:00
Oliver Gierke
f30c0f17b4 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:31:32 +02:00
Antoine Vandecreme
f368be8b68 DATAREST-539 - Log exception even if it has no message. 2015-07-09 18:55:57 +02:00
Oliver Gierke
bd0483f5e6 DATAREST-597 - Improved AlpsJsonHttpMessageConverter for Spring 4.2 compatibility.
AlpsJsonHttpMessageConverter now implements ResponseBodyAdvice to apply the potentially necessary conversion from RootResourceInformation to Alps to make sure we also get it applied on latest Spring 4.2 snapshots that invoke a newly introduced method to handle generic types in Jackson marshaling.
2015-07-09 17:58:38 +02:00
Oliver Gierke
f8c7a1c376 DATAREST-609 - Removed server-side template expansion for incoming URI mapping.
Previously we leniently expanded incoming URIs prior to mapping them to controllers. As the original ticket describes, this can cause security issues in rather lenient security setups as the call might bypass a simple security rule but then eventually map to a URI mapped to a stricter security rule.

Made sure that self links now return canonical URIs instead of templates. To still advertise projections, PersistentEntityResourceAssembler now adds an additional link to the canonical resource to resources that contains the unexpanded template.

Switched from requiring a Repositories instance to PersistentEntities on the way.

Related tickets: DATAREST-267, DATAREST-268, DATAREST-300, DATAREST-318, SEC-3027.
2015-07-06 17:23:35 +02:00
Oliver Gierke
b5c95ae3d6 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:48:22 +02:00
Greg Turnquist
70f35cd314 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:08 +02:00
Oliver Gierke
7f1799832d DATAREST-327 - Polishing.
Moved Spring Security specific dependencies to a dedicated profile in pom.xml. JavaDoc polishing. Removed assertions on the response message.

Original pull request: #171.
2015-06-23 18:11:12 +02:00
Greg Turnquist
ea8baf642b DATAREST-397 - Added integration tests to verify Spring Data REST working with Spring Security.
Added integration tests to verify Spring Data REST works with Spring Security as expected. Added method level security to sample repositories and verified HTTP responses to consider those.

Added some words on security configuration in the reference documentation. This is also demonstrated by some canonical samples found in [0].

Original pull request: #171.

[0] https://github.com/spring-projects/spring-data-examples/issues/21
2015-06-23 18:11:12 +02:00
Oliver Gierke
84aaa063b4 DATAREST-585 - Improvements in SpelAwareProxyProjectionFactory setup.
We now forward the ApplicationContext as ResourceLoader into the SpelAwareProxyProjectionFactory to make sure we use the correct class loader in a Spring Boot Dev Tools environment.
2015-06-19 13:19:07 +02:00
Oliver Gierke
e4cf6d9f23 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. Using guava property from Spring Data Build now.
2015-06-19 12:43:47 +02:00
Oliver Gierke
abd85f9e8a 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:05:55 +02:00
Oliver Gierke
6831e18cde DATAREST-583 - RepositoryRestMvcConfiguration now forwards Environment and ResourceLoader to AnnotatedTypeScanner. 2015-06-18 17:53:01 +02:00
Oliver Gierke
290c1886f0 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:31 +02:00
Spring Buildmaster
42fc85afdc DATAREST-563 - Prepare next development iteration. 2015-06-02 01:58:14 -07:00
Spring Buildmaster
0604e7b876 DATAREST-563 - Release version 2.4.0 M1 (Gosling). 2015-06-02 01:58:12 -07:00
Oliver Gierke
e4277378a0 DATAREST-553 - Polishing.
Removed obsolete logger in RepositoryRestConfiguration. Removed obsolete Commons IO dependency from POM.

Original pull request: #178.
2015-06-01 13:38:34 +02:00
Greg Turnquist
07986acc54 DATAREST-553 - Removed RepositoryRestConfiguration.setBaseUri(…).
Updated existing unit tests to use setBasePath. Added extra assertion to setBasePath to guard against sending in a URI with a protocol.

Original pull request: #178.
2015-06-01 13:38:34 +02:00
Oliver Gierke
018fa22593 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:56 +02:00
Oliver Gierke
d8ebdc3a15 DATAREST-551 - Re-enabled Cassandra integration tests.
Related tickets: DATAREST-532.
2015-05-19 19:14:43 +02:00
Oliver Gierke
f2d8a996bc 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:56 +02:00
Oliver Gierke
a7b672a64a DATAREST-549 - Added @JsonIgnore to RepositorySearchesResource.getDomainType(). 2015-05-18 19:55:26 +02:00
Oliver Gierke
17305f4067 DATAREST-479 - Empty collections now render a dedicated _embedded property.
Instead of rendering an empty _embedded document for empty collections and pages we now explicitly trigger the creations of an EmbeddedWrapper for that empty, collection to preserve the collection's element type.

Tweaked ResourceProcessorHandlerMethodReturnValueHandler to invoke ResourceProcessor instances for those empty collections, too. PRHMRVH now checks the assignability of the raw resource type before analyzing the value type for a match.

RepositorySearchController now adds additional self links for the list of searches and a search execution.
2015-05-18 19:55:23 +02:00
Andy Wilkinson
f1e928a744 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:20:58 +02:00
Oliver Gierke
ffed3c6d7e 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:34 +02:00
Oliver Gierke
70a248870d 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:13 +02:00
Oliver Gierke
6c44a60280 DATAREST-534 - RepositorySchemaController now also matches non-explicit schema requests. 2015-05-07 14:19:45 +02:00
Oliver Gierke
4bc0f0cc4c DATAREST-532 - Temporarily deactivate Cassandra integration tests. 2015-05-06 16:09:11 +02:00
Oliver Gierke
cd82411169 DATAREST-521 - Re-added accidentally dropped existing links.
The LinkCollector introduced in previous commits accidentally dropped links already existing on the Resource.
2015-04-19 13:52:16 +02:00
Oliver Gierke
9bba615d79 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:05 +02:00
Oliver Gierke
6b910fe06f DATAREST-521 - Removed toString() output from test cases. 2015-04-16 09:25:27 +02:00
Oliver Gierke
bba665cef4 DATAREST-521 - Excerpts now contain all links of the projection target.
Extended the serialization capabilities to explicitly treat projection proxies by wrapping them into a ProjectionResource and collecting links for the target backing the projection if the target is an exported resource.
2015-04-16 09:15:48 +02:00
Oliver Gierke
dd398c8011 DATAREST-519 - RepositoryEntityLinks now adds existing Pageable and Sort. 2015-04-14 22:27:04 +02:00
Oliver Gierke
3537bbd20b DATAREST-518 - MappingResourceMetadata is now not exported by default. 2015-04-14 22:27:02 +02:00
Oliver Gierke
85ced098c6 DATAREST-293 - Added new module to easily add a HAL browser to Spring Data REST apps.
Added a module that repackages the webjar version of the HAL browser. The repackaging is necessary to be able to control the exposure of the browser dynamically and prevent Spring Boot's auto-exposure of webjars from kicking in.

Tweaked BasePathAwareHandlerMapping to default the Accept header to the one defined in the configuration if none is present in the request or */* is given. This will make sure we default to a JSON dialect in case no header is set.
2015-04-14 18:13:02 +02:00
Oliver Gierke
9a77f20bf4 DATAREST-517 - Null query results are now translated into 404.
We now explicitly handle null query execution results by returning 404 Not Found.
2015-04-13 13:34:16 +02:00
Oliver Gierke
47d369608b 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:27:29 +02:00
Oliver Gierke
7c3b93fffd 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 08:38:44 +02:00
Oliver Gierke
bb933237b0 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:18:54 +02:00
Oliver Gierke
72647464c6 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 15:54:14 +02:00
Oliver Gierke
c412bc3a76 DATAREST-514 - Fixed resource exposure for customized associations.
We no correctly handle the customized association path if @RestResource is used on an association. Took the chance to refactor the resource mapping subsystem quite significantly to improve the handling of property mappings. Those had been externalized before.
2015-04-10 16:08:51 +02:00
Oliver Gierke
d30883c0ad 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:35:21 +02:00