@@ -0,0 +1,2810 @@
+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;%0Aimport com.google.sps.data.Card;%0A%0A@WebServlet(%22/deletecard%22)%0Apublic class DeleteCardServlet 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 cardKey = request.getParameter(%22cardKey%22);%0A      deleteCardFromDatastore(response, cardKey);%0A    %7D%0A  %7D%0A%0A  private void deleteCardFromDatastore(HttpServletResponse response, String cardKey) throws IOException %7B%0A    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();%0A    Entity card = getExistingCardInDatastore(response, datastore, cardKey);%0A    deleteBlob(card);%0A    deleteCard(datastore, card);%0A  %7D%0A%0A  private Entity getExistingCardInDatastore(HttpServletResponse response, DatastoreService datastore, String cardKey) throws IOException %7B%0A    Entity card;%0A    try %7B%0A      card = datastore.get(KeyFactory.stringToKey(cardKey));%0A    %7D catch (EntityNotFoundException e) %7B%0A      ResponseHandler.sendErrorMessage(response, %22Cannot edit Card at the moment%22);%0A      card = null;%0A    %7D%0A%0A    return card;%0A  %7D%0A%0A  private void deleteBlob(Entity card) throws IOException %7B%0A    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();%0A    String blobKey = (String) card.getProperty(%22blobKey%22);%0A    if (blobKey != %22null%22) %7B%0A      BlobKey key = new BlobKey(blobKey);%0A      blobstoreService.delete(key);%0A    %7D%0A  %7D%0A%0A  private void deleteCard(DatastoreService datastore, Entity card) %7B%0A    datastore.delete(card.getKey());%0A  %7D%0A%7D

Implement DeleteCardServlet.java