@@ -0,0 +1,1807 @@
+package com.google.sps.servlets;%0A%0Aimport com.google.appengine.api.datastore.DatastoreService;%0Aimport com.google.appengine.api.datastore.DatastoreServiceFactory;%0Aimport com.google.appengine.api.datastore.Entity;%0Aimport com.google.appengine.api.datastore.KeyFactory;%0Aimport com.google.appengine.api.datastore.PreparedQuery;%0Aimport com.google.appengine.api.datastore.Query;%0Aimport com.google.appengine.api.datastore.Query.FilterOperator;%0Aimport com.google.appengine.api.datastore.Query.FilterPredicate;%0Aimport com.google.gson.Gson;%0Aimport com.google.sps.environment.Environment;%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.annotation.WebServlet;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0A@WebServlet(%22/getEnvironments%22)%0Apublic class GetEnvironments extends HttpServlet %7B%0A  @Override%0A  protected void doGet(HttpServletRequest req, HttpServletResponse resp)%0A      throws ServletException, IOException %7B%0A    String classID = req.getParameter(%22classID%22);%0A%0A    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();%0A%0A    PreparedQuery q =%0A        datastore.prepare(%0A            new Query(%22Environment%22)%0A                .setFilter(%0A                    new FilterPredicate(%0A                        %22class%22, FilterOperator.EQUAL, KeyFactory.stringToKey(classID))));%0A%0A    List%3CEnvironment%3E envs = new ArrayList%3C%3E();%0A%0A    for (Entity e : q.asIterable()) %7B%0A      envs.add(%0A          new Environment(%0A              (String) e.getProperty(%22name%22),%0A              (String) e.getProperty(%22status%22),%0A              KeyFactory.keyToString(e.getKey())));%0A    %7D%0A%0A    resp.getWriter().println(new Gson().toJson(envs));%0A  %7D%0A%7D%0A

Add GetEnvironments servlet to get all environments for a class.