@@ -0,0 +1,2448 @@
+package com.google.sps.servlets;%0A%0Aimport javax.servlet.annotation.WebServlet;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport java.lang.Process;%0Aimport java.io.IOException;%0Aimport java.io.BufferedReader;%0Aimport java.io.InputStreamReader;%0Aimport java.io.UnsupportedEncodingException;%0Aimport java.net.URLEncoder;%0Aimport java.nio.charset.StandardCharsets;%0Aimport java.util.List;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport com.google.gson.Gson;%0A%0A/** Servlet that actions items.*/%0A@WebServlet(%22/actions%22)%0Apublic class ActionsServlet extends HttpServlet %7B%0A%0A  private static final List%3CString%3E terms = Arrays.asList(%22Black Lives Matter%22, %22COVID-19%22);%0A%0A  @Override%0A  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException %7B%0A    List%3CString%3E jsonResultList = new ArrayList%3C%3E();%0A    String apiKey = %22API_KEY%22; //Insert the API_KEY here for testing%0A    for (String term : terms) %7B%0A      String queryTerm = encodeTerm(term);%0A      String jsonResult = curlProjects(apiKey, queryTerm);%0A      jsonResultList.add(jsonResult);%0A    %7D%0A%0A    String jsonResultString = %22%7B%5C%22results%5C%22: %5B%22+String.join(%22,%22, jsonResultList)+%22%5D%7D%22;%0A    response.setContentType(%22application/json;%22);%0A    response.getWriter().println(jsonResultString);%0A  %7D%0A%0A  private String encodeTerm(String term) throws RuntimeException %7B%0A    try %7B%0A        return URLEncoder.encode(term, StandardCharsets.UTF_8.toString());%0A    %7D catch (UnsupportedEncodingException ex) %7B%0A        throw new RuntimeException(ex.getCause());%0A    %7D%0A  %7D%0A%0A  private String curlProjects(String apiKey, String queryTerm) throws IOException%7B%0A    String path = %22https://api.globalgiving.org/api/public/services/search/projects%22;%0A    String queryString = String.format(%22?api_key=%25s&q=%25s%22, apiKey, queryTerm);%0A%0A%09%09String%5B%5D curlCommand = %7B %22curl%22, %22-H%22, %22Accept: application/json%22, %22-H%22, %22Content-Type: application/json%22, %22-X%22, %22GET%22, path+queryString%7D;%0A    ProcessBuilder process = new ProcessBuilder(curlCommand);%0A%09%09Process p = process.start();%0A    BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));%0A    StringBuilder builder = new StringBuilder();%0A    String line = null;%0A    while ((line = reader.readLine()) != null) %7B%0A      builder.append(line);%0A      builder.append(System.getProperty(%22line.separator%22));%0A    %7D%0A    return builder.toString();%0A  %7D%0A%7D%0A

Add java servlet to get action items