Commit Graph

461 Commits

Author SHA1 Message Date
Oliver Gierke
07a8dd2ca6 DATAREST-319 - Adapt to changes in Spring Data Commons.
Fixed ReflectionRepositoryInvokerIntegrationTests after some CRUD method detection changes that invalidated the test cases.

Related ticket: DATACMNS-539.
2014-07-15 11:03:18 +02:00
Oliver Gierke
3a583ba511 DATAREST-350 - After release cleanups. 2014-07-10 20:45:44 +02:00
Spring Buildmaster
9e1c607abb DATAREST-350 - Prepare next development iteration. 2014-07-10 20:35:04 +02:00
Spring Buildmaster
527d2391ce DATAREST-350 - Release version 2.2.0.M1. 2014-07-10 20:35:04 +02:00
Oliver Gierke
c722743ad1 DATAREST-350 - Prepare 2.2.0.M1 (Evans M1). 2014-07-10 20:35:00 +02:00
Oliver Gierke
507bed6698 DATAREST-350 - Updated changelog. 2014-07-10 20:34:48 +02:00
Oliver Gierke
48700f239d DATAREST-337 - Updated changelog. 2014-07-10 17:07:56 +02:00
Oliver Gierke
12d2b813cc DATAREST-350 - Upgraded to Spring HATEOAS 0.15.0.RELEASE. 2014-07-10 17:07:56 +02:00
Oliver Gierke
b29fea84e9 DATAREST-333, DATAREST-348 - OPTIONS requests now expose Accept-Patch header.
As recommended in RFC 5789, the support for PATCH request should be advertised in OPTIONS requests (already in place) and include an Accept-Patch header listing the patch media types supported. We now include the media types for JSON Patch, JSON Merge Patch and plain JSON in that header.

[0] http://tools.ietf.org/html/rfc5789#section-3
2014-07-10 17:07:55 +02:00
Oliver Gierke
020de45c1b DATAREST-230 - Support for serving Alps documents.
This commit adds the support to expose additional resources that serve ALPS [0] resources to document the available state transitions and representations. The exposure is enabled by default and can be customized using the RepositoryRestConfiguration.metadataConfiguration() object.

Currently the set of descriptors exposed includes:

- A descriptor for the representation of the domain type. Linkable associations are represented as safe descriptors, ones that are not linked are semantic descriptors.
- Descriptors for each supported HTTP method for both the collection and item resources to indicate the ability to update, create, delete etc.
- Safe descriptors (e.g. to access the collection or item resource) get potentially available customizations (pagination, projections) attached through nested descriptors.

Documentation

An ALPS descriptor contains a doc attribute to carry semantic information for the end user or a potential client to display. The information can be described in two ways: the first one is the @Description annotation that captures the plain text information one wants to get listed. It is supported in @RepositoryRestResource, on query methods, projection interfaces and accessors etc.

The preferred approach however is to use a resource bundle rest-messages.properties. For each descriptor we will resolve a key starting with rest.description followed by a dot path into the resource. By default, doc attributes are only rendered if the resource bundle contains an entry for the relevant key. You can enforce displaying unresolved keys by configuring MetadataConfiguration.omitUnresolvableDescriptionKeys(…).

For representation descriptors and and the parameter list of query method descriptors we will display enum values by default as comma-separated list. The list is also available as message resolution argument, so that you can refer to the list in your description message via the {0} placeholder.

TODOs:

- Improve descriptors for associations (indicate ability to update etc.)

[0] ALPS - http://alps.io
2014-07-10 17:07:55 +02:00
Christoph Strobl
0f0d23c6b1 DATAREST-352 - Remove links to forum.spring.io.
Replace by liks to stackoverflow.
Additionally altered springsource.org to spring.io.
2014-07-10 07:29:35 +02:00
Oliver Gierke
bffa378bc5 DATAREST-350 - Upgraded to Spring HATEOAS 0.15.0.BUILD-SNAPSHOT. 2014-07-08 21:08:10 +02:00
Oliver Gierke
65c95d9068 DATAREST-351 - Upgraded to Evo Inflector 1.2.
This is mainly to prevent users from running into Java 6 incompatibility as the Evo library was accidentally compiled requiring Java 7 compatibility in version 1.1.
2014-07-08 17:01:26 +02:00
Oliver Gierke
b9aef87e05 DATAREST-337 - Fix trailing whitespace in poms. 2014-07-08 14:05:24 +02:00
Oliver Gierke
ef3720be11 DATAREST-348 - Support for json-patch+json and merge-patch+json media types.
We now support PATCH request with application/json-patch+json [0] and application/merge-patch+json media types. The support is based on some customized usage of the FGE JSON Patch library [2]. 

As we need to apply the patch to an existing object, we need translate the JSON Patch remove operation into a replace operation setting the value to null so that out entity processing component registers the request for removal. Same applies to requests for merge-patch+json.

From an implementation point of view the handling of the media type has moved from the controller into PersistentEntityResourceHandlerMethodArgumentResolver and its delegates, n particular JsonPatchHandler. The application of the changes to the existing domain object is handled in the newly introduced DomainObjectReader.

