1 package org.kuali.ole.describe.rule;
2
3 import org.kuali.ole.OLEConstants;
4 import org.kuali.rice.kim.api.identity.Person;
5 import org.kuali.rice.kim.api.permission.PermissionService;
6 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
7 import org.kuali.rice.krad.maintenance.MaintenanceViewAuthorizerBase;
8 import org.kuali.rice.krad.uif.field.Field;
9 import org.kuali.rice.krad.uif.view.View;
10 import org.kuali.rice.krad.uif.view.ViewModel;
11 import org.kuali.rice.krad.util.KRADConstants;
12
13
14
15
16 public class OleLocationLevelAuthoriser extends MaintenanceViewAuthorizerBase {
17
18
19
20
21
22
23
24
25
26
27
28 @Override
29 public boolean canEditField(View view, ViewModel model, Field field, String propertyName, Person user) {
30 PermissionService service = KimApiServiceLocator.getPermissionService();
31
32 boolean canEdit = service.hasPermission(user.getPrincipalId(), KRADConstants.KRAD_NAMESPACE, OLEConstants.OleLocationLevel.EDIT_LOCATION_LEVEL_PERM);
33
34
35
36 if (!field.getComponentSecurity().isEditAuthz() && field.getFieldLabel() != null && field.getFieldLabel().getLabelText() != null) {
37 String fieldName = field.getFieldLabel().getLabelText();
38 if (fieldName.equalsIgnoreCase(OLEConstants.OleLocationLevel.CODE) || fieldName.equalsIgnoreCase(OLEConstants.OleLocationLevel.PARENT_ID))
39 return false;
40 } else if (field.getComponentSecurity().isEditAuthz() && canEdit) {
41 return true;
42 } else {
43 return false;
44 }
45 return true;
46 }
47
48 }
49
50