@@ -0,0 +1,2893 @@
+package com.google.sps.servlets;%0A%0Aimport com.google.appengine.api.datastore.DatastoreService;%0Aimport com.google.appengine.api.datastore.DatastoreServiceConfig;%0Aimport com.google.appengine.api.datastore.DatastoreServiceFactory;%0Aimport com.google.appengine.api.datastore.EmbeddedEntity;%0Aimport com.google.appengine.api.datastore.Entity;%0Aimport com.google.appengine.api.datastore.EntityNotFoundException;%0Aimport com.google.appengine.api.datastore.Key;%0Aimport com.google.appengine.api.datastore.KeyFactory;%0Aimport com.google.firebase.auth.FirebaseAuth;%0Aimport com.google.firebase.auth.FirebaseAuthException;%0Aimport com.google.firebase.auth.FirebaseToken;%0Aimport com.google.firebase.auth.UserRecord;%0Aimport com.google.gson.Gson;%0Aimport com.google.sps.firebase.FirebaseAppManager;%0Aimport java.io.IOException;%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/get-ta%22)%0Apublic class GetTAHelping extends HttpServlet %7B%0A  FirebaseAuth authInstance;%0A  DatastoreService datastore;%0A  Gson gson;%0A%0A  @Override%0A  public void init(ServletConfig config) throws ServletException %7B%0A    try %7B%0A      authInstance = FirebaseAuth.getInstance(FirebaseAppManager.getApp());%0A      gson = new Gson();%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    System.setProperty(%0A        DatastoreServiceConfig.DATASTORE_EMPTY_LIST_SUPPORT, Boolean.TRUE.toString());%0A%0A    try %7B%0A      // Retrive class entity%0A      String classCode = request.getParameter(%22classCode%22).trim();%0A      Key classKey = KeyFactory.stringToKey(classCode);%0A      Entity classEntity = datastore.get(classKey);%0A%0A      String studentToken = request.getParameter(%22studentToken%22);%0A      FirebaseToken decodedToken = authInstance.verifyIdToken(studentToken);%0A      String studentID = decodedToken.getUid();%0A%0A      // Get TA id%0A      EmbeddedEntity beingHelped = (EmbeddedEntity) classEntity.getProperty(%22beingHelped%22);%0A      String taID = (String) beingHelped.getProperty(studentID);%0A%0A      // Get TA email%0A      UserRecord userRecord = authInstance.getUser(taID);%0A      String taEmail = userRecord.getEmail();%0A%0A      response.setContentType(%22application/json;%22);%0A      response.getWriter().print(gson.toJson(taEmail));%0A%0A    %7D catch (EntityNotFoundException e) %7B%0A      response.sendError(HttpServletResponse.SC_NOT_FOUND);%0A    %7D catch (IllegalArgumentException e) %7B%0A      response.sendError(HttpServletResponse.SC_BAD_REQUEST);%0A    %7D catch (FirebaseAuthException e) %7B%0A      response.sendError(HttpServletResponse.SC_FORBIDDEN);%0A    %7D%0A  %7D%0A%7D%0A

Create servlet to get TA email helping student