Related ticket: DATAREST-345.

[0] http://tools.ietf.org/html/rfc6902
[1] http://tools.ietf.org/html/draft-ietf-appsawg-json-merge-patch
[2] https://github.com/fge/json-patch
2014-07-08 14:04:47 +02:00
Oliver Gierke
ca2e88ae34 DATAREST-346 - Fixed invocation of overridden delete(…) methods.
We now defensively invoke the ConversionService prior to the reflective invocation of the delete method as we have to assume the clients providing the id value in a raw form, i.e. as obtained from the request and thus most likely as String.

Related ticket: DATAREST-335.
2014-07-02 13:26:03 +02:00
Oliver Gierke
59b15933ae DATAREST-343 - Added jackson-annotation as explicit dependency.
Added explicit dependency to jackson-annotations as a library previously declared might pull in that one in a different version which might cause conflicts.
2014-07-01 10:59:02 +02:00
Oliver Gierke
0dabf8d376 DATAREST-341 - Upgraded to Spring HATEOAS 0.14.0.RELEASE. 2014-06-30 14:08:55 +02:00
Oliver Gierke
e6949f8a46 DATAREST-340 - AssociationOmittingSerializerModifier now keeps non-persistent property writers.
AssociationOmittingSerializerModifier previously dropped the writer fro a particular property if it couldn't find a PersistentProperty for the bean property. We now keep those writers to make sure that non-persistent, additional fields are written as well.

Related issues: https://github.com/spring-projects/spring-boot/issues/1190
2014-06-30 13:31:16 +02:00
Oliver Gierke
71b8b275d1 DATAREST-322 - Updated changelog. 2014-06-30 11:15:53 +02:00
Oliver Gierke
2bfa422ee7 DATAREST-328, DATAREST-320 - AssociationOmittingSerializerModifier now correctly considers renamed properties.
Previously, if a persistent property was renamed using e.g. @JsonProperty, the lookup of the PersistentProperty failed as BeanPropertyWriter exposes the final (renamed) property name, not the internal one. We now defensively lookup the correct BeanPropertyDescriptor using the external name and use the corresponding internal one for the PersistentProperty lookup.
2014-06-27 18:43:02 +02:00
Oliver Gierke
ed77540a81 DATAREST-335 - ReflectionRepositoryInvoker correctly handles overridden delete(…) methods.
If a delete(…) method was overridden using the concrete id type, the check on invocation of course has to accommodate the concrete id type and not serializable only. 

We previously erroneously attempted a to-entity-conversion by invoking findOne(…) and then handed that result to the delete(…) method which caused an IllegalArgumentException as the argument wasn't matching the parameter type. We now explicitly check for the concrete id type in the first place and even bypass any kind of parameter conversion.
2014-06-27 17:05:15 +02:00
Oliver Gierke
2f1e9824cd DATAREST-336 - Default to ISO8601 date rendering. 2014-06-26 12:13:38 +02:00
Oliver Gierke
0f5d790dbd DATAREST-331 - Fixed NullPointerException in ResourcesProcessorWrapper.
During type matching in ResourcesProcessorWrapper we now accomodate the scenario that a Resources type is completely different than the Resources type to look for. This resulted in null being returned for the supertype generics lookup and this failed as the corresponding guard was missing.
2014-06-26 11:24:55 +02:00
Oliver Gierke
e70285331c DATAREST-333 - Added controller mappings for OPTIONS requests.
The root resource, collection and item resources as well as the search and query method resources now expose a handler method to handle OPTIONS requests and return a response with the Allow header set to the HTTP methods appropriate to the resource requested.

Added some additional methods for HEAD requests and a few integration tests for functionality that previously existed.

Related ticket: DATAREST-330.
2014-06-26 09:43:37 +02:00
Oliver Gierke
8618b7df8e DATAREST-182 - Removed obsolete wirings from AbstractRepositoryRestController.
Removed the wirings for PlatformTransactionManager and ValidationExceptionHandler from AbstractRepositoryRestController. Removed the latter entirely as it doesn't seem to be used anywhere anyway.
2014-06-24 23:38:16 +02:00
Oliver Gierke
dc695eecd1 DATAREST-331 - Fixed invocation of processors for Resources subtypes in ResourceProcessorHandlerMethodReturnValueHandler.
ResourceProcessorHandlerMethodReturnValueHandler now also invokes ResourceProcessors that are typed to Resources even if the value returned by the controller is a sub-type of it.

Also added test cases for the invocation of processors for projections.
2014-06-24 19:35:12 +02:00
Oliver Gierke
5dbbbf9703 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:31:23 +02:00
Oliver Gierke
b5f8d97ba3 DATAREST-329 - Improved RepositoryRestMvcConfiguration to not eagerly initialize beans.
The bean definition for annotatedHandlerBeanPostProcessor now is a static one so that it doesn't require the config class to be instantiated and populated, which caused the (too) eager initialization of all dependent beans.

Also we now leniently lookup all ResourceProcessor instances available in the context to prevent the lookup during config class preparation.

