use of org.mifos.security.util.UserContext in project head by mifos.
the class RolesPermissionsAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
List<ActivityEntity> activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, request);
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
rolesPermissionServiceFacade.createRole(userContext.getId(), rolesPermissionsActionForm.getName(), getActivityIds(getActivities(activities, rolesPermissionsActionForm.getActivities())), rolesPermissionsActionForm.getActivityRestrictionDtoToPersistList());
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class LoanUIHelperFnStrutsTest method testGetMeetingRecurrence.
@Test
public void testGetMeetingRecurrence() throws Exception {
UserContext userContext = TestObjectFactory.getContext();
MeetingBO meeting = TestObjectFactory.getNewMeeting(MONTHLY, EVERY_SECOND_MONTH, CUSTOMER_MEETING, MONDAY);
Assert.assertEquals("2 month(s)", LoanUIHelperFn.getMeetingRecurrence(meeting, userContext));
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class BulkEntryActionStrutsTest method getUserLocale.
private Locale getUserLocale(final 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 org.mifos.security.util.UserContext in project head by mifos.
the class NotesAction method create.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
NotesActionForm notesActionForm = (NotesActionForm) form;
UserContext uc = getUserContext(request);
CreateAccountNote accountNote = (CreateAccountNote) SessionUtils.getAttribute("model.accountNote", request);
AccountBO accountBO = new AccountBusinessService().getAccount(accountNote.getAccountId());
if (accountBO.getPersonnel() != null) {
checkPermissionForAddingNotes(accountBO.getType(), null, uc, accountBO.getOffice().getOfficeId(), accountBO.getPersonnel().getPersonnelId());
} else {
checkPermissionForAddingNotes(accountBO.getType(), null, uc, accountBO.getOffice().getOfficeId(), uc.getId());
}
if (accountBO.isSavingsAccount()) {
this.savingsServiceFacade.addNote(accountNote);
} else {
this.loanAccountServiceFacade.addNote(accountNote);
}
return mapping.findForward(chooseForward(Short.valueOf(notesActionForm.getAccountTypeId())));
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class SavingsApplyAdjustmentAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
clearActionForm(form);
doCleanUp(request);
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
Long savingsId = Long.valueOf(savings.getAccountId());
savings = this.savingsDao.findById(savingsId);
savings.setUserContext(uc);
String paymentIdParam = request.getParameter("paymentId");
Integer paymentId;
if (paymentIdParam == null) {
AccountPaymentEntity payment = savings.getLastPmnt();
paymentId = (payment == null) ? null : payment.getPaymentId();
} else {
paymentId = Integer.valueOf(paymentIdParam);
}
SavingsAdjustmentReferenceDto savingsAdjustmentDto = this.savingsServiceFacade.retrieveAdjustmentReferenceData(savingsId, paymentId);
if (savingsAdjustmentDto.isDepositOrWithdrawal()) {
AccountPaymentEntity payment = (paymentId == null) ? savings.findMostRecentPaymentByPaymentDate() : savings.findPaymentById(paymentId);
AccountActionEntity accountAction = legacyMasterDao.getPersistentObject(AccountActionEntity.class, new SavingsHelper().getPaymentActionType(payment));
Hibernate.initialize(savings.findMostRecentPaymentByPaymentDate().getAccountTrxns());
SessionUtils.setAttribute(SavingsConstants.ACCOUNT_ACTION, accountAction, request);
SessionUtils.setAttribute(SavingsConstants.CLIENT_NAME, savingsAdjustmentDto.getClientName(), request);
SessionUtils.setAttribute(SavingsConstants.IS_LAST_PAYMENT_VALID, Constants.YES, request);
SessionUtils.setAttribute(SavingsConstants.ADJUSTMENT_AMOUNT, payment.getAmount().getAmount(), request);
SavingsApplyAdjustmentActionForm actionForm = (SavingsApplyAdjustmentActionForm) form;
actionForm.setPaymentId(paymentId);
actionForm.setTrxnDate(new LocalDate(payment.getPaymentDate()));
} else {
SessionUtils.setAttribute(SavingsConstants.IS_LAST_PAYMENT_VALID, Constants.NO, request);
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
return mapping.findForward("load_success");
}
Aggregations