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