use of org.apache.struts.action.ActionForward in project cu-kfs by CU-CommunityApps.
the class KualiAccountingDocumentActionBase method performBalanceInquiryForAccountingLine.
/**
* This method handles preparing all of the accounting line data so that it can be pushed up to the balance inquiries for
* populating the search criteria of each.
*
* @param mapping
* @param form
* @param request
* @param line
* @return ActionForward
*/
protected ActionForward performBalanceInquiryForAccountingLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, AccountingLine line) {
// build out base path for return location
String basePath = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KFSConstants.APPLICATION_URL_KEY);
// build out the actual form key that will be used to retrieve the form on refresh
String callerDocFormKey = GlobalVariables.getUserSession().addObjectWithGeneratedKey(form);
// now add required parameters
Properties parameters = new Properties();
parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.START_METHOD);
// need this next param b/c the lookup's return back will overwrite
// the original doc form key
parameters.put(KFSConstants.BALANCE_INQUIRY_REPORT_MENU_CALLER_DOC_FORM_KEY, callerDocFormKey);
parameters.put(KFSConstants.DOC_FORM_KEY, callerDocFormKey);
parameters.put(KFSConstants.BACK_LOCATION, basePath + mapping.getPath() + ".do");
if (line.getPostingYear() != null) {
parameters.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, line.getPostingYear().toString());
}
if (StringUtils.isNotBlank(line.getReferenceOriginCode())) {
parameters.put("referenceOriginCode", line.getReferenceOriginCode());
}
if (StringUtils.isNotBlank(line.getReferenceNumber())) {
parameters.put("referenceNumber", line.getReferenceNumber());
}
if (StringUtils.isNotBlank(line.getReferenceTypeCode())) {
parameters.put("referenceTypeCode", line.getReferenceTypeCode());
}
if (StringUtils.isNotBlank(line.getDebitCreditCode())) {
parameters.put("debitCreditCode", line.getDebitCreditCode());
}
if (StringUtils.isNotBlank(line.getChartOfAccountsCode())) {
parameters.put("chartOfAccountsCode", line.getChartOfAccountsCode());
}
if (StringUtils.isNotBlank(line.getAccountNumber())) {
parameters.put("accountNumber", line.getAccountNumber());
}
if (StringUtils.isNotBlank(line.getFinancialObjectCode())) {
parameters.put("financialObjectCode", line.getFinancialObjectCode());
}
if (StringUtils.isNotBlank(line.getSubAccountNumber())) {
parameters.put("subAccountNumber", line.getSubAccountNumber());
}
if (StringUtils.isNotBlank(line.getFinancialSubObjectCode())) {
parameters.put("financialSubObjectCode", line.getFinancialSubObjectCode());
}
if (StringUtils.isNotBlank(line.getProjectCode())) {
parameters.put("projectCode", line.getProjectCode());
}
if (StringUtils.isNotBlank(getObjectTypeCodeFromLine(line))) {
if (!StringUtils.isBlank(line.getObjectTypeCode())) {
parameters.put("objectTypeCode", line.getObjectTypeCode());
} else {
line.refreshReferenceObject("objectCode");
parameters.put("objectTypeCode", line.getObjectCode().getFinancialObjectTypeCode());
}
}
String lookupUrl = UrlFactory.parameterizeUrl(basePath + "/" + KFSConstants.BALANCE_INQUIRY_REPORT_MENU_ACTION, parameters);
// register that we're going to come back w/ to this form w/ a refresh methodToCall
((KualiAccountingDocumentFormBase) form).registerEditableProperty(KRADConstants.DISPATCH_REQUEST_PARAMETER);
return new ActionForward(lookupUrl, true);
}
use of org.apache.struts.action.ActionForward in project iaf by ibissource.
the class ActionBase method getDefaultActionForward.
/**
* looks under the session for an attribute named forward. Returns it as an ActionForward
*/
public ActionForward getDefaultActionForward(HttpServletRequest request) {
HttpSession session = request.getSession();
ActionForward definedForward = (ActionForward) session.getAttribute("forward");
return definedForward;
}
use of org.apache.struts.action.ActionForward in project iaf by ibissource.
the class ActionBase method setDefaultActionForward.
/**
* Sets under the session an attribute named forward with an ActionForward to the current
* request.
*/
public ActionForward setDefaultActionForward(HttpServletRequest request) {
HttpSession session = request.getSession();
// store the request uri with query parameters in an actionforward
String reqUri = getFullRequestUri(request);
ActionForward forward = new ActionForward();
forward.setPath(reqUri);
log.info("default forward set to :" + reqUri);
session.setAttribute("forward", forward);
return forward;
}
use of org.apache.struts.action.ActionForward in project iaf by ibissource.
the class ShowMonitors method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Initialize action
initAction(request);
if (ibisManager == null)
return (mapping.findForward("noIbisContext"));
String forward = null;
DynaActionForm monitorForm = getPersistentForm(mapping, form, request);
if (isCancelled(request)) {
log.debug("edit is canceled");
forward = determineExitForward(monitorForm);
} else {
// debugFormData(request,form);
String action = request.getParameter("action");
String indexStr = request.getParameter("index");
String triggerIndexStr = request.getParameter("triggerIndex");
int index = -1;
if (StringUtils.isNotEmpty(indexStr)) {
index = Integer.parseInt(indexStr);
}
int triggerIndex = -1;
if (StringUtils.isNotEmpty(triggerIndexStr)) {
triggerIndex = Integer.parseInt(triggerIndexStr);
}
MonitorManager mm = MonitorManager.getInstance();
if ("getStatus".equals(action)) {
response.setContentType("text/xml");
PrintWriter out = response.getWriter();
out.print(mm.getStatusXml().toXML());
out.close();
return null;
}
Lock lock = mm.getStructureLock();
try {
lock.acquireExclusive();
forward = performAction(monitorForm, action, index, triggerIndex, response);
log.debug("forward [" + forward + "] returned from performAction");
mm.reconfigure();
} catch (Exception e) {
error("could not perform action [" + action + "] on monitorIndex [" + index + "] triggerIndex [" + triggerIndex + "]", e);
} finally {
lock.releaseExclusive();
}
if (response.isCommitted()) {
return null;
}
}
if (StringUtils.isEmpty(forward)) {
log.debug("replacing empty forward with [success]");
forward = "success";
}
initForm(monitorForm);
ActionForward af = mapping.findForward(forward);
if (af == null) {
throw new ServletException("could not find forward [" + forward + "]");
}
// Forward control to the specified success URI
log.debug("forward to [" + forward + "], path [" + af.getPath() + "]");
return (af);
}
use of org.apache.struts.action.ActionForward in project zoj by licheng.
the class TestSubmitAction 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 {
Random ran = new Random();
submission.setJudgeReply(ran.nextInt() % 2 == 0 ? JudgeReply.WRONG_ANSWER : JudgeReply.ACCEPTED);
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