AuditableListener
Posted: Tue Sep 11, 2012 12:53 am
While i was looking the code for audit-trial field i found org.broadleafcommerce.common.audit.AuditableListener which populate created user id always 0
protected void setAuditValueAgent(Field field, Object entity) throws IllegalArgumentException, IllegalAccessException {
try {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null) {
Object principal = authentication.getPrincipal();
}
} catch (Exception e) {
e.printStackTrace();
}
field.setAccessible(true);
field.set(entity, 0L);
}
if this is the case then how do it populate audit field. If this code is expected then how it will populate creator field
protected void setAuditValueAgent(Field field, Object entity) throws IllegalArgumentException, IllegalAccessException {
try {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null) {
Object principal = authentication.getPrincipal();
}
} catch (Exception e) {
e.printStackTrace();
}
field.setAccessible(true);
field.set(entity, 0L);
}
if this is the case then how do it populate audit field. If this code is expected then how it will populate creator field