Commit Graph

52 Commits

Author SHA1 Message Date
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
c662065ef2 DATAREST-216 - Added integration test.
Forgot to commit integration test with 5dd33b.

Related pull request: #126.
2014-02-14 10:26:57 +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
Oliver Gierke
5dd33ba7c0 DATAREST-216 - CrudRepositoryInvoker considers redeclared methods correctly.
CrudRepositoryInvoker now detects re-declared CRUD methods and falls back to reflection invocation if the re-declaration is detected.

Inspired by PR #126 by Nick Weedon but avoiding the introduction of a dependency to Spring Security by using a more precise testing approach.

Original pull request: #126.
2014-02-13 10:28:19 +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
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
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
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
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
Oliver Gierke
4b6f0f620a DATAREST-31 - Search links are now rendered as link templates.
MethodResourceMapping now exposes the parameters a query method expects. The RepositorySearchController the uses these to append the 

Upgraded to Spring Data Commons 1.7.0.BUILD-SNAPSHOT.
2014-01-17 13:28:10 +01:00
Oliver Gierke
5ff6457911 DATAREST-222 - Path now quotes reference before matching.
We now actively quote the String reference to match a path against as it most likely is not a regular expression.
2014-01-17 13:22:04 +01:00
Oliver Gierke
074c77cc3e DATAREST-107 - Polishing test cases.
Extracted DATAREST-107 specific test cases into separate test method.
2014-01-14 10:28:34 +01:00
Greg Turnquist
bc30b74cbe DATAREST-107 - Add tests to verify ambiguous mapping detection. 2014-01-14 10:28:00 +01:00
Phillip Webb
e7ce0e3f0b DATAREST-107 - Respect @RestResource exported flag on query methods.
ResourceMappings now only adds a RepositoryMethodResourceMapping if it's really exported.
2014-01-14 10:18:23 +01:00
Oliver Gierke
7c66a217be DATAREST-130 - Polished test implementation.
JavaDoc, formatting, simplified implementation.
2014-01-14 10:15:53 +01:00
Greg Turnquist
d32e69c1d3 DATAREST-130 - Added test case for DomainObjectMerger. 2014-01-14 10:12:07 +01:00
Oliver Gierke
4e5fa30282 DATAREST-130 - Code polish and JavaDoc. 2014-01-14 10:11:33 +01:00
Willie Wheeler
eafdc4771e DATAREST-130 - Support nulling out properties when doing HTTP PUTs. 2014-01-14 10:11:14 +01:00
Oliver Gierke
af520871dc DATAREST-203, DATAREST-75 - Initial support for HAL.
This commit introduces support for HAL rendering and making it the default rendering option. The configuration now registers an additional MappingJackson2HttpMessageConverter with the according HAL modules registered and makes this the default JSON renderer if the default media type is configured to HAL (which it is by default). To change this, set RepositoryRestConfiguration.setDefaultMediaType(…) back to application/json.

Refactored the PersistentEntityJackson2Module to turn the PersistentEntityResource into it's correct shape (turning associations into links) and the delegate to the default rendering, so that the HAL customizations provided by Spring HATEOAS can kick in. Adapted test cases to the change in default representation format.


Upgraded to Jackson 2.3.0, Spring 3.2.6 and Spring HATEOAS 0.9.0.BUILD-SNAPSHOT. Upgraded to Gradle 1.10.
2013-12-19 16:31:29 +01:00
Oliver Gierke
4ee1850a37 DATAREST-93 - Improvements after API updates in Spring Data Commons.
Switched to the usage of Simple(Property|Association)Handler to avoid having to use raw PersistentProperty instances.
2013-11-14 10:04:28 +00:00
Oliver Gierke
8f2e3eb4fe DATAREST-163 - Fixed rendering of embedded documents for MongoDB.
Removed the attempt to add a link to the response for non-associations. Switched to the usage of Simple(Property|Association)Handlers for simplified generics.
2013-11-14 10:04:28 +00:00
Oliver Gierke
9b4b111d23 DATAREST-93 - Cleanups in repository invoker area.
Made RepositoryInvokerFactory an interface and renamed the previously existing implementation class to DefaultRepositoryInvokerFactory. Removed instantiation of the class from ResourceMetadataHandlerMethodArgumentResolver to keep the logic which implementation to use solely in the configuration.
2013-11-14 10:03:48 +00:00
Oliver Gierke
cb4770db56 DATAREST-162 - PersistentPropertyResourceMapping now considers @RestResource.
PersistentPropertyResourceMapping now inspects the @RestResource annotation on the property if it is present.
2013-11-14 10:03:48 +00:00
Oliver Gierke
6260d3fba9 DATAREST-93 - Code cleanups.
Added missing license header. Polished code in RepositoryEntityController.
2013-10-01 17:41:50 +02:00
Oliver Gierke
9acad5d55d DATAREST-111 - Slightly raised precedence of RepositoryRestHandlerMapping.
Set order of RepositoryRestHandlerMapping to LOWEST_PRECEDENCE - 100 to give core Spring Framework components the chance to hook into the right place in the chain.

