Commit Graph

79 Commits

Author SHA1 Message Date
Oliver Gierke
6673f1987f #133 - Made JsonPathLinkDiscoverer more robust.
JsonPathLinkDiscoverer now handles InvalidPathExceptions that might occur if the representation doesn't contain the link container element.
2013-12-29 20:26:39 +01:00
Oliver Gierke
bc68707e73 #125 - Prevent curies from being rendered if no link is curied. 2013-12-29 16:20:03 +01:00
Oliver Gierke
3b41fc9149 #132 - Added guard to Resource to shield it from being used with Collection content.
Fixed ticket links in Jackson2HalIntegrationTests.
2013-12-29 16:02:28 +01:00
Oliver Gierke
88da0672ab #125 - Polished curies in HAL and HAL rendering in general.
Both _links and _embedded are now only rendered if there's actual content to be rendered. The curies link is now always rendered as array as specified.
2013-12-28 21:02:27 +01:00
Oliver Gierke
dfa30398b6 #130 - Removed @Inherited annotation from @EnableHypermediaSupport. 2013-12-20 18:59:27 +01:00
Oliver Gierke
7ed46deb7b #129 - ResourceSupport does not return an unmodifiable link collection anymore.
Needed to not fail during JAXB deserialization.
2013-12-19 14:12:37 +01:00
Oliver Gierke
5c737d4b53 #110 - Fixed the collection of values in HalEmbeddedBuilder.
HalEmbeddedBuilder now favors the collection rel to lookup already registered embeddeds.
2013-12-19 13:02:37 +01:00
Oliver Gierke
137e7c390f #128 - Severe refactoring regarding LinkDiscoverers.
The LinkDiscoverer interface is now a Plugin<MediaType> to allow selecting a discoverer per media type. We also provide a LinkDiscoverers wrapper around a PluginRegistry for easier injection.

Dropped DefaultLinkDiscoverer as the above mentioned changed prohibits the usage of a discoverer without a media type. Clients that previously used DefaultLinkDiscoverer should switch to JsonPathLinkDiscoverer with a custom JsonPath expression and media type.

@EnableHypermediaSupport now supports multiple HypermediaType values set to be able to set up support for multiple hypermedia formats. Admittedly, the only currently supported type is HAL but we prepare for the addition of other (e.g. Collection/JSON or the like). We changed the infrastructure setup taken care of by @EnableHypermediaSupport to not enrich all ObjectMapper instances with our HAL modules but explicitly register an ObjectMapper with the application context and then registering a custom MappingJackson(2)HttpMessageConverter with the HandlerAdapter instances present in the ApplicationContext. We skip the registration if an already registered MJ2HMC has an ObjectMapper already supporting the Spring HATEOAS mixins.

Removed some compiler warnings.
2013-12-19 13:01:35 +01:00
Oliver Gierke
9eacd07203 #126, #123 - Added support for HAL curies.
Introduced CurieProvider interface as well as a DefaultCurieProvider that can be registered as Spring Bean to enable Links being rendered in a curie namespace and an additional curie link exposing the metadata of how to lookup the rel definition.

Deprecated Jackson 1 integration. Added helper class to find out whether a relation type is defined by the IANA.
2013-12-17 11:23:30 +01:00
Oliver Gierke
fac6bbb2cc #124 - Fixed mapping annotations in ResourceSupport types.
Added @XmlAnyElement to Resource and moved annotations to accessors to avoid name clashes when overriding them using Jackson mixins.
2013-12-16 15:12:47 +01:00
Ito Zapata
27069b82d6 #112 - Added support for X-Forwarded-Ssl header during link construction. 2013-12-10 14:42:44 +01:00
Oliver Gierke
64d2554325 #89 - Tweaked assertions in PageMetadata.
PageMetadata doesn't reject empty pages anymore if they're used with 1-indexed Pageables. Also tweaked the assertions to only reject negative values for now.
2013-08-26 18:08:46 +02:00
Oliver Gierke
9ee4552bfe #101 - Enable annotation based parameter name discovery on MethodParameters.
MethodParameters can now get an AnnotationAttribute configured that will be inspected for parameter name lookup. If it's not set or no annotated parameter is found we fall back to the standard behavior of MethodParameter and use a LocalVariableTableParameterNameDiscoverer.
2013-07-24 13:35:46 +02:00
ericbottard
9c4d6029cf #98, #97 - Fixed XML element name for PagedResources to allow deserialization.
We need to have a different XML element name for PagedResources as it can be used as root element and JAXB cannot tell the difference between Resource and PagedResource otherwise.
2013-07-16 18:06:20 +02:00
Eric Bottard
cb6dd51e04 #99 - HalLinkListSerializer now generate stable link lists.
We're now using a LinkedHashMap when creating link lists.
2013-07-16 17:21:58 +02:00
Eric Bottard
eed331dbe2 #93 - Fix VndErrors un-marshalling when using Jackson.
Added equals() and hashCode() methods on VndErrors and VndError.

