Ejemplo n.º 1
0
  public void doPut(HttpServletRequest request, HttpServletResponse response)
      throws ServletException {
    DeckForm df = new DeckForm();
    Gson gson = new Gson();

    try {
      Deck nwDeck = df.ModifyDeck(request);
      if (nwDeck == null) {
        ErrorMessage em = new ErrorMessage("Forbidden", HttpServletResponse.SC_FORBIDDEN);
        String json = gson.toJson(em);
        response = UserForm.setJsonResponse(response, json, HttpServletResponse.SC_FORBIDDEN);
      }
    } catch (ResponseException e) {
      ErrorMessage em = new ErrorMessage(e);
      String json = gson.toJson(em);
      response = UserForm.setJsonResponse(response, json, e.getErrorcode());
    }
  }
Ejemplo n.º 2
0
  public void doDelete(HttpServletRequest request, HttpServletResponse response)
      throws ServletException {
    DeckForm rf = new DeckForm();
    Gson gson = new Gson();

    try {
      boolean res = rf.DeleteDeck(request);
      if (res == false) {
        ErrorMessage em = new ErrorMessage("Forbidden", HttpServletResponse.SC_FORBIDDEN);
        String json = gson.toJson(em);
        response = UserForm.setJsonResponse(response, json, HttpServletResponse.SC_FORBIDDEN);
      }
    } catch (ResponseException e) {
      ErrorMessage em = new ErrorMessage(e);
      String json = gson.toJson(em);
      response = UserForm.setJsonResponse(response, json, e.getErrorcode());
    }
  }
Ejemplo n.º 3
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException {
    DeckForm rf = new DeckForm();
    Deck a = null;
    Gson gson = new Gson();

    try {
      a = rf.GetDeck(request);
      if (a == null) {
        ErrorMessage em = new ErrorMessage("Forbidden", HttpServletResponse.SC_FORBIDDEN);
        String json = gson.toJson(em);
        response = UserForm.setJsonResponse(response, json, HttpServletResponse.SC_FORBIDDEN);
      } else {
        String json = gson.toJson(a);
        response = UserForm.setJsonResponse(response, json, HttpServletResponse.SC_OK);
      }
    } catch (ResponseException e) {
      ErrorMessage em = new ErrorMessage(e);
      String json = gson.toJson(em);
      response = UserForm.setJsonResponse(response, json, e.getErrorcode());
    }
  }