use of org.openlmis.stockmanagement.i18n.MessageKeys.ERROR_PROGRAM_NOT_SUPPORTED in project openlmis-stockmanagement by OpenLMIS.
the class HomeFacilityPermissionService method checkProgramSupported.
/**
* Check if program is supported by user's home facility.
*
* @param programId the program's id.
*/
public void checkProgramSupported(UUID programId) {
UUID homeFacilityId = authenticationHelper.getCurrentUser().getHomeFacilityId();
FacilityDto homeFacility = null;
if (homeFacilityId != null) {
homeFacility = facilityService.findOne(homeFacilityId);
}
boolean isSupported = homeFacility != null && homeFacility.getSupportedPrograms().stream().anyMatch(supportedProgram -> programId.equals(supportedProgram.getId()));
if (!isSupported) {
throwException(ERROR_PROGRAM_NOT_SUPPORTED, programId.toString());
}
}
Aggregations