250 Commits

Author SHA1 Message Date
Oliver Gierke
216686c2b6 DATAREST-330 - Exposed resources now support HEAD requests where reasonable.
The collection and item resources as well as the search and query method resources now answer HEAD requests according to the repository definition.
2014-06-24 18:34:09 +02:00
Spring Buildmaster
c6c1801980 DATAREST-322 - Prepare next development iteration. 2014-06-18 05:33:31 -07:00
Spring Buildmaster
c5b84075e8 DATAREST-322 - Release version 2.0.3.RELEASE (Codd SR3). 2014-06-18 05:33:29 -07:00
Oliver Gierke
dfa249795a DATAREST-318 - BaseUri now correctly strips template variables from request.
Bugfix in BaseUri to correctly strip template variables when the repository lookup path is obtained from a NativeWebRequest.
2014-06-12 12:45:45 +02:00
Oliver Gierke
4843a81fff DATAREST-316 - UriStringDeserializer now guards against UriTemplate.
We now defensively guard against URI templates submitted for related resources and expand the incoming URI string source to avoid URI.create(…) to fail.

Also, RepositoryPropertyReferenceController.loadPropertyValue(…) now also uses UriTemplate to guard against Uri templates provided for property references.
2014-06-12 12:44:05 +02:00
Rodrigue Bouleau
9e2d8f674e DATAREST-311 - Fixed execution of query methods for compact media type.
Fixed the request parameter binding of RepositorySearchController. executeSearchCompact(…). Changed returned value to Resources to be able to use the EMPTY_RESOURCES_LIST constant to indicate no actual results.

