Commit Graph

101 Commits

Author SHA1 Message Date
Oliver Gierke
9790d94872 #180 - Overhaul of URI template expansion in Traverson.
We're now consistently using Spring HATEOAS' UriTemplate instead of the Spring MVC one to be able to expand extended template parameters correctly.

Also the ObjectMapper used by Traverson to unmarshal JSON responses does not fail for unknown properties anymore.
2014-05-20 10:33:42 +02:00
Oliver Gierke
c9675640f2 #114 - Support for type mappings on sub-types in ControllerLinkBuilder.
When building links for method invocations we previously only inspected the type that declared the method for type level mappings. We now use the type the method was invoked on explicitly.
2014-05-01 18:38:52 +02:00
Vladimir Lyubitelev
2c6fa4d1b3 #170 - LinkBuilder takes X-Forwarded-Port header into account if present.
ControllerLinkBuilder now inspects the X-Forwarded-Port and uses that if present. If an X-Forwarded-Host header doesn't contain a :, we now also reset the port to prevent the local one from leaking into links generated.
2014-05-01 18:17:15 +02:00
Oliver Gierke
eafbda0c8a #172 - Made types contained in Link implement Serializable. 2014-05-01 17:57:04 +02:00
Oliver Gierke
0985979428 #131 - Add Traverson hypermedia client API.
Introduce Traverson as means to traverse hypermedia based APIs by providing a set of relation names to discover and follow to access the final representation. Traverson allows to specify a parameter map that will be used  to potentially expand the URIs discovered.

We currently support LinkDiscoverer based relation discovery, which means that relations in HAL representations can be found by simply stating their names. Alternatively JSON path expressions can be used (starting with a $).
2014-05-01 17:47:46 +02:00
Oliver Gierke
8436e9ed4e #165 - Removed support for Jackson 1.x. 2014-03-21 17:45:58 +01:00
Oliver Gierke
20befe9a58 #134 - Fixed initialization of HttpMessageConverters for HAL.
The Jackson(2)ModuleRegisteringBeanPostProcessor now uses postProcess*Before*Initialization to make sure, afterPropertiesSet() has not been called on the target components which might have propagated the original HttpMessageConverters into other internal components.

With this fix, adding the HttpMessageConverter for HAL is added before the call and thus will be propagated to downstream components.
2014-03-19 14:16:34 +01:00
Oliver Gierke
f954a11e47 #160 - Fixed UriTemplate.expand(…) method declaration.
UriTemplate.expand(Map) not takes a Map<String, ? extends Object> to make sure Link.expand(Map) binds to the correct method. Previously it was bound to the method overload taking an Object vararg which caused an invalid expansion.
2014-03-11 19:18:19 +01:00
Oliver Gierke
ec41d78828 #158 - HalEmbeddedBuilder now uses AopUtils.getTargetClass().
To correctly resolve the rel for a proxied class we need to build up relation types for, HalEmbeddedBuilder now uses Spring's AopUtils.getTargetClass(), which will use the object's getTargetClass() method in case it implements TargetClassAware.
2014-02-27 07:50:26 +01:00
Oliver Gierke
f9f7b5bc68 #?? - ObjectUtils now uses proxy target class for Advised proxies. 2014-02-26 18:23:01 +01:00
Oliver Gierke
850c5b6b02 #147 - Added toString() methods to VndErrors and VndError.
Removed duplicate test class.
2014-01-27 17:50:14 +01:00
Oliver Gierke
bb0a578701 #135 - HAL embedded resources are now rendered as collection by default.
To get consistent representations rendered for single-item collections and multi-item collections, we now use an enforceEmbeddedCollections flag in the Jackson 2 HAL module. Adapted HalEmbeddedBuilder to respect that setting and exposed it via the HandlerInstantiator for user level customization.

Changed RelProvider.getSingleResourceRel(…) to getItemResourceRel(…).
2014-01-24 14:52:57 +01:00
Oliver Gierke
9caa352470 #137 - Improved TemplateVariables to combine variables.
Request parameters variables {?…} and continued ones {&…} are now combined by TemplateVariables. Improved detection of the base URI and adapted the rendering logic accordingly. UriTemplates can now be augmented with additional TemplateVariables.

Added equals(…) and hashCode() methods for TempalteVariables.
2014-01-23 15:12:25 +01:00
Oliver Gierke
c790a5d834 #137 - Changed Link.isTempalte() to isTemplated(). 2014-01-23 11:46:08 +01:00
Oliver Gierke
64fd8543b6 #137 - Fixed variable expansion in UriTemplate.
We now eagerly return from UriTemplate.expand(…) if the template doesn't actually contain any variables.
2014-01-22 17:01:38 +01:00
Oliver Gierke
3c62de720f #137 - Improved Link and UriTemplate API.
Added constructor to Link to take a UriTemplate. Added constructor to UriTemplate to take a base URI and TemplateVariables.
2014-01-21 14:27:23 +01:00
Oliver Gierke
719a4b3af3 #142, #137 - CurieProvider can now return multiple curies.
Changed `getCurieInformation(…)` to receive a `Links` instance with the previously added links and is forced to return a collection of curies so that multiple ones can be resolved transparently.

Made Curie value class protected to be able to reuse it from extensions of DefaultCurieProvider. Switched to the custom HATEOAS UriTemplate instance instead of the standard Spring MVC one.

Polished JavaDoc of DefaultCurieProvider. Removed some of the deprecation warnings that were introduced by the upgrade to Jackson 2.3. Polished (read: reactivated) some test cases and slightly changed the internals of UriTemplate works. Added TemplateVariables.asList().
2014-01-21 14:25:43 +01:00
Oliver Gierke
b0cfaf7a62 #137 - Extracted TemplateVariable into separate class.
TempalteVariable is now a standalone class. Introduced TempalteVariables wrapper to allow easy collecting of TempalteVariable instances and rendering them in the shortest possible way.
2014-01-21 13:12:47 +01:00
Oliver Gierke
6e9caf2556 #137 - Merged Link and LinkTemplate.
Link now exposes additional methods like isTemplate(), getTemplateVariables() and expand(…).
2014-01-19 18:38:53 +01:00
Oliver Gierke
bc97010cad #138 - Extended MethodParameters to be able to return parameters by type.
MethodParameters now has a getParametersOfType(…) method to access parameters by type. Also, it now checks for the presence of Spring 4 and automatically uses the improved ParameterNameDiscoverer which will be able to discover interface method parameter names on Java 8.
2014-01-16 13:39:48 +01:00
Oliver Gierke
83743d80a2 #137 - Initial support for link templates.
Added LinkTemplate domain type that can deal with URI templates as defined in http://tools.ietf.org/html/rfc6570. We currently support /, ?, & and # variables up to level 3 of the spec (multiple parameter definitions). The templates can be expanded to a Link instance.

Added the necessary HAL mixins to render the instances as specified.
2014-01-15 17:04:57 +01:00
Oliver Gierke
653f28727c #122 - Fixed parameter binding for optional request parameters.
If the method arguments handed into a dummy controller method invocation are required but null we now throw an exception as we cannot build a URI that hits the very same method in the very same way. Based on that, we now inspect @RequestParam annotated parameters for null values, allow them but don't bind a parameter for them anymore.
2014-01-02 12:15:47 +01:00
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