private Person findOrCreateEnabledPersonForCurrentPortletUser(final PortletRequest req)
      throws UserNotEnabledException, UnableToCreateAccountException {
    Person person = null;
    @SuppressWarnings("unchecked")
    Map<String, String> userInfo = (Map<String, String>) req.getAttribute(PortletRequest.USER_INFO);
    String username = null;
    if (userInfo != null) {
      username = userInfo.get(PortletRequest.P3PUserInfos.USER_LOGIN_ID.toString());
    }
    username = StringUtils.isNotBlank(username) ? username : req.getRemoteUser();
    if (!(StringUtils.isNotBlank(username))) {
      throw new IllegalArgumentException("Cannot lookup nor create an account without a username");
    }

    try {
      person = findEnabledPersonByUsernameOrFail(username);
    } catch (ObjectNotFoundException e) {
      try {
        return personService.createUserAccountForCurrentPortletUser(username, req);
      } catch (ObjectExistsException ee) {
        try {
          person = findEnabledPersonByUsernameOrFail(username);
        } catch (ObjectNotFoundException eee) {
          throw new UnableToCreateAccountException(
              "Couldn't create account with username"
                  + username
                  + " because an account with that username seemed"
                  + " to already exist, but was unable to load that"
                  + " existing account.",
              eee);
        } // UserNotEnabledException is helpfully descriptive so just
        // let it bubble up
      }
    }
    return person;
  }