@@ -0,0 +1,2544 @@
+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 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/editfolder%22)%0Apublic class EditFolderServlet extends HttpServlet%7B%0A  %0A  @Override%0A  public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException %7B%0A    %0A    UserService userService = UserServiceFactory.getUserService();%0A%0A    if (userService.isUserLoggedIn()) %7B%0A      String newFolderName = request.getParameter(%22folderName%22);%0A      String newFolderDefaultLanguage = request.getParameter(%22folderDefaultLanguage%22);%0A      String folderKey = request.getParameter(%22folderKey%22);%0A      updateFolder(response, newFolderName, newFolderDefaultLanguage, folderKey);%0A    %7D%0A  %7D%0A%0A  private void updateFolder(HttpServletResponse response, String newFolderName, String newFolderDefaultLanguage, String folderKey) throws IOException %7B%0A    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();%0A    Entity folder = getExistingFolderInDatastore(response, datastore, folderKey);%0A    setFolderWithRequestedEdits(folder, newFolderName, newFolderDefaultLanguage);%0A    datastore.put(folder);%0A  %7D%0A%0A  private Entity getExistingFolderInDatastore(HttpServletResponse response, DatastoreService datastore, String folderKey) throws IOException %7B%0A    Entity folder;%0A    try %7B%0A      folder = datastore.get(KeyFactory.stringToKey(folderKey));%0A    %7D catch (EntityNotFoundException e) %7B%0A      ResponseHandler.sendErrorMessage(response, %22Cannot edit Folder at the moment%22);%0A      folder = null;%0A    %7D%0A%0A    return folder;%0A  %7D%0A%0A  private void setFolderWithRequestedEdits(Entity folderEntity, String newFolderName, String newFolderDefaultLanguage) throws IOException %7B%0A    folderEntity.setProperty(%22folderName%22, newFolderName);%0A    folderEntity.setProperty(%22folderDefaultLanguage%22, newFolderDefaultLanguage);%0A  %7D%0A%7D%0A

Implement EditFolderServlet.java