Commit Graph

125 Commits

Author SHA1 Message Date
Oliver Gierke
8d5424a6db #305 - Dependency upgrades.
Spring Framework 3.2.9 -> 3.2.13
Jackson 2.4.1 -> 2.4.3
JSONPath 0.9.1 -> 1.2.0
Slf4j 1.7.7 -> 1.7.10
Evo Inflector 1.2 -> 1.2.1

Adapted HalLinkDiscoverer to stricter checking of JSONPath expression.
2015-02-26 15:08:05 +01:00
Oliver Gierke
bf9584f91e #281 - UriTemplate now has convenience method to add a single template variable. 2015-02-10 19:48:56 +01:00
Ori Schwartz
ea4c1064c1 #273 - Fixed assertion in UriTemplate. 2015-02-10 14:59:47 +01:00
Oliver Gierke
a90e2f32c3 #286 - EmbeddedWrappers now allows empty collections if a rel or type is provided.
EmbeddedWrappers.wrap(Object, String) now allows empty collections. Also a new emptyCollectionOfType(Class<?>) was introduced to allow the RelProvider kick in and dynamically resolve the lazily.

Added more details to the JavaDoc of EmbeddedWrapper to make clear that we either expect a static rel returned or a type to resolve the rel from. Make HalEmbeddedBuilder detect invalid implementations and reject them although that should never occur if users use EmbeddedWrappers factory.
2015-02-10 14:49:43 +01:00
Oliver Gierke
c41b28e00d #271 - UriTemplate now correctly expands non-optional path segments. 2015-02-10 14:17:33 +01:00
Oliver Gierke
313afe1cc7 #293 - HypermediaSupportBeanDefinitionRegistrar also augments RestTemplates.
We now also augment HttpMessageConverters for RestTemplate Spring beans.
2015-02-10 14:13:29 +01:00
Jeff Stano
3ca6fa5504 #229 - Added support for curies in HalEmbeddedBuilder.
HalEmbeddedBuilder now takes an optional CurieProvider to create namespaced rels for embeddededs.

Original pull request: #233.
2014-12-02 09:20:49 +01:00
Oliver Gierke
994347c005 #257 - Added support for Forwarded and X-Forwarded-Proto headers.
ControllerLinkBuilder now favors the value of the Forwarded and X-Forwarded-Proto header to build the scheme for the link created.

For more information on the Forwarded header, see http://tools.ietf.org/html/rfc7239.

Related issue: #107.
2014-12-02 08:17:17 +01:00
Oliver Gierke
0bb2216502 #228 - TemplateVariable now correctly rejects invalid parameters. 2014-08-22 17:14:42 +02:00
Oliver Gierke
5882fcf0d6 #219 - HAL setup now registers a more strict HttpMessageConverter.
Previously we registered a special HttpMessageConverter with a custom ObjectMapper to deploy the HAL customizations. That converter was added to Spring MVC registered HandlerAdapters and registered as the first converter.