Original pull request: #139.
2014-06-02 12:04:54 +02:00
Oliver Gierke
77cf175b26 DATAREST-301 - Fixed location header creation for self links containing URI templates.
We now consistently expand the self links created before adding them as location header to make sure we can create a URI instance successfully.
2014-05-06 12:17:50 +02:00
Oliver Gierke
c20bfa520e DATAREST-300 - BaseUri now removes URI template variables from lookup path.
BaseUri now strips away the tail of a lookup path starting with {. An unencoded { must never appear in a URI but could accidentally be sent by a client forgetting to expand URI templates we return.
2014-05-05 14:09:50 +02:00
Oliver Gierke
6729e7e07c DATAREST-276 - Yet another round of trailing slash handling.
We need to proactively strip trailing slashes during base URI handling as even on a successful match (which previously left trailing slashes intact) this might subsequently on the resolving of the repository metadata when evaluating the left-over lookup path against the @RequestMapping methods (which keeps trailing slashes).
2014-05-02 11:19:55 +02:00
Oliver Gierke
a4d5b2ce23 DATAREST-276 - Improved BaseUri to accomodate trailing slashes.
We now strip trailing and leading slashes from configured base URI to make sure the matching algorithm accommodates both lookup paths with and without trailing slashes.

Added a few more tests in shape of unit tests for BaseUri.
2014-05-01 14:47:58 +02:00
Oliver Gierke
ef0b55590e DATAREST-276 - Improve base URI handling.
Introduced BaseUri value object being able to extract the lookup path within the Spring Data REST URI namespace from requests and plain lookup paths. This encapsulates the logic we previously had in RepositoryRestHandlerMapping but it is needed in the HandlerMethodArgumentResolver implementations as well to make sure they extract RepositoryMetadata correctly.
2014-04-30 14:59:28 +02:00
Oliver Gierke
a79cbb7a48 DATAREST-276 - Fixed ArrayIndexOutOfBoundsException in RepositoryRestHandlerMapping.
We now make sure the RepositoryRestHandlerMapping correctly refrains from handling the request in case the URI doesn't match the configured base URI.
2014-04-30 13:38:23 +02:00
Oliver Gierke
061bd2aa53 DATAREST-276 - RepositoryRestHandlerMapping now works with absolute base URIs.
Refined the algorithm to detect the lookup path within the configured base URI, even if the base URI was defined in an absolute way. Also, solidified the implementation against URIs with trailing slashes.
2014-04-29 16:45:11 +02:00
Oliver Gierke
29c16a0e74 DATAREST-292 - Fixed application of configured base URI.
Major overhaul of mapping detection in RepositoryRestHandlerMapping. We now correctly map URIs if a base URI is configured via RepositoryRestConfiguration.

Additional tweaks needed for the back-port.
2014-04-24 09:58:58 +02:00
Spring Buildmaster
0c3748c3c4 DATAREST-291 - Prepare next development iteration. 2014-04-16 11:13:35 +02:00
Spring Buildmaster
389212e186 DATAREST-291 - Release version 2.0.2.RELEASE (Codd SR2). 2014-04-16 02:03:11 -07:00
Oliver Gierke
286267951b DATAREST-288 - Removed javax.validation dependency from schema controller. 2014-04-10 12:08:35 +02:00
Spring Buildmaster
be719d599a DATAREST-258 - Prepare next development iteration. 2014-03-13 09:35:18 -07:00
Spring Buildmaster
4aa1b6f10e DATAREST-258 - Release version 2.0.1.RELEASE (Codd SR1). 2014-03-13 09:35:15 -07:00
Oliver Gierke
a7d80e0709 DATAREST-258 - Mitigate changes in Spring Data Neo4j 3.0.1.
We now explicitly set a base backage in the Neo4jConfiguration to make sure, the domain classes get added to the MappingContext upfront. Filed DATAGRAPH-448 [0] for some reasonable defaulting going forward.

[0] https://jira.spring.io/browse/DATAGRAPH-448
2014-03-13 17:24:58 +01:00
Oliver Gierke
6ca349a08f DATAREST-271 - Fixed application of pagination customizations.
The configuration of HateoasAwarePageableHandlerMethodArgumentResolver now gets the customizations made in RepositoryRestConfiguration applied.
2014-03-13 08:53:48 +01:00
Oliver Gierke
11b94b9d1a DATAREST-247 - RepositorySearchController now returns primitive results as is. 2014-03-11 19:33:12 +01:00
Oliver Gierke
d5d7478d04 DATAREST-268, DATAREST-267 - Controllers now ignore URI template variables submitted.
When parsing the id value from a URI we now pipe the obtained segment through Spring HATEOAS' UriTemplate to potentially remove optional tempalte variables. These variables might make it into the URI by clients that do not properly expanding URI templates before submitting requests. 

This is effectively a backport of parts of the fix for DATAREST-155 in master.
2014-03-11 18:11:17 +01:00
Greg Turnquist
227618d81b DATAREST-150 - Added test case showing PUT now works correctly.
The JIRA issue asserts that PUT wasn't properly storing things. But now it does. A partial record causes all other fields to get nulled out. Added a test case to confirm this.

Original pull request: #134.
2014-03-11 10:44:08 +01:00
Oliver Gierke
aa5316fb69 DATAREST-261 - Fixed RepositoryRelProvider registration.
We now register a RepositoryRelProvider that hadn't been exported before so that clients using a RelProvider will automatically see potentially customized rels for repositories.

Changed RepositoryRelProvider to lazily depend on the ResourceMappings as will be requested eagerly for injection into the configuration class itself.
2014-02-27 14:53:24 +01:00
Oliver Gierke
f409106139 DATAREST-253, DATAREST-254 - Fixed serialization handling of transient properties.
AssociationOmittingSerializerModifier not correctly handles transient properties, which means it's handling null PersistentProperties correctly.

Also, AbstractRepositoryRestController.handleNotReadable(…) is not bound to HttpMessageNotWritableException anymore which caused the former errors to be masked by a Spring MVC exception claiming about the exception handler method not being invokable correctly.
2014-02-25 07:44:11 +01:00
Spring Buildmaster
e5c1ce51c1 DATAREST-249 - Prepare next development iteration. 2014-02-25 07:44:05 +01:00
Spring Buildmaster
fb73b52be7 DATAREST-249 - Release version 2.0.0.RELEASE. 2014-02-24 10:00:15 -08:00
Oliver Gierke
efb4949a57 DATAREST-250 - Moved to List instead of Set to guarantee stable results. 2014-02-24 17:59:45 +01:00
Oliver Gierke
9ac9ca4d86 DATAREST-250 - More integration tests for serializations.
Added further integration tests to make sure serialization of embedded and non-embedded references works for paged resources.
2014-02-23 16:26:09 +01:00
Oliver Gierke
44fda4f8b7 DATAREST-250 - Fixed exposure of inline properties.
Fixed PersistentEntityResource serialization to correctly export associations that are not backed by an exported repository.
2014-02-21 11:53:18 +01:00
Oliver Gierke
3e5914d84f DATAREST-248 - Significant overhaul in entity serialization and deserialization.
Refactored PersistentEntityJackson2Module to move a lot of the customization logic into Bean(De)SerializerModifiers. Those allow to modify the Jackson metadata for a given type programmatically so that we can register the appropriate (de)serializers for associations. 

On the serializing side of things this allows us to easily turn associations into links and simply delegate to object serialization as the delegation will simply ignore the association properties as they have been dropped using the modifier. This solves the advanced requirements of DATAREST-117 nicely as all non-association properties are serialized using standard Jackson means so that all customizations apply.

On the deserialization side, we now support URIs as values for association properties to be able to submit references for non-optional associations on creation.

Related issue: DATAREST-117.
2014-02-19 11:44:46 +01:00
Oliver Gierke
cf41d4b692 DATAREST-117 - Polishing.
Simplified annotation detection. Added ignore guards to the association handling as well, so that associations not pointing to a repository managed resource can be ignored from being rendered as well.

Original pull request: #135.
2014-02-14 17:15:57 +01:00
Greg Turnquist
171ab2583e DATAREST-117 - Added support to detect @JsonIgnore and @JsonIgnoreProperties.
Wrote test cases to verify it handles class level and attribute level annotations to ignore properties when rendering PersistentEntityResources.

Original pull request: #135.
2014-02-14 17:14:44 +01:00
Oliver Gierke
b3b091e309 DATAREST-95 - General overhaul of HTTP method handling.
Code polishing in DomainObjectMerger and related test cases. Fixed the related test cases. Cleanups in ControllerUtils to remove unneeded constants and make sure we really render no content for empty responses.

Refactorings in controller classes to reduce code duplication. We now do not allow POST requests for partial updates to property reference resources anymore but require the usage of PATCH.

Tweaked test helper methods to correctly implement basic interaction patterns.

Related pull request: #127.
2014-02-14 13:25:35 +01:00
Greg Turnquist
d65179ccc8 DATAREST-95 - Add support for PATCH to partially update entities.
Added general support for HTTP PATCH to partially update entities and amend property resources.
2014-02-14 13:08:13 +01:00
Oliver Gierke
922827fe56 DATAREST-217 - Significant overhaul of HTTP method support detection.
Refactored the way the general support for an HTTP method for the resource exported. The decision is implemented in RootResourceInformation (formerly RepositoryRestRequest). Removed request specific information from that class and introduced a HandlerMethodArgumentResolver to be able to inject HttpMethod instance into controller methods (filed https://jira.springsource.org/browse/SPR-11425 to get that support into Spring Framework itself).

Generally moved away from throwing NoSuchMethodExceptions and correctly expose HttpRequestMethodNotSupportedException instead to make sure Spring MVC renders the appropriate allowed methods if possible.

Removed RepositoryInvokerHandlerMethodArgumentResolver as a RepositoryInvoker can be obtained from the RootResourceInformation where necessary.

Related pull request: #125.
2014-02-14 10:26:45 +01:00
Greg Turnquist
ef1ee10940 DATAREST-238 - Changed JSON deserializer to ignore links.
Links are a read-only and basically have to be ignored during any inputs. This required removing the deserializer from PersistentEntityJackson2Module. This will cause the object mapping to fail as it doesn't know about the links property in the request body. Instead of requiring that every entity apply the necessary annotation, the mapper is configured to not fail on non-existent attributes. This allowed all the tests to pass while properly handling PUT operations.

Original pull request: #130.
2014-02-13 12:23:57 +01:00
Oliver Gierke
13d90efbca DATAREST-246 - ValidatingRepositoryEntityListener now uses ObjectFactory<Repository>.
ValidatingRepositoryEntityListener previous referred to a Repositories instance which causes a circular reference on initialization after some changes in Spring Data Commons Repositories.

Major cleanups in the ValidatingRepositoryEntityListener implementation.
2014-02-12 16:03:59 +01:00
Greg Turnquist
6e817c440b DATAREST-50 - Added test case demonstrating this issue no longer exists.
Properties with null values properly get rendered in JSON outputs. This was fixed some time ago. Added test case to prove it.

Original pull request: #132.
2014-02-11 17:49:54 +01:00
Spring Buildmaster
84880ffe5e DATAREST-226 - Prepare next development iteration. 2014-01-29 06:40:33 -08:00
Spring Buildmaster
3a87ad8d49 DATAREST-226 - Release version 2.0.0.RC1. 2014-01-29 06:40:30 -08:00
Oliver Gierke
20a407d40c DATAREST-226 - Prepare 2.0 RC1 release.
Upgraded to Spring Data RC modules, Spring HATEOAS 0.9.0.RELEASE and Spring Plugin 1.0.0.RELEASE. Removed placeholder for Jackson 2 version as it's in the parent build pom now. Switched to milestone repository.
2014-01-29 15:35:46 +01:00
Oliver Gierke
bd8d3afa65 DATAREST-219 - Polishing.
Generally polished implementation and test cases for Greg's contribution.
Re-ordered parameters in ControllerUtils' helper methods for consistency.
Use Spring's CollectionFactory to create a suitable collection for the handled properties in the first place to avoid unnecessary conversion later on.

Removed duplication in test cases. Polished JavaDoc in UriListHttpMessageConverter and moved to a Scanner based implementation to read the request body. 

Adapted to latest changes in Spring HATEOAS. Reactivated ResourceStringUtilsTests.

Related pull requests: #128, #86.
2014-01-24 16:03:22 +01:00
Greg Turnquist
1f0b9bd664 DATAREST-219 - Make editing collection-based properties more efficient
This PR is inspired by #86, but had to be written from scratch because it was over 10 months old when this was undertaken. It was unmergeable.

Essentially, by casting existing collections and then iterating over them and making adjustments should render more efficient back end database operations. Only for a PUT should a new collection be created.

This PR not only updates these operations, but provides test cases to back up these edits, i.e. a test case for POSTing to a collection, PUTing to a collection, and DELETE-ing from a collection.

Adds ability to return an empty response with only the Location header populated by looking at the property update's incoming URL.

Original pull request: #128, #86.
2014-01-24 15:17:38 +01:00
Oliver Gierke
d59ec3bdd4 DATAREST-233 - Introduced @RepositoryRestResource.
@RepositoryRestResource exposes more detailed attributes tailored to the use case of exposing a repository. @RestResource is still recognized on repository interfaces but we now issue a warning and indicate the new annotation to be used.

Introduced a minimal ResourceDescription interface and let @Description be used within @RestResource and @RepositoryRestResource. We now generate default resource bundle keys and resolve them against a "rest-messages" resource bundle by default. JsonSchema converter now uses the rendered descriptions for schema descriptions.
2014-01-24 15:17:14 +01:00
Oliver Gierke
61d3d1c0bf DATAREST-31 - Improved link rendering for search resources.
If the search resource is capable of paging we now augment the link with pagination template variables.
2014-01-23 17:11:40 +01:00
Oliver Gierke
88b2f05edf DATAREST-229 - RepositoryEntityLinks now exposes templated links.
If the resource exposed for a domain or repository type is considered a paging resource we now return a templated URI. Introduced ResourceMapping.isPagingResource() to allow clients to find out about whether the resource is actually capable of pagination. Adapted implementations to inspect the findAll(…) method as well as the search methods for a Pageable parameter.

Tweaked pom.xml to create correct classpaths if the IDE uses direct workspace project references.
2014-01-23 17:11:34 +01:00
Oliver Gierke
9159339960 DATAREST-226 - Upgraded to Spring Data Neo4j 3.0 snapshots. 2014-01-20 13:48:47 +01:00
Oliver Gierke
f02000e619 DATAREST-224 - Introduce Maven POMs.
Adapted JpaWebTests to compile on Java6. Fixed some broken test case in Neo4jWebTests.
2014-01-20 10:18:44 +01:00