Original pull request: #94.
2013-07-16 17:14:43 +02:00
Frank Bille
c5caea5efd #90 - Fixed port handling in X-Forwarded-Host treatment.
ControllerLinkBuilder now correctly uses the X-Fowarded-Host header by inspecting it for a port being set and configuring the discovered one on the ServletUriComponentsBuilder created.

Also added that the first host listed in the header is used.
2013-07-03 15:25:57 +02:00
Oliver Gierke
a7baafc022 #92 - Removed obsolete annotations from PagedResources.
Removed JsonAutoDetect annotations from PagedResources as the reference to Visibility was causing compile errors in case one of the 2 Jackson variants was not on the classpath (which by design will usually be the case). Generally, the annotations weren't required anymore so that we could remove them.
2013-06-29 14:25:45 +02:00
Oliver Gierke
4142140a37 #91 - Improved proxying for method link references with Objenesis.
Upgraded to Spring 3.2.3 to be able to use inlined CGLib directly. We now use Objenesis to create the proxy instances which avoids the need for a default constructor.
2013-06-28 23:25:20 +02:00
Oliver Gierke
1db0068013 #85 - Added HeaderLinksResponseEntity.
The HeaderLinksResponseEntity wraps any HttpEntity containing a ResourceSupport and will transform it to contain the Links the ResourceSupport instance held in the first place in the entities headers now.
2013-06-12 13:05:30 +02:00
Oliver Gierke
4d4a43b88f #84 - Made constructor in Resource package private.
This change is to essentially prevent people from subclassing Resource and call the default constructor which wrecks the assumption of content never being null. For custom resources extend ResourceSupport.

Added missing license header in ResourcesMixin.
2013-06-12 11:01:51 +02:00
Dietrich Schulten
693faae0fe #81, #83 - Fixed potential NullPointerExceptions in HalEmbeddedBuilder. 2013-06-12 10:00:11 +02:00
Dietrich Schulten
3f995ee8f0 #70 - Fixed link build for controllers with type-level mapping parameters. 2013-05-27 14:15:27 +02:00
Oliver Gierke
85e3a2462f #73 - ControllerLinkBuilder does not reject unmapped types anymore.
ControllerLinkBuilder now simply assumes an empty mapping if no type-level mapping can be found.
2013-05-27 13:57:15 +02:00
Oliver Gierke
a46e662632 #72 - Improved mapping discovery in AnnotationMappingDiscoverer.
AnnotationMappingDiscoverer now returns a polished mapping in case the type mapping consists of a plain slash only.
2013-05-27 13:51:44 +02:00
Oliver Gierke
45c05a3203 Polishing in annotations of PagedResources. 2013-05-27 13:40:26 +02:00
Oliver Gierke
a9ccfc6782 #64 - Extended support for PagedResources.
Changed Relation type to identify previous links to standardized value of prev. Added integration tests for HAL rendering of PagedResources.
2013-05-16 00:07:57 +02:00
Oliver Gierke
0df0f2aab8 #63 - Use collection relation types for embedded collections.
When embedding values into HAL representations we now correctly expose the collection relation type as exposed by RelProvider.getCollectionResourceRelFor(…). Added EmbeddedHalBuilder to ease building these kinds of nested maps easily and use the commonly shared code between Jackson 1 and 2 implementations.
2013-05-07 19:08:03 +02:00
Oliver Gierke
4af8c917c2 #62 - Added support for application/vnd.error+(json|xml).
Introduced representation models for the application/vnd.error media type as specified in [0]. Added default mapping annotations to get it rendered in XML (via JAXB), and JSON (via Jackson 1 and 2).

