use of org.apache.struts.action.ActionForward in project head by mifos.
the class GroupCustAction method search.
@Override
@TransactionDemarcate(joinToken = true)
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
GroupCustActionForm actionForm = (GroupCustActionForm) form;
UserContext userContext = getUserContext(request);
ActionForward actionForward = super.search(mapping, form, request, response);
String searchString = actionForm.getSearchString();
if (searchString == null) {
if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
request.setAttribute(Constants.INPUT, CenterConstants.INPUT_SEARCH_TRANSFERGROUP);
} else {
request.setAttribute(Constants.INPUT, null);
}
throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
}
addSeachValues(searchString, userContext.getBranchId().toString(), new OfficeBusinessService().getOffice(userContext.getBranchId()).getOfficeName(), request);
final String normalizedSearchString = SearchUtils.normalizeSearchString(searchString);
if (normalizedSearchString.equals("")) {
if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
request.setAttribute(Constants.INPUT, CenterConstants.INPUT_SEARCH_TRANSFERGROUP);
} else {
request.setAttribute(Constants.INPUT, null);
}
throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
}
boolean searchForAddingClientsToGroup = (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_ADD_CLIENTS_TO_GROUPS));
GroupSearchResultsDto searchResult = this.customerServiceFacade.searchGroups(searchForAddingClientsToGroup, normalizedSearchString, userContext.getId());
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchResults(), request);
if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
return mapping.findForward(ActionForwards.transferSearch_success.toString());
} else if (searchForAddingClientsToGroup) {
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchForAddingClientToGroupResults(), request);
return mapping.findForward(ActionForwards.addGroupSearch_success.toString());
} else {
return actionForward;
}
}
use of org.apache.struts.action.ActionForward in project head by mifos.
the class CustomerNotesAction method create.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In CustomerNotesAction::create()");
ActionForward forward = null;
CustomerNotesActionForm notesActionForm = (CustomerNotesActionForm) form;
Integer customerId = Integer.valueOf(((CustomerNotesActionForm) form).getCustomerId());
CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
UserContext uc = getUserContext(request);
if (customerBO.getPersonnel() != null) {
checkPermissionForAddingNotes(AccountTypes.CUSTOMER_ACCOUNT, customerBO.getLevel(), uc, customerBO.getOffice().getOfficeId(), customerBO.getPersonnel().getPersonnelId());
} else {
checkPermissionForAddingNotes(AccountTypes.CUSTOMER_ACCOUNT, customerBO.getLevel(), uc, customerBO.getOffice().getOfficeId(), uc.getId());
}
CustomerNoteFormDto customerNoteForm = new CustomerNoteFormDto(customerBO.getGlobalCustNum(), customerBO.getDisplayName(), customerBO.getCustomerLevel().getId().intValue(), new LocalDate(), "", notesActionForm.getComment());
this.centerServiceFacade.createCustomerNote(customerNoteForm);
forward = mapping.findForward(getDetailCustomerPage(notesActionForm));
return forward;
}
use of org.apache.struts.action.ActionForward in project head by mifos.
the class LoanAccountActionTest method shouldViewOriginalSchedule.
@SuppressWarnings("unchecked")
@Test
public void shouldViewOriginalSchedule() throws Exception {
ActionForward viewOriginalScheduleForward = new ActionForward("viewOriginalSchedule");
int loanId = 1;
String loanAmount = "123";
List<RepaymentScheduleInstallment> installments = Collections.EMPTY_LIST;
java.sql.Date disbursementDate = new java.sql.Date(new DateTime().toDate().getTime());
OriginalScheduleInfoDto dto = mock(OriginalScheduleInfoDto.class);
when(dto.getOriginalLoanScheduleInstallment()).thenReturn(installments);
when(dto.getLoanAmount()).thenReturn(loanAmount);
when(dto.getDisbursementDate()).thenReturn(disbursementDate);
when(request.getParameter(LoanAccountAction.ACCOUNT_ID)).thenReturn(String.valueOf(loanId));
when(loanServiceFacade.retrieveOriginalLoanSchedule(loanId)).thenReturn(dto);
when(mapping.findForward("viewOriginalSchedule")).thenReturn(viewOriginalScheduleForward);
ActionForward forward = loanAccountAction.viewOriginalSchedule(mapping, form, request, response);
assertThat(forward, is(viewOriginalScheduleForward));
verify(request).getParameter(LoanAccountAction.ACCOUNT_ID);
verify(loanServiceFacade).retrieveOriginalLoanSchedule(loanId);
verify(dto).getOriginalLoanScheduleInstallment();
verify(dto).getLoanAmount();
verify(dto).getDisbursementDate();
verify(mapping).findForward("viewOriginalSchedule");
}
use of org.apache.struts.action.ActionForward in project zoj by licheng.
the class ShowUserRoleAction method execute.
/**
* ShowRunsAction.
*
* @param mapping
* action mapping
* @param form
* action form
* @param request
* http servlet request
* @param response
* http servlet response
*
* @return action forward instance
*
* @throws Exception
* any errors happened
*/
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
// check admin
ActionForward forward = this.checkAdmin(mapping, context);
if (forward != null) {
return forward;
}
long userId = Utility.parseLong(String.valueOf(context.getRequest().getParameter("userId")));
UserProfile user = UserManager.getInstance().getUserProfile(userId);
if (user == null) {
return this.handleSuccess(mapping, context, "failure");
}
context.getRequest().setAttribute("User", user);
context.getRequest().setAttribute("Roles", PersistenceManager.getInstance().getAuthorizationPersistence().getAllRoles());
context.getRequest().setAttribute("UserRoles", PersistenceManager.getInstance().getAuthorizationPersistence().getUserSecurity(userId).getRoles());
return this.handleSuccess(mapping, context, "success");
}
use of org.apache.struts.action.ActionForward in project zoj by licheng.
the class SubmitAction method execute.
/**
* SubmitAction.
*
* @param mapping
* action mapping
* @param form
* action form
* @param request
* http servlet request
* @param response
* http servlet response
*
* @return action forward instance
*
* @throws Exception
* any errors happened
*/
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
if (!this.isLogin(context, true)) {
return this.handleSuccess(mapping, context, "login");
}
boolean isProblemset = context.getRequest().getRequestURI().endsWith("submit.do");
ActionForward forward = this.checkProblemParticipatePermission(mapping, context, isProblemset);
if (forward != null) {
return forward;
}
AbstractContest contest = context.getContest();
Problem problem = context.getProblem();
long languageId = Utility.parseLong(context.getRequest().getParameter("languageId"));
Language language = PersistenceManager.getInstance().getLanguagePersistence().getLanguage(languageId);
if (language == null) {
return this.handleSuccess(mapping, context, "submit");
}
String source = context.getRequest().getParameter("source");
if (source == null || source.length() == 0) {
return this.handleSuccess(mapping, context, "submit");
}
List refrance = PersistenceManager.getInstance().getReferencePersistence().getProblemReferences(problem.getId(), ReferenceType.HEADER);
if (refrance.size() != 0) {
Reference r = (Reference) refrance.get(0);
String percode = new String(r.getContent());
source = percode + "\n" + source;
}
UserProfile user = context.getUserProfile();
if (submitCache != null && submitCache.contains(user.getId())) {
ActionMessages messages = new ActionMessages();
messages.add("message", new ActionMessage("onlinejudge.submit.interval"));
this.saveErrors(context.getRequest(), messages);
context.setAttribute("source", source);
return handleSuccess(mapping, context, "submit");
}
if (contest.isCheckIp()) {
forward = this.checkLastLoginIP(mapping, context, isProblemset);
if (forward != null) {
return forward;
}
}
Submission submission = new Submission();
submission.setContestId(contest.getId());
submission.setLanguage(language);
submission.setProblemId(problem.getId());
submission.setUserProfileId(user.getId());
submission.setContent(source);
submission.setMemoryConsumption(0);
submission.setTimeConsumption(0);
submission.setSubmitDate(new Date());
SubmissionPersistence submissionPersistence = PersistenceManager.getInstance().getSubmissionPersistence();
if (contest.getEndTime() != null && new Date().after(contest.getEndTime())) {
submission.setJudgeReply(JudgeReply.OUT_OF_CONTEST_TIME);
submissionPersistence.createSubmission(submission, user.getId());
} else if (source.getBytes().length > problem.getLimit().getSubmissionLimit() * 1024) {
submission.setContent(source.substring(0, problem.getLimit().getSubmissionLimit() * 1024));
submission.setJudgeReply(JudgeReply.SUBMISSION_LIMIT_EXCEEDED);
submissionPersistence.createSubmission(submission, user.getId());
} else {
submission.setJudgeReply(JudgeReply.QUEUING);
submissionPersistence.createSubmission(submission, user.getId());
JudgeService.getInstance().judge(submission, Priority.NORMAL);
}
context.setAttribute("contestOrder", submission.getContestOrder());
if (submitCache != null) {
submitCache.put(user.getId(), user.getId());
}
return this.handleSuccess(mapping, context, "success");
}
Aggregations