use of org.mifos.security.util.UserContext in project head by mifos.
the class PictureFormFile method updatePersonalInfo.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updatePersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
ClientBO clientInSession = getClientFromSession(request);
Integer oldClientVersionNumber = clientInSession.getVersionNo();
Integer customerId = clientInSession.getCustomerId();
String clientStatus = clientInSession.getCustomerStatus().getName();
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
short loanOfficerId = clientInSession.getCreatedBy();
final String clientSystemId = clientInSession.getGlobalCustNum();
ClientPersonalInfoDto clientPersonalInfo = this.clientServiceFacade.retrieveClientPersonalInfoForUpdate(clientSystemId, clientStatus, loanOfficerId);
AddressDto address = null;
if (actionForm.getAddress() != null) {
address = Address.toDto(actionForm.getAddress());
}
if (clientPersonalInfo.getCustomerDetail() != null) {
if (clientPersonalInfo.getCustomerDetail().getAddress() != null) {
if (clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber() != null && (!clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber().equals(address.getPhoneNumber()))) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
} else if (clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber() == null && address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
} else if (address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
} else if (address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
ClientNameDetailDto spouseFather = null;
if (!ClientRules.isFamilyDetailsRequired()) {
spouseFather = actionForm.getSpouseName();
}
InputStream picture = null;
if (actionForm.getPicture() != null && StringUtils.isNotBlank(actionForm.getPicture().getFileName())) {
picture = actionForm.getCustomerPicture();
}
ClientNameDetailDto clientNameDetails = actionForm.getClientName();
ClientPersonalDetailDto clientDetail = actionForm.getClientDetailView();
String governmentId = actionForm.getGovernmentId();
String clientDisplayName = actionForm.getClientName().getDisplayName();
String dateOfBirth = actionForm.getDateOfBirth();
ClientPersonalInfoUpdate personalInfo = new ClientPersonalInfoUpdate(customerId, oldClientVersionNumber, customFields, address, clientDetail, clientNameDetails, spouseFather, picture, governmentId, clientDisplayName, dateOfBirth);
this.clientServiceFacade.updateClientPersonalInfo(personalInfo, clientStatus, loanOfficerId);
return mapping.findForward(ActionForwards.updatePersonalInfo_success.toString());
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class PictureFormFile method preview.
@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
String governmentId = actionForm.getGovernmentId();
ClientNameDetailDto clientNameDetail = actionForm.getClientName();
clientNameDetail.setNames(ClientRules.getNameSequence());
String clientName = clientNameDetail.getDisplayName();
String givenDateOfBirth = actionForm.getDateOfBirth();
ClientNameDetailDto spouseName = actionForm.getSpouseName();
spouseName.setNames(ClientRules.getNameSequence());
DateTime dateOfBirth = new DateTime(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth));
ProcessRulesDto processRules = this.clientServiceFacade.previewClient(governmentId, dateOfBirth, clientName, actionForm.isDefaultFeeRemoved(), actionForm.getOfficeIdValue(), actionForm.getLoanOfficerIdValue());
String pendingApprovalState = processRules.isClientPendingApprovalStateEnabled() ? CustomerConstants.YES : CustomerConstants.NO;
SessionUtils.setAttribute(CustomerConstants.PENDING_APPROVAL_DEFINED, pendingApprovalState, request);
Short officeId = actionForm.getOfficeIdValue();
Short groupFlag = actionForm.getGroupFlagValue();
String parentGroupId = actionForm.getParentGroupId();
ClientFormCreationDto clientFormCreationDto = this.clientServiceFacade.retrieveClientFormCreationData(groupFlag, officeId, parentGroupId);
InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
SessionUtils.setCollectionAttribute("personalInformationOrder", informationOrderServiceFacade.getInformationOrder("CreateClient"), request);
if (clientFormCreationDto.getFormedByPersonnelId() != null) {
UserContext userContext = getUserContext(request);
MeetingBO groupMeeting = customerDao.findCustomerById(Integer.valueOf(parentGroupId)).getCustomerMeetingValue();
clientFormCreationDto.getParentCustomerMeeting().setMeetingSchedule(CustomerUIHelperFn.getMeetingSchedule(groupMeeting, userContext));
SessionUtils.setAttribute("meeting", clientFormCreationDto.getParentCustomerMeeting(), request);
}
addWarningMessages(request, processRules, calculateAge(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth)));
actionForm.setEditFamily("edit");
actionForm.setAge(calculateAge(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth)));
actionForm.setClientName(clientNameDetail);
actionForm.setSpouseName(spouseName);
return mapping.findForward(ActionForwards.preview_success.toString());
}
use of org.mifos.security.util.UserContext 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 org.mifos.security.util.UserContext in project head by mifos.
the class CollectionSheetEntryAction method getLogMessage.
private StringBuilder getLogMessage(final String actionMethodName, final HttpServletRequest request) {
UserContext userContext = getUserContext(request);
StringBuilder message = new StringBuilder();
message.append(", url:" + request.getRequestURI());
message.append(", action:" + actionMethodName);
message.append(", session id:" + request.getSession().getId());
message.append(", user id:" + userContext.getId());
message.append(", username:" + userContext.getName());
message.append(", branch id:" + userContext.getBranchGlobalNum());
return message;
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class CollectionSheetEntryAction method load.
/**
* This method is called before the load page for center is called It sets this information in session and
* context.This should be removed after center was successfully created.
*/
@TransactionDemarcate(saveToken = true)
public ActionForward load(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
logTrackingInfo("load", request);
// clean up
request.getSession().setAttribute(CollectionSheetEntryConstants.BULKENTRYACTIONFORM, null);
request.getSession().setAttribute(Constants.BUSINESS_KEY, null);
final UserContext userContext = getUserContext(request);
final CollectionSheetEntryFormDto collectionSheetForm = collectionSheetServiceFacade.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
// settings for action
request.setAttribute(CollectionSheetEntryConstants.REFRESH, collectionSheetForm.getReloadFormAutomatically());
storeOnRequestCollectionSheetEntryFormDto(request, collectionSheetForm);
return mapping.findForward(CollectionSheetEntryConstants.LOADSUCCESS);
}
Aggregations