// Retrieve the person object that is associated with the request
person = this.personManager.getPerson(request);
}
catch (Exception e) {
logger.error("Exception while retrieving IPerson!", e);
throw new PortalSecurityException("Could not retrieve IPerson", e);
}
if (person == null) {
throw new PortalSecurityException("PersonManager returned null person for this request. With no user, there's no UserInstance. Is PersonManager misconfigured? RDBMS access misconfigured?");
}
final HttpSession session = request.getSession(false);
if (session == null) {
throw new IllegalStateException("An existing HttpSession is required while retrieving a UserInstance for a HttpServletRequest");
}
// Return the UserInstance object if it's in the session
UserInstanceHolder userInstanceHolder = getUserInstanceHolder(session);
if (userInstanceHolder != null) {
final IUserInstance userInstance = userInstanceHolder.getUserInstance();
if (userInstance != null) {
return userInstance;
}
}
// Create either a UserInstance or a GuestUserInstance
final IUserInstance userInstance;
if (person.isGuest()) {
final Integer personId = person.getID();
//Get or Create a shared GuestUserPreferencesManager for the Guest IPerson
//sync so multiple managers aren't created for a single guest
GuestUserPreferencesManager guestUserPreferencesManager;
synchronized (guestUserPreferencesManagers) {
guestUserPreferencesManager = guestUserPreferencesManagers.get(personId);
if (guestUserPreferencesManager == null) {
guestUserPreferencesManager = new GuestUserPreferencesManager(person);
guestUserPreferencesManagers.put(personId, guestUserPreferencesManager);
}
}
userInstance = new GuestUserInstance(person, guestUserPreferencesManager, request);
}
else {
final ISecurityContext securityContext = person.getSecurityContext();
if (securityContext.isAuthenticated()) {
userInstance = new UserInstance(person, request);
}
else {
// we can't allow for unauthenticated, non-guest user to come into the system
throw new PortalSecurityException("System does not allow for unauthenticated non-guest users.");
}
}
//Ensure the newly created UserInstance is cached in the session
if (userInstanceHolder == null) {