Is there way how to commit changes to entity programatically in the name of specific user so that EntityLog contains name of that user instead of admin for example?
I tried to use this:
private void commitAsUser(User user, CommitContext commitContext){
if(user != null) {
Locale locale = user.getLanguage() != null ? Locale.forLanguageTag(user.getLanguage()):Locale.ENGLISH;
UserSession substitutedUserSession = userSessionManager.createSession(user, locale, true);
SecurityContext securityContext = new SecurityContext(substitutedUserSession);
SecurityContext previousSecurityContext = AppContext.getSecurityContext();
AppContext.setSecurityContext(securityContext);
try {
dataManager.commit(commitContext);
} finally {
AppContext.setSecurityContext(previousSecurityContext);
}
}
}
but i was getting NoUserSessionException on some EntityChangeListener methods.