appengine-java8/datastore/src/main/java/com/example/appengine/StartupServlet.java [91:118]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    resp.setContentType("text/plain");
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

    Key isPopulatedKey = KeyFactory.createKey(IS_POPULATED_ENTITY, IS_POPULATED_KEY_NAME);
    boolean isAlreadyPopulated;
    try {
      datastore.get(isPopulatedKey);
      isAlreadyPopulated = true;
    } catch (EntityNotFoundException expected) {
      isAlreadyPopulated = false;
    }
    if (isAlreadyPopulated) {
      resp.getWriter().println("ok");
      return;
    }

    ImmutableList.Builder<Entity> people = ImmutableList.builder();
    for (String name : US_PRESIDENTS) {
      Entity person = new Entity(PERSON_ENTITY);
      person.setProperty(NAME_PROPERTY, name);
      people.add(person);
    }
    datastore.put(people.build());
    datastore.put(new Entity(isPopulatedKey));
    resp.getWriter().println("ok");
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



appengine-java17-bundled-services/datastore/src/main/java/com/example/appengine/StartupServlet.java [91:118]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    resp.setContentType("text/plain");
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

    Key isPopulatedKey = KeyFactory.createKey(IS_POPULATED_ENTITY, IS_POPULATED_KEY_NAME);
    boolean isAlreadyPopulated;
    try {
      datastore.get(isPopulatedKey);
      isAlreadyPopulated = true;
    } catch (EntityNotFoundException expected) {
      isAlreadyPopulated = false;
    }
    if (isAlreadyPopulated) {
      resp.getWriter().println("ok");
      return;
    }

    ImmutableList.Builder<Entity> people = ImmutableList.builder();
    for (String name : US_PRESIDENTS) {
      Entity person = new Entity(PERSON_ENTITY);
      person.setProperty(NAME_PROPERTY, name);
      people.add(person);
    }
    datastore.put(people.build());
    datastore.put(new Entity(isPopulatedKey));
    resp.getWriter().println("ok");
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



appengine-java11-bundled-services/datastore/src/main/java/com/example/appengine/StartupServlet.java [91:118]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    resp.setContentType("text/plain");
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

    Key isPopulatedKey = KeyFactory.createKey(IS_POPULATED_ENTITY, IS_POPULATED_KEY_NAME);
    boolean isAlreadyPopulated;
    try {
      datastore.get(isPopulatedKey);
      isAlreadyPopulated = true;
    } catch (EntityNotFoundException expected) {
      isAlreadyPopulated = false;
    }
    if (isAlreadyPopulated) {
      resp.getWriter().println("ok");
      return;
    }

    ImmutableList.Builder<Entity> people = ImmutableList.builder();
    for (String name : US_PRESIDENTS) {
      Entity person = new Entity(PERSON_ENTITY);
      person.setProperty(NAME_PROPERTY, name);
      people.add(person);
    }
    datastore.put(people.build());
    datastore.put(new Entity(isPopulatedKey));
    resp.getWriter().println("ok");
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



