Commit Graph

407 Commits

Author SHA1 Message Date
Oliver Gierke
addaea62ef 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 15:01:07 +02:00
Oliver Gierke
e5dbc30d8a 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:36:54 +02:00
Oliver Gierke
b844b95a27 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:44:49 +02:00
Oliver Gierke
b73ae0fd1b DATAREST-298 - Fixed rel lookup in RepositoryMethodResourceMapping.
In case @RestResource was used to customize the path a method resource was mapped to, we didn't correctly fall back to the method name as rel in case no rel was configured explicitly.

We now check for a rel being configured and fall back to the method name if we don't discover manual configuration.
2014-04-29 12:29:48 +02:00
Oliver Gierke
7dfdaa5114 DATAREST-294 - RepositoryRestConfiguration has more fine grained control over media type defaults.
RepositorRestConfiguration now has a ….useHalAsDefaultJsonMediaType() which defaults to true. Configuring this to false allows to still use HAL as default media type in case no Accept header is set or it is set to */*. The flag decides what to return when an Accept header is set to application/json.
2014-04-29 10:09:15 +02:00
Oliver Gierke
b69b715a66 DATAREST-292, DATAREST-296 - RepositoryLinkBuilder now honors absolute base URIs.
In case a base URI is an absolute one, we now rely on only the base URI as foundation for all links created. Relative base URIs are considered are considered an amendment to the current server base up until the servlet mapping. The latter allows to create a dedicated URI namespace for Spring Data REST exposed resources.
2014-04-29 09:54:17 +02:00
Oliver Gierke
45ef259826 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.
2014-04-23 17:56:28 +02:00
Oliver Gierke
eb3d073714 DATAREST-257 - Upgrade to snapshot dependencies. 2014-04-17 18:51:25 +02:00
Oliver Gierke
9f1a08d412 DATAREST-288 - Removed javax.validation dependency from schema controller. 2014-04-10 09:23:41 +02:00
Spring Buildmaster
d0ccd7251d DATAREST-257 - Prepare next development iteration. 2014-03-31 08:33:17 -07:00
Spring Buildmaster
b5b5b94f01 DATAREST-257 - Release version 2.1.0.M1. 2014-03-31 08:33:14 -07:00
Oliver Gierke
08864ba5b5 DATAREST-257 - Prepare 2.1 M1. 2014-03-31 17:26:55 +02:00
Oliver Gierke
fc4eb30aa1 DATAREST-279 - Fixed creation of point instances from longitude and latitude. 2014-03-25 10:36:56 +01:00
Oliver Gierke
a0395002d0 DATAREST-281 - Upgraded to Spring Data Gemfire 1.4.0.BUILD-SNAPSHOT. 2014-03-21 18:51:13 +01:00
Oliver Gierke
162bba05d5 DATAREST-280 - Improvements in RepositoryRestConfiguration.
Removed custom subclass to use @EnableHypermediaSupport as this was effectively a workaround for SPR-11251, fixed in Spring 3.2.7.

Move away from autowiring all MappingContexts into the configuration as this will require the instances to be created when the configuration class is prepared. We now rather inspect the BeanFactory on access of persistentEntities().
2014-03-21 18:17:52 +01:00
Oliver Gierke
174d3d0e8c DATAREST-279 - Marshalling support for new geo types.
Added StringTo(Distance|Point)Converter implementations to be able to submit Distances and Points via URIs. See the JavaDoc of those classes for more details.

RepositoryRestMvcConfiguration now also registers the GeoModule provided by Spring Data Commons with the ObjectMapper registered for our custom HttpMessageConverters.
2014-03-21 18:12:03 +01:00
Oliver Gierke
6dd353f9c9 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-21 14:35:58 +01:00
Oliver Gierke
05fa30abc1 DATAREST-277 - Adapted to changed generics in BeanWrapper. 2014-03-21 11:39:31 +01:00
Oliver Gierke
063cebe6c1 DATAREST-271 - Fixed application of pagination customizations.
The configuration of HateoasAwarePageableHandlerMethodArgumentResolver now gets the customizations made in RepositoryRestConfiguration applied.
2014-03-13 08:45:40 +01:00
Oliver Gierke
31499b4ebf DATAREST-247 - RepositorySearchController now returns primitive results as is. 2014-03-11 19:25:14 +01:00
Oliver Gierke
572690b888 DATAREST-155 - Introduce API to alter exposed backend ids.
Introduced BackendIdConverter SPI to be able to register custom components that will be used during URI construction and URI parsing to determine the actual backend identifier.

To register a custom BackendIdConverter simply declare a bean definition for it in the ApplicationContext. The Spring Data REST URI creation infrastructure (RepositoryEntityLinks in particular) will pick it up transparently.
2014-03-11 18:13:22 +01:00
Greg Turnquist
0a3738782d 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:39:27 +01:00
Oliver Gierke
ba71362c15 DATAREST-221 - Improvements in ProxyProjectionFactory.
PropertyAccessingMethodInterceptor now ignores Object methods and forwards them to the proxy target. ProxyProjectionFactory now correctly sets up the SpEL root object for reference in expression on accessors.
2014-03-11 10:36:47 +01:00
Oliver Gierke
6e0d153e08 DATAREST-221 - Improved return type matching in ProjectingMethodInterceptor.
We're now using Spring's ClassUtils.isAssignableFrom(…) to make sure we match primitives and wrapper types as well.
2014-03-07 19:47:35 +01:00
Oliver Gierke
1d53e84cae DATAREST-262 - Support for associations in nested types.
Previously we only handled URIs to associations on the root object level as the mapping information for potentially nested embeddables were not accessible via the Repositories instance. This is now fixed by switching to the newly introduced PersistentEntities.

Related tickets: DATACMNS-457, DATACMNS-458, DATAJPA-484.
2014-03-03 18:13:01 +01:00
Oliver Gierke
84ed09c735 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:51:44 +01:00
Oliver Gierke
7d84c1b8db DATAREST-221 - Further refinements in Projector.
Prevent NullPointerException in case we don't find a requested projection. We simply return the source object if so. Added unit tests to make sure we don't introduce a regression.

Removed NoOpProjector from production code as it is only needed in test cases anyway.
2014-02-27 09:25:34 +01:00
Oliver Gierke
af7e15b8e6 DATAREST-221 - Added support for projections.
This commit introduces support to access resources via projections, which means naming a dedicated set of properties of the entity to be exposed and being able to refer to that set through a request parameter.

## General usage

Projections are defined as interfaces that mimic the properties of the domain class to be exported:

@Projection(types = Customer.class, name = "summary")
interface Summary {
  String getFirstname();
  String getLastname();
  AddressSummary getAddress();
}

interface AddressSummary() {
  String getZipCode();
}

The projection interface can be annotated with @Projection to be auto-discovered. We scan all packages in which we find domain types to be exported for projection types and auto-register them. For manual registration, use RepositoryRestConfiguration.projectionDefinitionConfiguration().addProjection(…) and manually register them.

If a projection is registered for a given type, this will be indicated via a "projection" template variable in the URI pointing to resources with projections. The name of the variable can also be configured on ProjectionDefinitionConfiguration.

## Internals

The projection interfaces are consider bean property delegates by default. This means, that for the above interfaces we will lookup the firstname, lastname and address property of the projection target. In the case of address we re-project the result of the proxy target invocation with a sub-projection onto AddressSummary.

For more advanced use-cases you can annotate a method of the projection interface with @Value and use a SpEL expression to invoke further functionality and return that to be rendered:

interface MyProjection {

  @Value("#{@myBean.someMethod(target)}")
  SubProjection getValue();
}

This projection would call the someMethod(…) method on a Spring bean named myBean handing the proxy target to the method. The result will be projected in turn onto a type called SubProjection.

As the projection objects are exposed to Jackson as is, they can be annotated with Jackson annotations to further customize the representation.
2014-02-27 08:48:58 +01:00
Oliver Gierke
faf9a48f30 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:45:35 +01:00
Spring Buildmaster
b16b2e0ec6 DATAREST-249 - Prepare next development iteration. 2014-02-25 07:45:29 +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
8fb93e7484 DATAREST-249 - Prepare 2.0.0.RELEASE.
Upgraded to release versions of Spring Data modules. Updated change log and notice.txt.
2014-02-24 14:40:59 +01:00
Oliver Gierke
afe2bd9361 DATAREST-252 - Documentation overhaul.
Updated documentation and removed obsolete parts.
2014-02-24 09:13:26 +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
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
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
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
Greg Turnquist
4508bc094a DATAREST-228 - Added Maven Enforcer plugin to ensure project is built with Java 7.
Original pull request: #131.
2014-02-12 16:29:11 +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
Oliver Gierke
a5e7aebb65 DATAREST-226 - After release cleanups.
Upgraded to Spring Data snapshot dependencies. Added missing changelog entries.
2014-02-03 14:34:01 +01:00
Spring Buildmaster
84880ffe5e DATAREST-226 - Prepare next development iteration. 2014-01-29 06:40:33 -08:00