@@ -0,0 +1,2783 @@
+package com.google.sps.servlets;%0A%0Aimport com.google.appengine.api.users.UserService;%0Aimport com.google.appengine.api.users.UserServiceFactory;%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.EntityNotFoundException;%0A%0Aimport com.google.appengine.api.blobstore.BlobInfo;%0Aimport com.google.appengine.api.blobstore.BlobInfoFactory;%0Aimport com.google.appengine.api.blobstore.BlobKey;%0Aimport com.google.appengine.api.blobstore.BlobstoreService;%0Aimport com.google.appengine.api.blobstore.BlobstoreServiceFactory;%0A%0Aimport com.google.appengine.api.datastore.PreparedQuery;%0Aimport com.google.appengine.api.datastore.Query;%0A%0Aimport javax.servlet.annotation.WebServlet;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport java.io.IOException;%0Aimport com.google.gson.Gson;%0Aimport com.google.sps.tool.ResponseHandler;%0Aimport com.google.sps.data.Folder;%0A%0A@WebServlet(%22/deletefolder%22)%0Apublic class DeleteFolderServlet extends HttpServlet %7B%0A  %0A  @Override%0A  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException %7B%0A    UserService userService = UserServiceFactory.getUserService();%0A%0A    if (userService.isUserLoggedIn()) %7B%0A      String folderKey = request.getParameter(%22folderKey%22);%0A      deleteAllCardsInsideFolder(folderKey);%0A      deleteFolder(folderKey);%0A    %7D%0A  %7D%0A  %0A  private void deleteFolder(String folderKey) throws IOException %7B%0A    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();%0A    datastore.delete(KeyFactory.stringToKey(folderKey));%0A  %7D%0A%0A  private void deleteAllCardsInsideFolder(String folderKey) throws IOException %7B%0A%0A    Query cardQuery = new Query(%22Card%22).setAncestor(KeyFactory.stringToKey(folderKey));%0A%0A    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();%0A    PreparedQuery results = datastore.prepare(cardQuery);%0A%0A    if (results != null) %7B%0A      for (Entity card: results.asIterable()) %7B%0A        String blobKey = (String) card.getProperty(%22blobKey%22);%0A        if (blobKey != null) %7B%0A          deleteBlob(blobKey);%0A        %7D%0A        deleteCard(datastore, card);%0A      %7D   %0A    %7D%0A  %7D%0A%0A  private void deleteBlob(String blobKey) throws IOException %7B%0A    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();%0A    BlobKey key = new BlobKey(blobKey);%0A    blobstoreService.delete(key);%0A  %7D%0A%0A  private void deleteCard(DatastoreService datastore, Entity card) %7B%0A    datastore.delete(card.getKey());%0A  %7D%0A%7D

Implement DeleteFolderServlet.java