if(userId != null) {
try {
// this is not correct. profile in session can come also from a concurrent execution
profile = (IEngUserProfile) ioManager.getFromSession(IEngUserProfile.ENG_USER_PROFILE);
if (profile == null || !profile.getUserUniqueIdentifier().toString().equals(userId)) {
SecurityServiceProxy proxy = new SecurityServiceProxy(userId, ioManager.getSession());
profile = proxy.getUserProfile();
if (profile!=null){
ioManager.setInSession(IEngUserProfile.ENG_USER_PROFILE, profile);
ioManager.setInSession("userId", profile.getUserUniqueIdentifier());
ioManager.contextManager.set(IEngUserProfile.ENG_USER_PROFILE, profile);
ioManager.contextManager.set("userId", profile.getUserUniqueIdentifier());