<commit_before>package com.google.sampling.experiential.server;

import java.util.Iterator;
import java.util.List;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.api.datastore.Query.FilterOperator;
import com.google.appengine.api.datastore.QueryResultIterator;
import com.google.common.collect.Lists;

public class DBWhitelist extends Whitelist {
  
  private static final String EMAIL_PROPERTY = "email";
  private static final String WHITELISTED_USER_KIND = "whitelist";


  @Override
  public boolean allowed(String email) {
    email = email.toLowerCase();
    return isAdmin(email) || getUserByEmail(email) != null;
  }

  private String getUserByEmail(String email) {
    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    Query query = new Query(WHITELISTED_USER_KIND);
    query.addFilter(EMAIL_PROPERTY, FilterOperator.EQUAL, email);
    PreparedQuery preparedQuery = ds.prepare(query);    
    Iterator<Entity> iterator = preparedQuery.asIterator();
    Entity user = null;
    if (iterator.hasNext()) {
      user = iterator.next();
    }
    return user != null ? (String)user.getProperty(EMAIL_PROPERTY) : null;
  }<commit_msg>added missing method to DBWhitelist<commit_after>package com.google.sampling.experiential.server;

import java.util.Iterator;
import java.util.List;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.api.datastore.Query.FilterOperator;
import com.google.appengine.api.datastore.QueryResultIterator;
import com.google.common.collect.Lists;

public class DBWhitelist extends Whitelist {
  
  private static final String EMAIL_PROPERTY = "email";
  private static final String WHITELISTED_USER_KIND = "whitelist";


  @Override
  public boolean allowed(String email) {
    email = email.toLowerCase();
    return isAdmin(email) || getUserByEmail(email) != null;
  }

  protected boolean isAdmin(String email) {
    return false;
  }
  
  private String getUserByEmail(String email) {
    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    Query query = new Query(WHITELISTED_USER_KIND);
    query.addFilter(EMAIL_PROPERTY, FilterOperator.EQUAL, email);
    PreparedQuery preparedQuery = ds.prepare(query);    
    Iterator<Entity> iterator = preparedQuery.asIterator();
    Entity user = null;
    if (iterator.hasNext()) {
      user = iterator.next();
    }
    return user != null ? (String)user.getProperty(EMAIL_PROPERTY) : null;
  }
{'fraction_non_alphanumeric': 0.10084889643463497, 'fraction_numerical': 0.0, 'mean_word_length': 4.939516129032258, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4941698', 'n_tokens_mistral': 905, 'n_tokens_neox': 900, 'n_words': 174}