Search in sources :

Example 1 with SurveyTemplate

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);
        }
    });
}
Also used : SurveyTemplate(org.finos.waltz.model.survey.SurveyTemplate) Person(org.finos.waltz.model.person.Person)

Aggregations

Person (org.finos.waltz.model.person.Person)1 SurveyTemplate (org.finos.waltz.model.survey.SurveyTemplate)1