Exemplo n.º 1
0
  @GET
  @Path("/logs")
  @Produces("application/json")
  public String getLogs(@QueryParam("recv") String receiver) {
    List<LogViewModel> lvm = new ArrayList<LogViewModel>();
    List<Log> original = LogDB.listUserLogs(receiver);

    for (Log log : original) {
      log.setBody(log.getBody().replaceAll("(.{60})", "$1\n"));
      lvm.add(new LogViewModel(log));
    }
    String json = null;
    if (lvm.size() > 0) {
      Gson gson = new Gson();
      json = gson.toJson(lvm, ArrayList.class);
    }
    return json;
  }
Exemplo n.º 2
0
  @GET
  @Path("/feed")
  @Produces("application/json")
  public String getFeed(@QueryParam("user") String username) {
    User usr = new User();
    usr.setUsername(username);
    List<LogViewModel> lvm = new ArrayList<LogViewModel>();
    List<Log> original = LogDB.listUserFeed(usr);

    for (Log log : original) {
      log.setBody(log.getBody().replaceAll("(.{60})", "$1\n"));
      lvm.add(new LogViewModel(log));
    }
    String json = null;
    if (lvm.size() > 0) {
      Gson gson = new Gson();
      json = gson.toJson(lvm, ArrayList.class);
    }
    return json;
  }