use of org.openlmis.stockmanagement.dto.referencedata.RightDto in project openlmis-stockmanagement by OpenLMIS.
the class StockoutNotifier method getEditors.
private Collection<UserDto> getEditors(StockCard stockCard) {
RightDto right = rightReferenceDataService.findRight(STOCK_INVENTORIES_EDIT);
SupervisoryNodeDto supervisoryNode = supervisoryNodeReferenceDataService.findSupervisoryNode(stockCard.getProgramId(), stockCard.getFacilityId());
if (supervisoryNode == null) {
throw new IllegalArgumentException(String.format("There is no supervisory node for program %s and facility %s", stockCard.getProgramId(), stockCard.getFacilityId()));
}
return supervisingUsersReferenceDataService.findAll(supervisoryNode.getId(), right.getId(), stockCard.getProgramId());
}
use of org.openlmis.stockmanagement.dto.referencedata.RightDto in project openlmis-stockmanagement by OpenLMIS.
the class AuthenticationHelperTest method shouldReturnRight.
@Test
public void shouldReturnRight() throws Exception {
// given
RightDto right = mock(RightDto.class);
when(rightReferenceDataService.findRight(anyString())).thenReturn(right);
// when
RightDto dto = authenticationHelper.getRight("rightName");
// then
assertNotNull(dto);
assertThat(dto, is(right));
}
use of org.openlmis.stockmanagement.dto.referencedata.RightDto in project openlmis-stockmanagement by OpenLMIS.
the class PermissionService method checkUserToken.
private ResultDto<Boolean> checkUserToken(String rightName, UUID program, UUID facility, UUID warehouse) {
UserDto user = authenticationHelper.getCurrentUser();
RightDto right = authenticationHelper.getRight(rightName);
try {
return userReferenceDataService.hasRight(user.getId(), right.getId(), program, facility, warehouse);
} catch (HttpClientErrorException httpException) {
throw new PermissionMessageException(new Message(ERROR_PERMISSION_CHECK_FAILED, httpException.getMessage()), httpException);
}
}
Aggregations