@@ -0,0 +1,2533 @@
+package com.google.sps.servlets.course;%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.Key;%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.firebase.auth.FirebaseAuth;%0Aimport com.google.gson.Gson;%0Aimport com.google.sps.firebase.FirebaseAppManager;%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport javax.servlet.ServletConfig;%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/student-participants%22)%0Apublic class StudentParticipants extends HttpServlet %7B%0A  private FirebaseAuth authInstance;%0A  private DatastoreService datastore;%0A%0A  @Override%0A  public void init(ServletConfig config) throws ServletException %7B%0A    try %7B%0A      authInstance = FirebaseAuth.getInstance(FirebaseAppManager.getApp());%0A    %7D catch (IOException e) %7B%0A      throw new ServletException(e);%0A    %7D%0A  %7D%0A%0A  @Override%0A  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException %7B%0A    datastore = DatastoreServiceFactory.getDatastoreService();%0A%0A    try %7B%0A      ArrayList%3CString%3E classStudents = new ArrayList%3CString%3E();%0A%0A      // Retrieve class entity%0A      String classCode = request.getParameter(%22classCode%22).trim();%0A      Key classKey = KeyFactory.stringToKey(classCode);%0A%0A      // Filter for TAs that teach this class%0A      Query query =%0A          new Query(%22User%22)%0A              .setFilter(new FilterPredicate(%22registeredClasses%22, FilterOperator.EQUAL, classKey));%0A      PreparedQuery results = datastore.prepare(query);%0A%0A      // Store the TA emails%0A      for (Entity entity : results.asIterable()) %7B%0A        String email = (String) entity.getProperty(%22userEmail%22);%0A        classStudents.add(email);%0A      %7D%0A%0A      response.setContentType(%22application/json;%22);%0A      Gson gson = new Gson();%0A      String json = gson.toJson(classStudents);%0A      response.getWriter().println(json);%0A%0A    %7D catch (IllegalArgumentException e) %7B%0A      response.sendError(HttpServletResponse.SC_BAD_REQUEST);%0A    %7D%0A  %7D%0A%7D

Create student participants servlet.