use of org.finos.waltz.model.survey.SurveyTemplate in project waltz by khartec.
the class SurveyTemplateEndpoint method ensureUserIsOwnerOrAdmin.
private void ensureUserIsOwnerOrAdmin(Request request, Long templateId, String username) {
Person person = personService.getPersonByUserId(username);
if (person == null) {
throw new IllegalArgumentException("User not found");
}
SurveyTemplate template = surveyTemplateService.getById(templateId);
// if person record found id is always present
person.id().ifPresent(id -> {
if (template.ownerId().equals(id)) {
WebUtilities.requireRole(userRoleService, request, SystemRole.SURVEY_TEMPLATE_ADMIN);
} else {
WebUtilities.requireRole(userRoleService, request, SystemRole.ADMIN);
}
});
}
Aggregations