|
33 | 33 | import org.openmrs.ui.framework.annotation.SpringBean; |
34 | 34 | import org.openmrs.ui.framework.page.PageModel; |
35 | 35 | import org.openmrs.ui.framework.page.PageRequest; |
| 36 | +import org.openmrs.util.PrivilegeConstants; |
36 | 37 | import org.openmrs.web.user.CurrentUsers; |
37 | 38 | import org.springframework.stereotype.Controller; |
38 | 39 | import org.springframework.web.bind.annotation.CookieValue; |
@@ -150,10 +151,16 @@ public String get(PageModel model, UiUtils ui, PageRequest pageRequest, |
150 | 151 | } |
151 | 152 |
|
152 | 153 | private boolean isLocationUserPropertyAvailable(AdministrationService administrationService) { |
153 | | - String locationUserPropertyName = administrationService |
154 | | - .getGlobalProperty(ReferenceApplicationConstants.LOCATION_USER_PROPERTY_NAME); |
155 | | - |
156 | | - return StringUtils.isNotBlank(locationUserPropertyName); |
| 154 | + try { |
| 155 | + Context.addProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES); |
| 156 | + String locationUserPropertyName = administrationService |
| 157 | + .getGlobalProperty(ReferenceApplicationConstants.LOCATION_USER_PROPERTY_NAME); |
| 158 | + |
| 159 | + return StringUtils.isNotBlank(locationUserPropertyName); |
| 160 | + } finally { |
| 161 | + Context.removeProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES); |
| 162 | + } |
| 163 | + |
157 | 164 | } |
158 | 165 |
|
159 | 166 | private boolean isUrlWithinOpenmrs(PageRequest pageRequest, String redirectUrl) { |
@@ -376,8 +383,14 @@ private boolean isSameUser(PageRequest pageRequest, String username) { |
376 | 383 | } |
377 | 384 |
|
378 | 385 | private List<Location> getUserLocations(AdministrationService adminService, LocationService locationService) { |
379 | | - String locationUserPropertyName = adminService |
380 | | - .getGlobalProperty(ReferenceApplicationConstants.LOCATION_USER_PROPERTY_NAME); |
| 386 | + String locationUserPropertyName; |
| 387 | + try { |
| 388 | + Context.addProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES); |
| 389 | + locationUserPropertyName = adminService.getGlobalProperty(ReferenceApplicationConstants.LOCATION_USER_PROPERTY_NAME); |
| 390 | + } |
| 391 | + finally { |
| 392 | + Context.removeProxyPrivilege(PrivilegeConstants.GET_GLOBAL_PROPERTIES); |
| 393 | + } |
381 | 394 | List<Location> locations = new ArrayList(); |
382 | 395 | String locationUuids = Context.getAuthenticatedUser().getUserProperty(locationUserPropertyName); |
383 | 396 | if (StringUtils.isNotBlank(locationUuids)) { |
|
0 commit comments