Ejemplo n.º 1
0
  public String respond(Reader requestData) {
    long startTime = clock.currentTime();

    Gson gson = new Gson();

    List<String> checks = null;

    try {
      checks = gson.fromJson(GetPostData(requestData), requestType());
    } catch (Exception ex) {
      System.err.println(ex.getMessage());
    }

    LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>();

    if (checks != null) {
      for (String amount : checks) {

        if (clock.IsOverTime(startTime)) {
          break;
        }

        Long parsedValue = checkParser.parseExpression(amount);
        if (parsedValue == null) {
          System.err.println("could not parse amount " + amount);
        } else {
          map.put(amount, parsedValue);
        }

        // don't save when upload google appengine
        // it will cause timeout issue !!!
        //
        dataStore.saveRow("Checks", amount);
      }
    }

    // if we want to display "&" rather than "\u0026"
    // return new GsonBuilder().disableHtmlEscaping().create().toString(map);
    return gson.toJson(map);
  }