package com.google.sps.servlets;

import com.google.sps.data.VolunteeringOpportunity;
import com.google.sps.utilities.CommonUtils;
import com.google.sps.utilities.DatabaseConstants;
import com.google.sps.utilities.SpannerTasks;
import java.io.IOException;
import java.util.Set;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/** Servlet to get all volunteering data for a given event */
@WebServlet("/event-volunteering-data")
public class EventVolunteeringDataServlet extends HttpServlet {
  private static final String HARDCODED_EVENT_ID = "0883de79-17d7-49a3-a866-dbd5135062a8";

  /**
   * Queries database for all opportunities with event ID given in the request parameter and writes
   * opportunities to the response.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws IOException if Input/Output error occurs
   */
  @Override
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    // TO DO: change eventId to parameter value
    Set<VolunteeringOpportunity> opportunities =
        SpannerTasks.getVolunteeringOpportunitiesByEventId(HARDCODED_EVENT_ID);

    response.setContentType("application/json;");
    response.getWriter().println(CommonUtils.convertToJson(opportunities));
  }
}

@@ -644,26 +644,16 @@
  String 
-HARDCODED_
 EVENT_ID
@@ -660,44 +660,16 @@
  = %22
-0883de79-17d7-49a3-a866-dbd5135062a8
+event-id
 %22;%0A%0A
@@ -1068,51 +1068,204 @@
     
-// TO DO: change eventId to parameter value
+String eventId = request.getParameter(EVENT_ID);%0A    if (eventId == null) %7B%0A      response.sendError(HttpServletResponse.SC_BAD_REQUEST, String.format(%22No event specified.%22));%0A      return;%0A    %7D%0A
 %0A   
@@ -1373,30 +1373,18 @@
 tId(
-HARDCODED_EVENT_ID
+eventId
 );%0A
-%0A
     

Add error checking in servlet and remove hardcoded event id.