In case Spring MVC handled a request with Accept header */* or no Accept header at all, this meant that this converter kicked in and served HAL even for objects that don't need the customizations.

We now restrict the applicability of that special HttpMessageConverter to subtypes of ResourceSupport so that it will only be chosen if the object to render is of such type.
2014-07-25 10:24:30 +02:00
Oliver Gierke
67aa51dbea #217 - Improve UriTempalte's handling of TemplateVariables.
TempalteVariables now concatenates all request parameter styles correctly. UriTemplate uses continued style of request parameters if the base URI already contains request parameters.
2014-07-23 15:53:55 +02:00
Oliver Gierke
377f4adff8 #141 - Added model to build ALPS documents.
Added the necessary abstractions to build an ALPS [0] document.

[0] http://alps.io
2014-07-09 16:02:20 +02:00
Oliver Gierke
8fba900aee #212 - Traverson can now return the last link. 2014-07-08 20:59:35 +02:00
Oliver Gierke
a363122be9 #185 - Traverson can now get LinkDiscoverers configured.
Moved to a setter based configuration for both the RestOperations and LinkDiscoverers to be used.

Related pull request: #189.
2014-07-08 20:40:21 +02:00
Dietrich Schulten
c1e940c5f3 #201 - Traverson can now take a customized RestTemplate.
Traverson now has an additional constructor taking a RestOperations instance which will be used instead of the default one. This allows more fine grained control over the HTTP request infrastructure used when performing link traversals.

Some internal polishing (moved from RestTemplate to RestOperations).

Original pull request: #203.
2014-07-08 14:40:27 +02:00
Kory Markevich
921d1af9fb #206 - Set class loader for dummy method proxies.
The Enhancer used to create the proxy instances wasn't explicitly
setting the class loader to use, which meant by default the proxied
class's class loader was chosen. This is fine for controller classes, but
in some containers the return types for the controller may have a
class loader that doesn't have access to Spring, resulting in
ClassNotFoundExceptions. For example, returning a JAX-RS class JBoss.
Using the controller's class loader when proxying the return type solves
this. 

Related issues: #136.
2014-06-30 08:44:17 +02:00
Oliver Gierke
d4d788d9e0 #205 - Jackson2ModuleRegisteringBeanPostProcessor now looks up dependent beans lazily.
We now only lookup the beans, Jackson2ModuleRegisteringBeanPostProcessor needs to post-process other beans if the post-processing is really needed. This avoids premature initialization of those dependent beans.
2014-06-24 16:09:21 +02:00
Oliver Gierke
0b4b3c1ad9 #199 - Refactorings in HalEmbeddedBuilder.
We now provide a dedicated EmbeddedWrappers API that HalEmbeddedBuilder uses to transparently handle the collection enforcement etc. It also allow manually hand in EmbeddedWrapper instances to enforce a certain behavior independent of the global settings in HalEmbeddedBuilder.

Simplified HalResourcesSerializer in Jackson2Hal module as we now don't have to deploy custom serializers for the embedded elements anymore.

Supersedes some of the API introduced for #195.
2014-06-12 10:46:30 +02:00
Oliver Gierke
40ceba3c47 #198 - TemplateVariables now drops duplicate TemplateVariable instances. 2014-06-11 10:21:21 +02:00
Oliver Gierke
20bfa86c5f #195 - HalEmbeddedBuilder now considers RelAware on objects added.
This change introduces a RelAware interface for objects to implement which want to enforce a particular rel to be used in the _embedded clause. This is useful if the objects being added are not categorized by type but rather by their role in the context of the main object.
2014-06-10 10:46:46 +02:00
Oliver Gierke
673f82d388 #192 - Added linkTo(Class<?>, Method, Object...) to MethodLinkBuilderFactory.
The newly introduced method is needed to make sure the correct mappings are looked up if the method given is actually not declared on the class the method shall eventually be invoked on.

This is basically allowing to try to build links, similar to the dummy invocation mechanism but effectively avoiding the overhead of creating such invocation manually (as it would usually require reflection to be used).
2014-06-05 16:19:10 +02:00
Dietrich Schulten
4f7e1cb561 #187, #188 - Fix header handling in Traverson.
Traverson correctly applies headers when using JsonPath to evaluate GET result: accepts the media types it is configured for and preserves additional headers.
2014-06-04 19:36:54 +02:00
Oliver Gierke
48749e7a87 #178 - Fixed potential NullPointerException in ResourceSupport.
ResourceSupport now has a null guard in equals(…) to prevent NullPointerExceptions from happening.
2014-05-20 10:52:56 +02:00
Kamill Sokol
6473c10113 #96 - Fixed double-encoding issues in LinkBuilderSupport.
LinkBuilderSupport now prefers the URI string over the URI to avoid double encoding issues.

VndErrorsMarshallingTest.jackson2marshalling(…) shouldn't take line breaks into account due to platform differences (Win, OSX, Linux)

Original pull request: #179.
2014-05-20 10:49:05 +02:00
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