use of org.jboss.resteasy.spi.MethodInjector in project candlepin by candlepin.
the class VerifyAuthorizationFilter method getArguments.
protected Map<Verify, Object> getArguments(HttpRequest request, Method method) {
ResteasyProviderFactory resourceFactory = ResteasyProviderFactory.getInstance();
InjectorFactory injectorFactory = resourceFactory.getInjectorFactory();
ResourceLocator locator = locatorMap.get(method);
if (null == locator) {
throw new IseException("Method " + method.getName() + " not registered as RESTful.");
}
MethodInjector methodInjector = injectorFactory.createMethodInjector(locator, resourceFactory);
HttpResponse response = ResteasyProviderFactory.popContextData(HttpResponse.class);
Object[] args = methodInjector.injectArguments(request, response);
// LinkedHashMap preserves insertion order
Map<Verify, Object> argMap = new LinkedHashMap<>();
Annotation[][] allAnnotations = method.getParameterAnnotations();
// Any occurrence of the Verify annotation means the method is not superadmin exclusive.
for (int i = 0; i < allAnnotations.length; i++) {
for (Annotation a : allAnnotations[i]) {
if (a instanceof Verify) {
Verify v = (Verify) a;
if (!v.nullable() && args[i] == null) {
throw new IllegalStateException("Null passed to a non-nullable Verify annotation.");
} else {
argMap.put(v, args[i]);
}
}
}
}
return argMap;
}
Aggregations