class RdfEngine implements Engine {

    @Override
    public Optional<User> retrieveUser(String username) {
        try (RepositoryConnection conn = repository.getConnection()) {
            Optional<Resource> optId = getUserId(username, conn);
            if (!optId.isPresent()) {
                return Optional.empty();
            }

            Model userModel = mf.createModel();
            RepositoryResult<Statement> statements = conn.getStatements(optId.get(), null, null, context);
            statements.forEach(userModel::add);
            roles.stream()
                    .map(this::getRole)
                    .forEach(roleOptional -> roleOptional.ifPresent(role -> userModel.addAll(role.getModel())));

            return userFactory.getExisting(optId.get(), userModel);
        }
    }

}