コード例 #1
0
 /**
  * String returned when no avatar is found
  *
  * @param avatarManager
  * @return
  * @throws ApsSystemException
  */
 private String getNullAvatar(IAvatarManager avatarManager) throws ApsSystemException {
   String nullAvatar = null;
   if (null != this.getReturnDefaultAvatar()
       && this.getReturnDefaultAvatar().equalsIgnoreCase("true")) {
     nullAvatar =
         avatarManager.getAvatarUrl(null); // + JpAvatarSystemConstants.DEFAULT_AVATAR_NAME;
   }
   return nullAvatar;
 }
コード例 #2
0
  public int doEndTag() throws JspException {
    try {
      IAvatarManager avatarManager =
          (IAvatarManager)
              ApsWebApplicationUtils.getBean(JpAvatarSystemConstants.AVATAR_MANAGER, pageContext);
      HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
      UserDetails currentUser =
          (UserDetails)
              request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);

      boolean isCurrentUserGuest =
          null == currentUser
              || currentUser.getUsername().trim().length() == 0
              || currentUser.getUsername().equalsIgnoreCase(SystemConstants.GUEST_USER_NAME);
      if (StringUtils.isBlank(this.getUsername()) && isCurrentUserGuest) {
        this.doOut(this.getNullAvatar(avatarManager));
      } else {
        String username = this.getUsername();
        if (StringUtils.isBlank(username)) {
          username = currentUser.getUsername();
        }
        String avatarName = avatarManager.getAvatarUrl(username);
        if (null != avatarName) {
          this.doOut(avatarName);
        } else {
          this.doOut(this.getNullAvatar(avatarManager));
        }
      }
      if (StringUtils.isNotBlank(this.getAvatarStyleVar())) {
        this.pageContext
            .getRequest()
            .setAttribute(this.getAvatarStyleVar(), avatarManager.getConfig().getStyle());
      }
    } catch (Throwable e) {
      ApsSystemUtils.logThrowable(e, this, "doEndTag");
      throw new JspException("Error in AvatarTag", e);
    }
    return EVAL_PAGE;
  }