1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.lookup;
17
18 import org.kuali.rice.kim.bo.Person;
19 import org.kuali.rice.kim.service.KIMServiceLocator;
20 import org.kuali.rice.kim.service.KimTypeInfoService;
21 import org.kuali.rice.kns.document.authorization.DocumentAuthorizer;
22 import org.kuali.rice.kns.document.authorization.DocumentPresentationController;
23 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
24 import org.kuali.rice.kns.service.DocumentHelperService;
25 import org.kuali.rice.kns.service.KNSServiceLocator;
26 import org.kuali.rice.kns.util.GlobalVariables;
27
28
29
30
31
32
33
34 public class KimLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl {
35
36 private static final long serialVersionUID = 1L;
37
38 private static DocumentHelperService documentHelperService;
39 private static KimTypeInfoService typeInfoService;
40
41 @Override
42 public boolean allowsNewOrCopyAction(String documentTypeName) {
43
44 DocumentAuthorizer documentAuthorizer = getDocumentHelperService().getDocumentAuthorizer(documentTypeName);
45 DocumentPresentationController documentPresentationController = getDocumentHelperService().getDocumentPresentationController(documentTypeName);
46
47 Person currentUser = GlobalVariables.getUserSession().getPerson();
48 return documentPresentationController.canInitiate(documentTypeName) && documentAuthorizer.canInitiate(documentTypeName, currentUser);
49
50 }
51
52 protected DocumentHelperService getDocumentHelperService() {
53 if ( documentHelperService == null ) {
54 documentHelperService = KNSServiceLocator.getDocumentHelperService();
55 }
56 return documentHelperService;
57 }
58
59 protected KimTypeInfoService getTypeInfoService() {
60 if ( typeInfoService == null ) {
61 typeInfoService = KIMServiceLocator.getTypeInfoService();
62 }
63 return typeInfoService;
64 }
65 }