final Map<PathPattern, ResourceMethodMap> patternMethodMap =
new HashMap<PathPattern, ResourceMethodMap>();
for (final AbstractSubResourceMethod method : resource.getSubResourceMethods()) {
PathPattern p;
try {
p = new PathPattern(new PathTemplate(method.getPath().getValue()), "(/)?");
} catch (IllegalArgumentException ex) {
Errors.error(String.format("Illegal URI template for sub-resource method %s: %s",
method.getMethod(), ex.getMessage()));
continue;
}
final ResourceMethod rm = new ResourceHttpMethod(dp, ff, p.getTemplate(), method);
ResourceMethodMap rmm = patternMethodMap.get(p);
if (rmm == null) {
rmm = new ResourceMethodMap();
patternMethodMap.put(p, rmm);
}
if (isValidResourceMethod(rm, rmm)) {
rmm.put(rm);
}
rmm.put(rm);
}
// Create the rules for the sub-resource HTTP methods
for (final Map.Entry<PathPattern, ResourceMethodMap> e : patternMethodMap.entrySet()) {
addImplicitMethod(implictProduces, e.getValue());
final PathPattern p = e.getKey();
final ResourceMethodMap rmm = e.getValue();
processHead(rmm);
processOptions(rmm, resource, p);
rmm.sort();
rulesMap.put(p,
new RightHandPathRule(
resourceConfig.getFeature(ResourceConfig.FEATURE_REDIRECT),
p.getTemplate().endsWithSlash(),
new HttpMethodRule(rmm, true, dispatchingListener)));
}
}