/** * load quota and current using space * * @return JSON */ private JSON loadQuota() { MailAcctConfigInfo config = this.configBo.findByUser(); if (config == null) return FAILURE_JSON; String smtpDef = config.getDefaultSMTP(); if (!StringService.hasLength(smtpDef)) { return FAILURE_JSON; } // get email account from ticket String email = MailService.getUsername(smtpDef); // find detail LDAP mail account LdapMailAccount ldapMailAccount = mailAccountManager.findByName(email); if (ldapMailAccount == null) return FAILURE_JSON; // get quota int quota = 0; try { quota = Integer.parseInt(ldapMailAccount.getQuota()); } catch (NumberFormatException ex) { logger.warning("Error to parse quota to integer", ex); return FAILURE_JSON; } // check quota equal zero if (quota == 0) return FAILURE_JSON; long spaceUsed = this.headerBo.getCurrentUsing(getCode(), smtpDef); // create JSON to return result JSONObject object = new JSONObject(); object.accumulate(FIELD_QUOTA, quota).accumulate(FIELD_USED, spaceUsed); return object; }
/** {@inheritDoc} */ public void logout( HttpServletRequest request, HttpServletResponse response, Authentication authentication) { if (logger.isDebugEnabled()) logger.debug("BEFORE cleaning the account cache..."); if (authentication != null) { String username = authentication.getName(); if (authentication instanceof PrincipalAcegiUserToken) { username = ((PrincipalAcegiUserToken) authentication).getName(); } else if (authentication.getPrincipal() instanceof UserDetails) { username = ((UserDetails) authentication.getPrincipal()).getUsername(); } // show information. if (logger.isDebugEnabled()) logger.debug("Cleaning account of user: [" + username + "]"); try { if (StringService.hasLength(username)) AccountCacheService.remove(username); } catch (Exception ex) { logger.warning("Could not cleaning the cache, message: [" + ex.getMessage() + "]."); } } if (logger.isDebugEnabled()) logger.debug("AFTER cleaning the account cache..."); }