hydra-java
hydra-java copied to clipboard
Issue generating links off of request mapping in parent class
I am running into a problem generating links off of routes in a specific scenario. I have a controller method in an abstract parent class that has a signature like this:
@RequestMapping(method = RequestMethod.GET)
public HttpEntity<CollectionResource> getCollection(
@RequestParam(name = "offset") Integer offset,
@RequestParam(name = "size") Integer size,
@RequestParam(name = "sort") String sort,
@RequestParam(name = "q") String q,
@RequestParam(name = "filter") T filter)
...where T is a generic parameter specified by what is subclassing this parent class. In another unrelated resource, I link to the child class using AffordanceBuilder like so:
Affordance links = AffordanceBuilder.linkTo(methodOn(
ChildController.class)
.getCollection(null, null, null, null, null))
.withRel("resourcerelation");
What gets generated winds up looking like this:
href: "http://localhost:8080/apinull{?offset,size,sort,q,filter}"
...the obvious issue being that while the base url, context root and uri template all get generated properly, the path is coming through as "null".
Let me know if I can give more specific details about this or create a quick example app that demonstrates it. There is a lot more code around this than what I posted that could possibly have an effect.
Hi Evan,
Thank you for the feedback.
Could you provide a test, just add to
https://github.com/dschulten/hydra-java/blob/master/hydra-spring/src/test/java/de/escalon/hypermedia/spring/hydra/HydraMessageConverterTest.java
That would be most helpful.
Best, Dietrich
Am 08.02.2016 18:09 schrieb Evan Lennick [email protected]:
I am running into a problem generating links off of routes in a specific scenario. I have a controller method in an abstract parent class that has a signature like this:
@RequestMapping(method = RequestMethod.GET) public HttpEntity<CollectionResource> getCollection( @RequestParam(name = "offset") Integer offset, @RequestParam(name = "size") Integer size, @RequestParam(name = "sort") String sort, @RequestParam(name = "q") String q, @RequestParam(name = "filter") T filter)
...where T is a generic parameter specified by what is subclassing this parent class. In another unrelated resource, I link to the child class using AffordanceBuilder like so:
Affordance links = AffordanceBuilder.linkTo(methodOn( ChildController.class) .getCollection(null, null, null, null, null)) .withRel("resourcerelation");
What gets generated winds up looking like this:
href: "http://localhost:8080/apinull{?offset,size,sort,q,filter}"
...the obvious issue being that while the base url, context root and uri template all get generated properly, the path is coming through as "null".
Let me know if I can give more specific details about this or create a quick example app that demonstrates it. There is a lot more code around this than what I posted that could possibly have an effect.
— Reply to this email directly or view it on GitHub.