use of org.apache.deltaspike.data.api.audit.CurrentUser in project deltaspike by apache.
the class PrincipalProvider method resolvePrincipal.
private Object resolvePrincipal(Object entity, Property<Object> property) {
CurrentUser principal = AnnotationInstanceProvider.of(CurrentUser.class);
Class<?> propertyClass = property.getJavaClass();
Set<Bean<?>> beans = manager.getBeans(propertyClass, principal);
if (!beans.isEmpty() && beans.size() == 1) {
Bean<?> bean = beans.iterator().next();
Object result = manager.getReference(bean, propertyClass, manager.createCreationalContext(bean));
return result;
}
throw new IllegalArgumentException("Principal " + (beans.isEmpty() ? "not found" : "not unique") + " for " + propertyName(entity, property));
}
Aggregations