docs: public String getSelectedProfile(PortletRequest request) {
  
          // if a profile selection exists in the session, use it
          final PortletSession session = request.getPortletSession();
          String profileName =
                  (String)
                          session.getAttribute(
                                  SessionAttributeProfileMapperImpl.DEFAULT_SESSION_ATTRIBUTE_NAME,
                                  PortletSession.APPLICATION_SCOPE);
  
          // otherwise, set the selected profile to the one currently in use by
          // the user
          if (profileName == null) {
              // get the profile for the current request
              final HttpServletRequest httpServletRequest =
                      portalRequestUtils.getPortletHttpRequest(request);
              final IUserInstance ui = userInstanceManager.getUserInstance(httpServletRequest);
              final IUserProfile profile = ui.getPreferencesManager().getUserProfile();
  
              // check to see if the profile's fname matches one of the entries in
              // the profile key map used by the session attribute profile mapper
              for (Map.Entry<String, String> entry : mappings.entrySet()) {
                  if (entry.getValue().equals(profile.getProfileFname())) {
                      profileName = entry.getKey();
                      break;
                  }
              }
          }
  
          return profileName;
      }