[0] https://github.com/blongden/vnd.error
2013-05-01 22:03:44 +02:00
Oliver Gierke
64663a5648 #57 - Method reference link building now considers formatting annotations.
The String value handed into the UriTemplate created through mock method invocations now uses a DefaultFormattingConversionService to consider formatting annotations on the controller method parameters.
2013-04-30 16:12:00 +02:00
Oliver Gierke
6acf17e730 #47, #60 - Added RelProvider implementation pluralizing using the Evo Inflector algorithm.
See http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html for details of the algorithm.
2013-04-29 12:18:54 +02:00
Oliver Gierke
254339c3b2 #47, #60 - Implemented RelProvider registration into HAL serializers.
Added @Relation annotation to be able to define the relations that shall be exposed. The annotation can be used on domain classes or ResourceSupport subtypes to define the relations that shall be used to build links pointing to them.

Introduced RelProvider implementations that use the plain domain class name plus an appended List by default (DefaultRelProvider, fallback) as well as an AnnotationRelProvider that will inspect @Relation on the domain type. Added a DelegatingRelProvider that is based on a Spring Plugin PluginRegistry to allow adding RelProvider implementations transparently. Polished AnnotationRelProvider (added annotation caching) and corrected ControllerRelProvider to lookup relation types from Controller classes. Added BeanDefinition setup to HypermediaSupportBeanDefinitionRegistrar to setup a PluginRegistry of RelProviders and the wrapping DelegatingRelProvider to become the primary auto wiring candidate.

Moved RelProvider registration into Jackson HandlerInstantiator implementations. Made the BeanPostProcessors for Jackson ObjectMapper customization aware of the BeanFactory to lookup the DelegatingRelProvider instance to hand them into the Jackson HandlerInstantiators.

TODOs:
- More tests
- Correctly register ControllerRelProviders
2013-04-29 12:18:32 +02:00
Alexander Bätz
47b50266b8 #47, #60 - First draft on extended HAL integration.
Collections are now rendered as _embedded in combination with a topic relation (https://groups.google.com/forum/?fromgroups=#!topic/hal-discuss/bCzydTlHB3M
). Adapted deserializers accordingly.
2013-04-29 12:17:41 +02:00
Oliver Gierke
1d1d959143 #47, #60 - Added provider interface for relation types by entity type. 2013-04-29 12:17:16 +02:00
Oliver Gierke
2c49f397da #56 - LinkBuilderSupport.slash(…) now handles fragments correctly. 2013-03-08 17:49:45 +01:00
Oliver Gierke
db4f96a4e0 #29 - Fixed obsolete inline rendering of rel in HAL links. 2013-03-06 18:39:47 +01:00
Oliver Gierke
6bc906971a #26, #39 - Fixed potential transitive assertion error in UrComponentsBuilder.
If a String piped into LinkBuilderSupport.slash(…) is empty, the call to UriComponentsBuilder.fromUriString(…) fails with an assertion exception. We now guard against this specific case by returning the current builder instance in case an empty String (potentially returned from the toString() method of the object handed in) would be handed to the UriComponentsBuilder.

The issue was introduced by commit 84efebc7a6.
2013-03-04 16:04:19 +01:00
Oliver Gierke
f568845146 #52 - ControllerLinkBuilder builds absolute URIs again.
Commit 8039c306e9 introduced a glitch in ControllerLinkBuilderFactory that caused URIs created not being absolute ones anymore. This commit fixes that glitch.
2013-03-01 12:20:11 +01:00
Oliver Gierke
0db1916dde #50 - Add HAL JSON Module to handler adapters.
In case no ObjectMapper bean has been configured explicitly, the Spring MVC infrastructure registers HttpMessageConverters directly and does not declare them as Spring beans. Thus we now also inspect RequestMappingHandlerAdapter and AnnotationMethodHandlerAdapter instances for their HttpMessageConverters and transparently augment the ObjectMappers backing potentially registered Jackson converters.
2013-02-28 22:50:07 +01:00
Oliver Gierke
8aad5cf83b #50 - Only register LinkDiscoverer if JsonPath is on the classpath. 2013-02-28 22:47:18 +01:00
Oliver Gierke
84efebc7a6 #26, #39 - Added support for request parameters to ControllerLinkBuilder.
We now transparently handle "?foo=bar" expressions passed into ….slash(…). Added method to return UriComponentsBuilder to allow more fine grained control over the URI to be built if needed. The dummy method invocations handled to ….linkTo(…) now transparently adds the values handed in for parameters annotated with @RequestParam.