Ignore Neo4j tests now as they run into OutOfMemoryErrors.
2014-06-24 16:13:01 +02:00
Oliver Gierke
57732db3ad DATAREST-327 - DomainObjectMerger doesn't merge empty collections.
The association handling in DomainObjectMerger is in place to allow the creation of resources using PUT that have non-optional associations. However, if the domain types that the request payload was unmarshalled into use default values - in particular empty collections to avoid nulls - the merger cannot really distinguish between the default set in the type versus an empty collection being submitted through the request.

As the usecase here is creation only we can safely ignore empty collections as submitting those doesn't make a difference anyway (no related items attached). By ignoring those, we fix the issue defaulted empty collections in the type definitions being considered as value to set.
2014-06-20 13:55:32 +02:00
Oliver Gierke
173d528e47 DATAREST-325 - ReflectionRepositoryInvoker now makes method accessible before invoking.
This allows methods in package protected repository interfaces to be invoked successfully.
2014-06-20 11:52:34 +02:00
Elnur Abdurrakhimov
a9305cab33 DATAREST-323 - Fix typos and remove a duplicated word.
Original pull requests: #140, #141.
Related tickets: DATAREST-324.
2014-06-20 11:52:22 +02:00
Oliver Gierke
59beb1db1a 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 13:16:17 +02:00
Oliver Gierke
3969c34940 DATAREST-317 - Support for excerpt projections.
This commit adds a mechanism to define excerpt projections to be rendered for exposed repositories. The main user facing mechanism is the addition of the excerptProjection attribute to @RepositoryRestResource. This attribute takes a type which has to be a projection interface (see DATAREST-221 for more information about the general mechanism).

If such a excerpt projection is in place, it will be used by default when rendering instances of the domain type in _embedded clauses or if it is related to.

class Person {

  String name;
  int age;
  Person father;
  Person mother;
  Set<Person> siblings:
}

interface PersonExcerpt {
  String getName();
}

If PersonExcerpt is now configured as excerpt projection for Person the collection resource for people will return:

{ _embedded : {
    people : [{
      name : "Some name",
      _embedded : {
        mother : { name : "…" },
        father : { name : "…" },
        siblings : [ … ]
      },
      _links : { self : { href : "…" }}
    }, … ]
  }
}

Here you can see how the age property is omitted when rendering a person in a collection. Also each person contains the excerpt projections of related resources and the links to them omitted. If you now follow the link to the item resource, you'll something like this:

{ name : "Some name",
  age : 34,
  _embedded : {
    mother : { name : "…" },
    father : { name : "…" },
    siblings : [ … ]
  },
  _links : {
    self : { href : "…" },
    mother : { href : "…" },
    father : { href : "…" },
    siblings : { href : "…" }
  }
}

Note, that age appears, as the representation is now rendered entirely. We also see the excerpts of related resource but also the links pointing to them in case you want to manage them.
2014-06-12 13:16:12 +02:00
Oliver Gierke
a1c54b2475 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:51 +02:00
Rodrigue Bouleau
582b13a7f7 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:11 +02:00
Oliver Gierke
aa0bd6c99e DATAREST-306 - After release cleanups. 2014-05-20 20:04:40 +02:00
Spring Buildmaster
2db0203817 DATAREST-306 - Prepare next development iteration. 2014-05-20 20:04:39 +02:00
Spring Buildmaster
c67f79d5ae DATAREST-306 - Release version 2.1.0.RELEASE. 2014-05-20 20:04:39 +02:00
Oliver Gierke
e9e4da3062 DATAREST-306 - Prepare 2.1 GA. 2014-05-20 20:04:32 +02:00
Oliver Gierke
e61e6794e3 DATAREST-306 - Updated changelog. 2014-05-20 16:26:41 +02:00
Oliver Gierke
5c507edb52 DATAREST-307 - Fixed handling of root resource on Tomcat.
We're now using a single slash to make sure the downstream method mapping works as expected.
2014-05-20 13:39:21 +02:00
Thomas Darimont
9f58e2452c DATAREST-305 - Enable Java 8 build in maven configuration.
Extended closed interval in maven enforcerer plugin configuration to include Java 8 (1.8).

Original pull request: #138.
2014-05-19 11:37:59 +02:00
Oliver Gierke
ca3b3bb354 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:10:55 +02:00
Oliver Gierke
fe3c10bead 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:26:17 +02:00
Oliver Gierke
ef7cf82441 DATAREST-297 - After release cleanups. 2014-05-02 15:46:29 +02:00
Spring Buildmaster
cafa6f7931 DATAREST-297 - Prepare next development iteration. 2014-05-02 06:15:33 -07:00
Spring Buildmaster
5693af6f2a DATAREST-297 - Release version 2.1.0.RC1. 2014-05-02 06:15:31 -07:00
Oliver Gierke
683e0afacf DATAREST-297 - Prepare 2.1.0.RC1.
Upgraded to Spring Data Parent 1.4.0.RC1 and Spring Data Commons 1.8.0.RC1. Switched to milestone repository.
2014-05-02 15:01:45 +02:00
Oliver Gierke
bbd94c22ef DATAREST-297 - Updated changelog. 2014-05-02 15:01:28 +02:00