예제 #1
0
  /**
   * Retrieves visitor information from web client in JSON format
   *
   * @param content
   */
  @POST
  @Consumes("application/json")
  public Response log(String content) {
    logger.log(Level.FINE, "Client input: {0}", content);

    Visit visit = null;
    Gson gson = new Gson();
    try {
      visit = gson.fromJson(content, Visit.class);
    } catch (JsonSyntaxException e) {
      // Deserialization went wrong
      throw new WebApplicationException(e, Response.status(Response.Status.BAD_REQUEST).build());
    }
    dataProvider.persistVisit(visit);
    logger.log(Level.FINE, content);
    return Response.noContent().build();
  }
예제 #2
0
 /**
  * Gets Data for the map
  *
  * @return json object with data for the map.
  */
 @GET
 @Produces("application/json")
 public Response getData() {
   return Response.ok(dataProvider.getCountries()).build();
 }