Most of the commit is highly inspired by Dietrich Schultens work at [0]. I just reworked and polished it slightly as we had too many merge conflicts due to related changes in the meantime.

[0] 1ebdc9025a
2013-02-23 22:34:21 +01:00
Oliver Gierke
d152bcb7d1 #54 - Added support for RFC5988 link headers.
Introduced new Links container element to group a list of links and allow parsing an RFC5988 compatible String representation of links into it. The parsing mechanism is currently regarding the rel attribute only.

Added valueOf(…) factory methods to allow Spring MVC to pick the types up out of the box.
2013-02-20 14:44:08 +01:00
Oliver Gierke
3976ae168b #50 - Added @EnableHypermediaSupport annotation.
The annotation registers supporting application components as Spring beans based on the configured hypermedia type. Currently supported are the default rendering as well as HAL. We register a matching LinkDiscoverer implementation as well as the appropriate Jackson modules (if present on the classpath) to support HAL.

Upgraded to Spring 3.1.4 to benefit from fix to prevent multiple invocations of ImportBeanDefinitionRegistrars (see SPR-9939 / SPR-9925).
2013-02-18 19:30:51 +01:00
Oliver Gierke
8039c306e9 #52 - Introduced UriComponentsContributor SPI.
Introduced UriComponentsContributor interface to allow components to enhance the UriComponentsBuilder used while building links point in to controller methods.

Moved logic from ControllerLinkBuilder into ControllerLinkBuilderFactory as we now potentially need access to Spring injected components. Might be necessary to get rid of the static LinkBuilder implementations entirely.
2013-02-18 19:14:35 +01:00
Oliver Gierke
72837210ee #51 - Added HalLinkDiscoverer.
Added LinkDiscoverer implementation that discovers Links from HAL style representations. Extracted AbstractLinkDiscovererUnitTest to define expected behavior for LinkDiscoverers in general.
2013-02-15 11:25:45 +01:00
Alexander Chilingaryan
29b433445c #46 - AnnotationMappingDiscoverer now deals with missing method mapping.
If a method level @RequestMapping is not carrying a value we now fall back to the type level mapping as Spring MVC does. Before the fix, providing no mapping lead to an ArrayIndexOutOfBoundsException.
2013-02-14 18:10:42 +01:00
Oliver Gierke
0bd6657dd5 #43 - Improved contract in ControllerEntityLinks.
Fixed StackOverflowError in ControllerEntityLinks by delegating to the proper methods now. Clarified contract in EntityLinks interface. Added further unit tests to make sure the implementation behaves like the interface specifies.

Fixes #43.
2013-01-23 16:27:29 +01:00
Alex Coyle
6b7256edad #41, #42 - Allow ResourceAssemberSupport to be used without Identifiable.
Extracted Identifiable related code into an IdentifiableResourceAssemblerSupport to be able to use ResourceAssemblerSupport without the need of the domain object to implement Identifiable.
2013-01-22 14:09:26 +01:00
Oliver Gierke
3f8b90e2b5 #33 - ControllerLinkBuilder now regards X-Forwarded-Host header.
When setting up the builder we now set the host to the value held in the X-Forwarded-Host [0] header if present. This allows to render appropriate URIs in reverse proxy scenarios. This is essentially an extension of ServletUriComponentsBuilder that will be fixed in there eventually. See SPR-10110 [1] for details.

[0] http://tools.ietf.org/html/draft-ietf-appsawg-http-forwarded-10
[1] https://jira.springsource.org/browse/SPR-10110
2012-12-19 17:34:47 +01:00
Oliver Gierke
87537a4def #32 - @EnableEntityLinks is now inherited and documented. 2012-12-19 14:32:06 +01:00