use of org.mifos.security.util.UserContext in project head by mifos.
the class ClientCustActionForm method checkForMandatoryFields.
@SuppressWarnings("unchecked")
@Override
public void checkForMandatoryFields(Short entityId, ActionErrors errors, HttpServletRequest request) {
Map<Short, List<FieldConfigurationEntity>> entityMandatoryFieldMap = (Map<Short, List<FieldConfigurationEntity>>) request.getSession().getServletContext().getAttribute(Constants.FIELD_CONFIGURATION);
List<FieldConfigurationEntity> mandatoryfieldList = entityMandatoryFieldMap.get(entityId);
for (FieldConfigurationEntity fieldConfigurationEntity : mandatoryfieldList) {
String propertyName = request.getParameter(fieldConfigurationEntity.getLabel());
UserContext userContext = ((UserContext) request.getSession().getAttribute(LoginConstants.USERCONTEXT));
if (propertyName != null && !propertyName.equals("") && !propertyName.equalsIgnoreCase("picture")) {
String propertyValue = request.getParameter(propertyName);
if (propertyValue == null || propertyValue.equals("")) {
errors.add(fieldConfigurationEntity.getLabel(), new ActionMessage(FieldConfigurationConstant.EXCEPTION_MANDATORY, FieldConfigurationHelper.getLocalSpecificFieldNames(fieldConfigurationEntity.getLabel(), userContext)));
}
} else if (propertyName != null && !propertyName.equals("") && propertyName.equalsIgnoreCase("picture")) {
try {
if (getCustomerPicture() == null || getCustomerPicture().read() == -1) {
errors.add(fieldConfigurationEntity.getLabel(), new ActionMessage(FieldConfigurationConstant.EXCEPTION_MANDATORY, FieldConfigurationHelper.getLocalSpecificFieldNames(fieldConfigurationEntity.getLabel(), userContext)));
}
getCustomerPicture().reset();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class CollectionSheetEntryAction method getUserLocale.
/**
* used by JSP functions in view.
*/
protected Locale getUserLocale(final HttpServletRequest request) {
Locale locale = null;
UserContext userContext = getUserContext(request);
if (null != userContext) {
locale = userContext.getCurrentLocale();
}
return locale;
}
use of org.mifos.security.util.UserContext 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;
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class CenterCustAction method load.
@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
CenterCustActionForm actionForm = (CenterCustActionForm) form;
actionForm.clearActionFormFields();
SessionUtils.removeAttribute(CustomerConstants.CUSTOMER_MEETING, request);
UserContext userContext = getUserContext(request);
CenterCreation centerCreationDto = new CenterCreation(actionForm.getOfficeIdValue(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
CenterFormCreationDto centerFormCreation = this.centerServiceFacade.retrieveCenterFormCreationData(centerCreationDto);
// SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<Serializable>(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, centerFormCreation.getActiveLoanOfficersForBranch(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, centerFormCreation.getAdditionalFees(), request);
// actionForm.setCustomFields(centerFormCreation.getCustomFieldViews());
actionForm.setDefaultFees(centerFormCreation.getDefaultFees());
DateTime today = new DateTime().toDateMidnight().toDateTime();
actionForm.setMfiJoiningDate(today.getDayOfMonth(), today.getMonthOfYear(), today.getYear());
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class RolesPermissionsAction method update.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
List<ActivityEntity> activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, request);
rolesPermissionServiceFacade.updateRole(Short.parseShort(rolesPermissionsActionForm.getId()), userContext.getId(), rolesPermissionsActionForm.getName(), getActivityIds(getActivities(activities, rolesPermissionsActionForm.getActivities())), rolesPermissionsActionForm.getActivityRestrictionDtoToPersistList());
// MIFOS-3530: update all currently logged users
for (String loggedUser : getLoggedUsers(request)) {
this.authenticationAuthorizationServiceFacade.reloadUserDetailsForSecurityContext(loggedUser);
}
return mapping.findForward(ActionForwards.update_success.toString());
}
Aggregations