use of javax.servlet.http.HttpSession in project head by mifos.
the class PersonAction method refreshUserContextIfActive.
/*
* When we update user we want to refresh his roles (and permissions) immediately
* This method search for edited user in all active sessions and refresh his context
*/
private void refreshUserContextIfActive(HttpServletRequest request, Long id, String username, Set<Short> roles) {
ShutdownManager shutdownManager = (ShutdownManager) ServletUtils.getGlobal(request, ShutdownManager.class.getName());
Collection<HttpSession> sessions = shutdownManager.getActiveSessions();
for (HttpSession session : sessions) {
UserContext userContext = (UserContext) session.getAttribute("UserContext");
if (userContext != null) {
if (userContext.getId() == id.shortValue()) {
userContext.setRoles(roles);
authenticationAuthorizationServiceFacade.reloadUserDetailsForSecurityContext(username);
break;
}
}
}
}
use of javax.servlet.http.HttpSession in project head by mifos.
the class CustomerActionForm method getUserLocale.
protected Locale getUserLocale(HttpServletRequest request) {
Locale locale = null;
HttpSession session = request.getSession();
if (session != null) {
UserContext userContext = (UserContext) session.getAttribute(LoginConstants.USERCONTEXT);
if (null != userContext) {
locale = userContext.getCurrentLocale();
}
}
return locale;
}
use of javax.servlet.http.HttpSession in project head by mifos.
the class ApproveTransactions method submit.
public ActionForward submit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
HttpSession session = request.getSession(true);
ViewStageTransactionActionForm actionForm = (ViewStageTransactionActionForm) form;
GlMasterBO glMasterBO = new GlMasterBO();
int stage = 1;
List<String> amountActionList = getAmountAction(actionForm);
List<GlDetailBO> glDetailBOList = getGlDetailBOList(actionForm, amountActionList, Integer.parseInt(actionForm.getTransactionDetailID()));
glMasterBO.setTransactionMasterId(Integer.parseInt(actionForm.getStageTransactionNo()));
glMasterBO.setTransactionDate(DateUtils.getDate(actionForm.getStageTrxnDate()));
glMasterBO.setTransactionType(actionForm.getStageTrxnType());
glMasterBO.setFromOfficeLevel(new Integer(actionForm.getStageOfficeHierarchy()));
glMasterBO.setFromOfficeId(actionForm.getStageOffice());
glMasterBO.setToOfficeLevel(new Integer(actionForm.getStageOfficeHierarchy()));
glMasterBO.setToOfficeId(actionForm.getStageOffice());
glMasterBO.setMainAccount(actionForm.getStageMainAccount());
glMasterBO.setTransactionAmount(new BigDecimal(actionForm.getStageAmount()));
glMasterBO.setAmountAction(amountActionList.get(0));
glMasterBO.setTransactionNarration(actionForm.getStageNotes());
glMasterBO.setStage(stage);
glMasterBO.setGlDetailBOList(glDetailBOList);
// default value
glMasterBO.setStatus("");
// default value
glMasterBO.setTransactionBy(0);
glMasterBO.setCreatedBy(getUserContext(request).getId());
glMasterBO.setCreatedDate(DateUtils.getCurrentDateWithoutTimeStamp());
accountingServiceFacade.savingAccountingTransactions(glMasterBO);
return mapping.findForward("submit_success");
}
use of javax.servlet.http.HttpSession in project head by mifos.
the class ShutdownServiceFacadeWebTier method getLoggedUsers.
@Override
public List<LoggedUserDto> getLoggedUsers(HttpServletRequest request) {
ShutdownManager shutdownManager = (ShutdownManager) ServletUtils.getGlobal(request, ShutdownManager.class.getName());
Collection<HttpSession> sessions = shutdownManager.getActiveSessions();
List<PersonnelInfo> personnelInfos = new ArrayList<PersonnelInfo>();
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
if (ActivityMapper.getInstance().isViewActiveSessionsPermitted(userContext, userContext.getBranchId())) {
PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService();
for (HttpSession session : sessions) {
UserContext userContextFromSession = (UserContext) session.getAttribute(LoginConstants.USERCONTEXT);
if (userContextFromSession == null) {
continue;
}
PersonnelBO personnel;
try {
personnel = personnelBusinessService.getPersonnel(userContextFromSession.getId());
} catch (ServiceException e) {
continue;
}
String offices = generateOfficeChain(personnel.getOffice());
String names = personnel.getPersonnelDetails().getName().getFirstName() + " " + personnel.getPersonnelDetails().getName().getLastName();
DateTimeFormatter formatter = DateTimeFormat.shortDateTime().withOffsetParsed().withLocale(userContext.getCurrentLocale());
String activityTime = formatter.print(session.getLastAccessedTime());
ActivityContext activityContext = (ActivityContext) session.getAttribute(LoginConstants.ACTIVITYCONTEXT);
String activityDesc = "[" + activityContext.getLastForward().getName() + "] " + activityContext.getLastForward().getPath();
personnelInfos.add(new PersonnelInfo(offices, names, activityTime, activityDesc));
}
}
Collections.sort(personnelInfos);
List<LoggedUserDto> loggedUsers = new ArrayList<LoggedUserDto>();
for (PersonnelInfo personnelInfo : personnelInfos) {
loggedUsers.add(new LoggedUserDto(personnelInfo.getOffices(), personnelInfo.getNames(), personnelInfo.getActivityTime(), personnelInfo.getActivityContext()));
}
return loggedUsers;
}
use of javax.servlet.http.HttpSession in project head by mifos.
the class LookupOptionsActionForm method getUserLocale.
protected Locale getUserLocale(HttpServletRequest request) {
Locale locale = null;
HttpSession session = request.getSession();
if (session != null) {
UserContext userContext = (UserContext) session.getAttribute(LoginConstants.USERCONTEXT);
if (null != userContext) {
locale = userContext.getCurrentLocale();
}
}
return locale;
}
Aggregations