Ejemplo n.º 1
0
  @POST
  @Produces("application/json")
  public EventResponse addEvent(String body) {

    EventQuery query = null;

    try {
      query = gson.fromJson(body, EventQuery.class);
    } catch (Exception e) {
      e.printStackTrace();
      return new EventResponse(2, "Invalid EventQuery Object", null);
    }

    if (query == null) {
      return new EventResponse(2, "Invalid EventQuery Object", null);
    }

    // CHECK THE TOKEN AUGHHH
    boolean eve;

    try {
      eve = eventService.addNewEvent(query.getEvent());
    } catch (Exception e) {
      e.printStackTrace();
      return new EventResponse(3, "FAILURE", null);
    }

    // Re-work event response - maybe make it an interface
    // SUCKSS UGH LIFE
    if (eve) {
      return new EventResponse(0, "OK", null);
    } else {
      return new EventResponse(4, "Failed to create object...somehow...", null);
    }
  }
Ejemplo n.º 2
0
  @GET
  @Produces("application/json")
  public EventResponse getEvents() {

    Map<Integer, List<EventSummary>> toRet;

    try {
      toRet = eventService.getEvents();
    } catch (Exception e) {
      e.printStackTrace();
      return new EventResponse(1, "FAILURE", null);
    }

    return new EventResponse(0, "OK", toRet);
  }