Refactored RepositoryRestHandlerMapping to really check for the exposed path and added test cases for handler method resolution.
2013-08-21 12:19:46 +02:00
Oliver Gierke
252efc5196 DATAREST-112 - Moved property mapping into PropertyResourceMapping.
PersistentEntityJackson2Module now entirely relies on the property mapping to do the right thing for link creation. The PropertyResourceMapping now returns the property name for both rel and path.
2013-08-21 10:20:37 +02:00
Oliver Gierke
d2c2ec8262 DATAREST-93 - More cleanups.
Merged core and repository modules into core. Renamed some packages for consistency in naming and in preparation to break up some package cycles. Removed @BaseUri and the according resolver. Refactored controllers a bit to have more reusable chunks of code.
2013-07-24 12:59:23 +02:00
Oliver Gierke
a4d8a22428 DATAREST-93 - Further refactorings and refinements regarding the search resource mapping. 2013-07-12 14:20:32 +02:00
Oliver Gierke
c5a592bd9d DATAREST-93 - Further fixes in repository mappings.
Simplified new RepositoryMappings infrastructure. Integrated EvoInflectionRelProvider to build collection resource rels. Bumped version number to 2.0 as we're going to break backwards compatibility with the next release to straighten out the rel construction and mapping.
2013-06-18 19:17:56 +02:00
Oliver Gierke
5c61632ec2 DATAREST-93 - Fixed formatting in Spring Data REST.
Added formatter to be used within Eclipse going forward.
2013-06-18 16:21:34 +02:00
Oliver Gierke
90c4b62428 DATAREST-93 - Removed compiler warnings.
Removed dependency on jMock.
2013-06-11 15:01:03 +02:00
Oliver Gierke
cb4056e351 DATAREST-94 - Removed dependency to Guava.
Introduced simple Function interface. Replaced usage of Multimap with Spring's MultiValueMap.
2013-06-05 22:13:00 +02:00
Jon Brisbin
6ef500804b Tweak abstract base tests. 2013-03-02 11:50:09 -06:00
Jon Brisbin
6e4e7da142 Incorporated recent changes to Spring Data Commons and dependent projects that obsoleted the need to manage domain object metadata within Spring Data REST. Required updating to the latest snapshots available for spring-data-commons and spring-data-jpa.
Additional changes include:

* Re-wrote the monolithic Controller into separate controller classes that have a more narrow focus.
* Implemented common functionality as a `HandlerMethodArgumentResolver` rather than as a helper method in a controller class.
* Re-implemented JSONP functionality as an HttpMessageConverter rather than inline within a controller class.
* Updated to Jackson 2 for all JSON handling.
* By relying on spring-data-commons, spring-data-rest now handles all supported Repository types: JPA, MongoDB, and GemFire.

Added support for MongoDB and GemFire repositories by relying on spring-data-commons to provide the metadata rather than maintaining internal metadata information that is store-specific.

Replaced Spock spec tests with JMock unit and integration tests. Started integrating Jetty 8 into the testing so MVC testing can be done against a live server.
2013-01-18 10:14:29 -06:00
Jon Brisbin
5cfa242a8d Added package-info 2012-10-17 12:51:23 -04:00
Jon Brisbin
40645673bf Integrated Spring HATEOAS. 2012-08-27 15:16:02 -05:00
Jon Brisbin
3aa8905b15 Added configuration property for domain type to repository mappings. Also improved the post-processing support, though I think there's still some room for tweaking. 2012-08-20 15:06:15 -05:00
Jon Brisbin
d7e2e53ce2 Implemented a new style of JSON serialization and deserialization by registering Repository-aware components with Jackson's underlying ObjectMapper. This has the benefit of allowing us to transliterate domain objects into link representations and back again, no matter where those entities appear in complex nested object graphs. 2012-08-15 14:31:57 -05:00
Jon Brisbin
d2c6ecacc5 Tweaking fluent bean utils by adding fallback to Field access. 2012-08-15 14:28:23 -05:00
Jon Brisbin
3393780e65 DATAREST-37: Display entities inline when accessing relationship links. 2012-08-13 09:32:42 -05:00
Jon Brisbin
7775af8be4 Changing the representation to be more consistent in key naming (breaking change). Also starting work on the ability to "enrich" a representation with e.g. more links to other resources, etc... 2012-08-06 12:25:26 -05:00
Jon Brisbin
7f8abc5aa8 Big update. Bug fixes, code re-formatting, changing tests. 2012-07-26 13:31:34 -05:00
Jon Brisbin
f969f92acc #18, DATAREST-20, DATAREST-21, DATAREST-22 Bugfixes, re-vamp output method, JSONPE support
There were some issues with how results were being displayed in searches versus entity lists. This code changes the way all results are displayed by offereing several options for output. The default is to inline the entity in the response and page the results (defaults to 20). If the UA sends an `Accept` header of `application/x-spring-data-compact+json` or `text/uri-list`, however, SD REST will output a compact list of only links and will not inline the entities.

The method of output was completely rewritten to use HttpMessageConverters exclusively. Views and the subsequent ContentNegotiatingViewResolver machinery have been elimintated. This should make it easier to embed inside an existing Spring MVC application. This is also easily extendable so the user can plug in their own set of HttpMessageConverters for any output format they like (JAXB, Atom/XML, etc...).

Also added was JSONPE support. By setting the `jsonpParamName` property on the `RepositoryRestConfiguration` customization class, the user can change the default JSONP param name of `callback`. There's also a `jsonpOnErrParamName` property on that configuration (defaults to `null`) that will allow you to capture errors using JSONP. Normally this would not be possible using script element injection, but the REST controller changes the status code to 200 and pass your javascript function the actual response code and wraps the error as the second parameter.
2012-07-23 17:08:10 -05:00
Jon Brisbin
3b3814772f Bumped Spring version to 3.1.2 2012-07-20 16:54:34 -05:00
Jon Brisbin
e44506c4e0 Reorganize how configuration is loaded, add UUID/String Converters. 2012-05-07 10:26:27 -05:00
Jon Brisbin
61170d8b43 Javadoc updates. 2012-05-03 11:35:05 -05:00
Jon Brisbin
d549aaecee Tweaking query method support. 2012-05-02 11:09:27 -05:00