import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;










/** **/
@WebServlet("/userfolders")
public class UserFoldersServlet extends HttpServlet {

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

  }








  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {

      
  }
    
}
@@ -4,43 +4,117 @@
 ort 
-javax.serv
+com.google.gson.Gson;%0Aimport java.io.IOException;%0A%0Aimport com.goog
 le
-t
 .a
-nnotation.Web
+ppengine.api.datastore.Datastore
 Serv
-let
+ice
 ;%0Aim
@@ -122,168 +122,479 @@
 ort 
-javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport java.io.IOException;%0A%0A%0A%0A%0A%0A%0A%0A
+com.google.appengine.api.datastore.DatastoreServiceFactory;%0Aimport com.google.appengine.api.datastore.Entity;%0Aimport com.google.appengine.api.datastore.PreparedQuery;%0Aimport com.google.appengine.api.datastore.Query;%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.sps.data.Folder;%0Aimport java.util.List; %0Aimport java.util.ArrayList;
 %0A%0A%0A/
@@ -683,16 +683,79 @@
 vlet %7B%0A%0A
+  /**%0A  * Query all folders from current user%0A  */%0A  @Override%0A
   public
@@ -849,135 +849,1561 @@
 n %7B%0A
-%0A  %7D%0A%0A%0A%0A%0A%0A%0A%0A%0A  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException %7B%0A%0A      %0A
+    %0A    UserService userService = UserServiceFactory.getUserService();%0A%0A    if (userService.isUserLoggedIn()) %7B%0A%0A      List%3CFolder%3E userFolders = new ArrayList%3C%3E();%0A%0A      String userKey = request.getParameter(%22userKey%22);%0A%0A      // Query all folders identified by the userKey%0A      Query folderQuery = new Query(%22Folder%22).setAncestor(userKey);%0A%0A      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();%0A      PreparedQuery results = datastore.prepare(folderQuery);%0A%0A      // Add folders to a list%0A      for (Entity entity: results.asIterable()) %7B%0A        Folder folder = Folder.EntityToFolder(entity);%0A        userFolders.add(folder);%0A      %7D%0A      %0A      response.setContentType(%22application/json;%22);%0A      response.getWriter().println(new Gson().toJson(userFolders));%0A    %7D%0A  %7D%0A  %0A  /**%0A  ** Store new folder into Datastore%0A  **/%0A%0A  @Override%0A  public void doPost(HttpServletRequest request, HttpServletResponse response) %7B%0A%0A    UserService userService = UserServiceFactory.getUserService();%0A%0A    if (userService.isUserLoggedIn()) %7B%0A      %0A      String folderName = request.getParameter(%22folderName%22);%0A      String folderDefaultLanguage = request.getParameter(%22folderDefaultLanguage%22);%0A      String userKey = request.getParameter(%22userKey%22);%0A%0A      Folder folder = new Folder(folderName, folderDefaultLanguage);%0A      Entity folderEntity = folder.createEntity(KeyFactory.stringToKey(userKey));%0A      %0A      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();%0A      datastore.put(folderEntity);%0A  
   %7D%0A  
- 
+%7D
  %0A%7D

Implement UserFoldersServlet