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.api.identity.Person;
19 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
20 import org.kuali.rice.kim.api.type.KimTypeInfoService;
21 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
22 import org.kuali.rice.krad.document.authorization.DocumentAuthorizer;
23 import org.kuali.rice.krad.document.authorization.DocumentPresentationController;
24 import org.kuali.rice.krad.service.DocumentHelperService;
25 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
26 import org.kuali.rice.krad.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 = KRADServiceLocatorWeb.getDocumentHelperService();
55 }
56 return documentHelperService;
57 }
58
59 protected KimTypeInfoService getTypeInfoService() {
60 if ( typeInfoService == null ) {
61 typeInfoService = KimApiServiceLocator.getKimTypeInfoService();
62 }
63 return typeInfoService;
64 }
65 }