* @return statsRecord HashMap with the info ready to be sent to the StatsManager
*/
private StatsRecord loadStatsRecord(RequestContext reqCtx) {
HttpServletRequest req = reqCtx.getRequest();
HttpSession session = req.getSession();
StatsRecord statsRecord = new StatsRecord(Calendar.getInstance());
Lang lang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
Page page = (Page) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
statsRecord.setIp(reqCtx.getRequest().getRemoteAddr());
statsRecord.setReferer(reqCtx.getRequest().getHeader("Referer"));
statsRecord.setSessionId(session.getId());
UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
StringBuffer rolesBuffer = new StringBuffer();
boolean isFirstRole = true;
IApsAuthority[] auths = currentUser.getAuthorities();
for (int i=0; i<auths.length; i++) {
if (auths[i] instanceof Role) {
Role role = (Role) auths[i];
if (!isFirstRole) rolesBuffer.append(" - ");
rolesBuffer.append(role.getName());
isFirstRole = false;
}
}
statsRecord.setRole(rolesBuffer.toString());
NumberFormat formato = NumberFormat.getIntegerInstance(java.util.Locale.ITALIAN);
formato.setMinimumIntegerDigits(2);
String contentId = this.getContentId(page);
statsRecord.setPageCode(page.getCode());
statsRecord.setLangcode(lang.getCode());
statsRecord.setUseragent(reqCtx.getRequest().getHeader("User-Agent"));
statsRecord.setBrowserLang(reqCtx.getRequest().getHeader("accept-language"));
statsRecord.setContentId(contentId);
return statsRecord;
}