use of org.openlmis.stockmanagement.dto.referencedata.UserDto 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);
}
}
use of org.openlmis.stockmanagement.dto.referencedata.UserDto in project openlmis-stockmanagement by OpenLMIS.
the class StockoutNotifier method notifyStockEditors.
/**
* Notify user with "Edit stock inventories" right for the facility/program that
* facility has stocked out of a product.
*
* @param stockCard StockCard for a product
*/
public void notifyStockEditors(StockCard stockCard) {
Collection<UserDto> recipients = getEditors(stockCard);
String subject = getMessage(EMAIL_ACTION_REQUIRED_SUBJECT);
String content = getMessage(EMAIL_ACTION_REQUIRED_CONTENT);
Map<String, String> valuesMap = getValuesMap(stockCard);
StrSubstitutor sub = new StrSubstitutor(valuesMap);
for (UserDto recipient : recipients) {
if (recipient.getHomeFacilityId().equals(stockCard.getFacilityId()) && canBeNotified(recipient)) {
valuesMap.put("username", recipient.getUsername());
notificationService.notify(recipient, sub.replace(subject), sub.replace(content));
}
}
}
use of org.openlmis.stockmanagement.dto.referencedata.UserDto in project openlmis-stockmanagement by OpenLMIS.
the class BaseWebIntegrationTest method mockUserAuthenticated.
protected void mockUserAuthenticated() {
UserDto user = new UserDto();
user.setId(UUID.randomUUID());
user.setFirstName("admin");
user.setLastName("strator");
user.setEmail("admin@openlmis.org");
given(authenticationHelper.getCurrentUser()).willReturn(user);
}
Aggregations