class ProjectUpdateWhitelistService {

	@UseCaseUpdateProjectWhitelist(
			@Step(number = 2,
			name = "Update project",
			description = "The service will update the <<section-shared-project, Project whitelist>>."))
	/* @formatter:on */
	public void updateProjectWhitelist(String projectId, @NotNull List<URI> whitelist) {
		auditLog.log("triggers update of whitelist for project {}. Allowed URIs shall be {}", logSanitizer.sanitize(projectId, 30), whitelist);

		assertion.isValidProjectId(projectId);

		Optional<Project> found = repository.findById(projectId);
		if (!found.isPresent()) {
			throw new NotFoundException("Project '" + projectId + "' does not exist or you have now ");
		}
		/*
		 * TODO Albert Tregnaghi, 2018-09-06: currently we check only role SUPER_ADMIN.
		 * Because super admin is the only role having access. But when we got a project
		 * owner, the access to this project must be checked too! Here we should use
		 * permissions instead of roles then
		 */
		Project project = found.get();
		Set<URI> oldWhiteList = project.getWhiteList();
		oldWhiteList.clear();
		whitelist.stream().filter(uri -> uriValidation.validate(uri).isValid()).forEach(oldWhiteList::add);

		repository.save(project);

		sendProjectCreatedEvent(project.getId(), project.getWhiteList());

	}

}