1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.authorization;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.kim.api.identity.Person;
20 import org.kuali.rice.krad.document.DocumentAuthorizerBase;
21 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
22 import org.kuali.rice.krad.maintenance.MaintenanceDocumentAuthorizer;
23 import org.kuali.rice.krms.api.KrmsConstants;
24 import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
25 import org.kuali.rice.krms.impl.ui.AgendaEditor;
26
27 import java.util.HashSet;
28 import java.util.Set;
29
30 public class AgendaEditorAuthorizer extends DocumentAuthorizerBase implements MaintenanceDocumentAuthorizer {
31
32 @Override
33 public boolean canCreate(Class boClass, Person user) {
34
35
36 return true;
37 }
38
39 @Override
40 public boolean canMaintain(Object dataObject, Person user) {
41 AgendaEditor agendaEditor = (AgendaEditor) dataObject;
42 return getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, agendaEditor.getAgenda().getContextId());
43 }
44
45 @Override
46 public boolean canCreateOrMaintain(MaintenanceDocument maintenanceDocument, Person user) {
47 AgendaEditor agendaEditor = (AgendaEditor) maintenanceDocument.getOldMaintainableObject().getDataObject();
48 if (StringUtils.isEmpty(agendaEditor.getAgenda().getContextId())) {
49
50 agendaEditor = (AgendaEditor) maintenanceDocument.getNewMaintainableObject().getDataObject();
51 return getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, agendaEditor.getAgenda().getContextId());
52 } else {
53 return getAgendaAuthorizationService().isAuthorized(KrmsConstants.MAINTAIN_KRMS_AGENDA, agendaEditor.getAgenda().getContextId());
54 }
55 }
56
57 private AgendaAuthorizationService getAgendaAuthorizationService() {
58 return KrmsRepositoryServiceLocator.getAgendaAuthorizationService();
59 }
60 }