1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.web.struts.action; |
17 | |
|
18 | |
import java.util.HashMap; |
19 | |
import java.util.Map; |
20 | |
import java.util.Set; |
21 | |
|
22 | |
import javax.servlet.http.HttpServletRequest; |
23 | |
import javax.servlet.http.HttpServletResponse; |
24 | |
|
25 | |
import org.apache.struts.action.ActionForm; |
26 | |
import org.apache.struts.action.ActionForward; |
27 | |
import org.apache.struts.action.ActionMapping; |
28 | |
import org.kuali.rice.core.util.RiceConstants; |
29 | |
import org.kuali.rice.kim.bo.Person; |
30 | |
import org.kuali.rice.kns.document.Copyable; |
31 | |
import org.kuali.rice.kns.document.Document; |
32 | |
import org.kuali.rice.kns.document.authorization.TransactionalDocumentAuthorizer; |
33 | |
import org.kuali.rice.kns.document.authorization.TransactionalDocumentPresentationController; |
34 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
35 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
36 | |
import org.kuali.rice.kns.util.GlobalVariables; |
37 | |
import org.kuali.rice.kns.util.KNSConstants; |
38 | |
import org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase; |
39 | |
import org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | 0 | public class KualiTransactionalDocumentActionBase extends KualiDocumentActionBase { |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
51 | 0 | KualiTransactionalDocumentFormBase tmpForm = (KualiTransactionalDocumentFormBase) form; |
52 | |
|
53 | 0 | Document document = tmpForm.getDocument(); |
54 | |
|
55 | 0 | if (!tmpForm.getDocumentActions().containsKey(KNSConstants.KUALI_ACTION_CAN_COPY)) { |
56 | 0 | throw buildAuthorizationException("copy", document); |
57 | |
} |
58 | |
|
59 | 0 | ((Copyable) tmpForm.getTransactionalDocument()).toCopy(); |
60 | |
|
61 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
62 | |
} |
63 | |
|
64 | |
@SuppressWarnings("unchecked") |
65 | |
protected void populateAuthorizationFields(KualiDocumentFormBase formBase){ |
66 | 0 | super.populateAuthorizationFields(formBase); |
67 | 0 | Document document = formBase.getDocument(); |
68 | 0 | Map editMode = new HashMap(); |
69 | |
|
70 | 0 | if (formBase.isFormDocumentInitialized()) { |
71 | 0 | Person user = GlobalVariables.getUserSession().getPerson(); |
72 | |
|
73 | 0 | TransactionalDocumentPresentationController documentPresentationController = (TransactionalDocumentPresentationController) getDocumentHelperService().getDocumentPresentationController(document); |
74 | 0 | TransactionalDocumentAuthorizer documentAuthorizer = (TransactionalDocumentAuthorizer) KNSServiceLocatorWeb.getDocumentHelperService().getDocumentAuthorizer(document); |
75 | 0 | Set<String> editModes = documentAuthorizer.getEditModes(document, user, documentPresentationController.getEditModes(document)); |
76 | 0 | editMode = this.convertSetToMap(editModes); |
77 | 0 | if (getDataDictionaryService().getDataDictionary().getDocumentEntry(document.getClass().getName()).getUsePessimisticLocking()) { |
78 | 0 | editMode = getPessimisticLockService().establishLocks(document, editMode, user); |
79 | |
} |
80 | |
} |
81 | 0 | formBase.setEditingMode(editMode); |
82 | 0 | } |
83 | |
} |