if (subPath == null)
{
// resource method
ResourceMethodDescriptor res =
new ResourceMethodDescriptorImpl(method, httpMethod.value(), params, this, consumes, produces,
new DefaultMethodInvoker());
ResourceMethodDescriptor exist =
findMethodResourceMediaType(resourceMethods.getList(httpMethod.value()), res.consumes(), res
.produces());
if (exist == null)
{
resourceMethods.add(httpMethod.value(), res);
}
else
{
String msg =
"Two resource method " + res + " and " + exist
+ " with the same HTTP method, consumes and produces found.";
throw new RuntimeException(msg);
}
}
else
{
// sub-resource method
SubResourceMethodDescriptor subRes =
new SubResourceMethodDescriptorImpl(new PathValue(subPath.value()), method, httpMethod.value(),
params, this, consumes, produces, new DefaultMethodInvoker());
SubResourceMethodDescriptor exist = null;
ResourceMethodMap<SubResourceMethodDescriptor> rmm =
(ResourceMethodMap<SubResourceMethodDescriptor>)subResourceMethods.getMethodMap(subRes
.getUriPattern());
// rmm is never null, empty map instead
List<SubResourceMethodDescriptor> l = rmm.getList(httpMethod.value());
exist =
(SubResourceMethodDescriptor)findMethodResourceMediaType(l, subRes.consumes(), subRes.produces());
if (exist == null)
{
rmm.add(httpMethod.value(), subRes);
}
else
{
String msg =
"Two sub-resource method " + subRes + " and " + exist
+ " with the same HTTP method, path, consumes and produces found.";
throw new RuntimeException(msg);
}
}
}
else
{
if (subPath != null)
{
// sub-resource locator
SubResourceLocatorDescriptor loc =
new SubResourceLocatorDescriptorImpl(new PathValue(subPath.value()), method, params, this,
new DefaultMethodInvoker());
if (!subResourceLocators.containsKey(loc.getUriPattern()))
{
subResourceLocators.put(loc.getUriPattern(), loc);
}
else