users@jax-rs-spec.java.net

[jax-rs-spec users] Getting full path template after sub-resource locators

From: Ron Dagostino <rndgstn_at_gmail.com>
Date: Mon, 15 Feb 2016 21:55:51 -0500

Hi everyone. I want to write a ContainerRequestFilter that can generate
the full path template value "root/id1={id1Value}/id2={id2Value}" for the
following case and also generate correct full path template values in the
general case. I don't think it can be reliably done when sub-resource
locators are involved. For example, given these classes:


@Path("root") // resource class
public class Root {
    @Path("id1={id1Value}") // sub-resource locator
    public SubResource getSubResource() {
        return new SubResource();
    }
}

public class SubResource {
    @Path("id2={id2Value}")
    @GET // sub-resource method
    public String get() {
        return "the entity";
    }
}

And given this request:

/root/id1=2/id2=2


The problem is that uriInfo.getPathParameters() returns this MultiValuedMap
in the filter:

{id2Value=[2], id1Value=[2]}

There is no way I can reliably get from "/root/id1=2/id2=2" to
"root/id1={id1Value}/id2={id2Value}" given the MultiValuesMap contents.

Basically I think there is no way to reliably know what the full path
template value is for a request when sub-resource locators are involved.
Is this true?

Ron