@@ -0,0 +1,1788 @@
+import 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.EntityNotFoundException;%0Aimport com.google.appengine.api.datastore.Key;%0Aimport com.google.appengine.api.datastore.KeyFactory;%0Aimport com.google.sps.data.Recipe;%0Aimport com.google.sps.data.User;%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport javax.servlet.annotation.WebServlet;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0A@WebServlet(%22/shopping-list%22)%0Apublic class ShoppinListServlet extends HttpServlet %7B%0A%0A  @Override%0A  @SuppressWarnings(%22unchecked%22) // Compiler cannot verify cast to ArrayList%0A  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException %7B%0A    String idToken = request.getParameter(%22idToken%22);%0A    User user = new User(idToken);%0A    List%3CKey%3E plannerKeys = user.getPlannerList();%0A    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();%0A%0A    // Avoid repeating ingredients.%0A    HashSet%3CString%3E shoppingList = new HashSet%3C%3E();%0A%0A    plannerKeys.forEach(key -%3E %7B%0A      try %7B%0A        Entity entity = datastore.get(key);%0A        ArrayList%3CString%3E ingredients = (ArrayList%3CString%3E) entity.getProperty(%22ingredients%22);%0A        ingredients.forEach(ingredient -%3E shoppingList.add(ingredient));%0A%0A      %7D catch(EntityNotFoundException e) %7B%0A        System.out.prinln(%22Ignoring invalid key%22);%0A      %7D%0A    %7D);%0A%0A    Gson gson = new Gson();%0A    response.setContentType(%22application/json%22);%0A    response.getWriter().print(gson.toJson(shoppingList));%0A  %7D%0A%7D

Implement servlet for fetching user shopping list