1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.web.struts;
17
18 import java.util.ArrayList;
19
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.http.HttpServletResponse;
22
23 import org.apache.struts.action.ActionForm;
24 import org.apache.struts.action.ActionForward;
25 import org.apache.struts.action.ActionMapping;
26 import org.kuali.ole.sys.OLEConstants;
27 import org.kuali.ole.sys.context.SpringContext;
28 import org.kuali.ole.sys.document.Correctable;
29 import org.kuali.ole.sys.service.impl.OleParameterConstants;
30 import org.kuali.rice.core.api.util.RiceConstants;
31 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
32 import org.kuali.rice.kns.web.struts.action.KualiTransactionalDocumentActionBase;
33 import org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase;
34 import org.kuali.rice.kns.web.ui.ExtraButton;
35 import org.kuali.rice.krad.document.Document;
36 import org.kuali.rice.krad.util.KRADConstants;
37
38
39
40
41 public class FinancialSystemTransactionalDocumentActionBase extends KualiTransactionalDocumentActionBase {
42 public static final String MODULE_LOCKED_MESSAGE = "moduleLockedMessage";
43 public static final String MODULE_LOCKED_URL_SUFFIX = "/moduleLocked.do";
44
45
46
47
48
49
50
51
52
53
54
55
56 public ActionForward correct(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
57 KualiTransactionalDocumentFormBase tmpForm = (KualiTransactionalDocumentFormBase) form;
58
59 Document document = tmpForm.getDocument();
60
61 ((Correctable) tmpForm.getTransactionalDocument()).toErrorCorrection();
62 tmpForm.setExtraButtons(new ArrayList<ExtraButton>());
63
64 return mapping.findForward(RiceConstants.MAPPING_BASIC);
65 }
66
67 @Override
68
69
70
71 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
72
73 ActionForward returnForward = super.execute(mapping, form, request, response);
74 if( isDocumentLocked(mapping, form, request)) {
75 String message = SpringContext.getBean(ParameterService.class).getParameterValueAsString(OLEConstants.CoreModuleNamespaces.OLE, OleParameterConstants.PARAMETER_ALL_DETAIL_TYPE, OLEConstants.DOCUMENT_LOCKOUT_DEFAULT_MESSAGE);
76 request.setAttribute(MODULE_LOCKED_MESSAGE, message);
77 returnForward = mapping.findForward(RiceConstants.MODULE_LOCKED_MAPPING);
78 }
79
80 return returnForward;
81
82 }
83
84
85
86
87 protected boolean isDocumentLocked(ActionMapping mapping , ActionForm form, HttpServletRequest request) {
88 KualiTransactionalDocumentFormBase tmpForm = (KualiTransactionalDocumentFormBase) form;
89 Document document = tmpForm.getDocument();
90
91 boolean exists = SpringContext.getBean(ParameterService.class).parameterExists(document.getClass(),OLEConstants.DOCUMENT_LOCKOUT_PARM_NM );
92 if(exists) {
93 boolean documentLockedOut = SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(document.getClass(),OLEConstants.DOCUMENT_LOCKOUT_PARM_NM );
94 if(documentLockedOut) {
95 return tmpForm.getDocumentActions().containsKey(KRADConstants.KUALI_ACTION_CAN_EDIT);
96 }
97 }
98
99 return false;
100 }
101 }
102