Beispiel #1
0
  private int getCmsId(String orderBy) {

    Map<String, String> params = new LinkedHashMap<String, String>();

    params.put("pn", "1");
    params.put("pl", "2");
    params.put("fd", "title desc cmsurl thumburl publishtime");
    params.put("ob", orderBy);
    params.put("cl", "search_result");

    JSONObject resource = NovaMiddleResource.search("cms", "cms", "", params);

    if (resource == null || resource.isNull("results")) {
      for (int i = 0; i < 5; i++) {
        resource = NovaMiddleResource.search("cms", "cms", "", params);
        if (resource != null && !resource.isNull("results")) {
          break;
        }
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    }

    JSONArray showArray = resource.optJSONArray("results");
    if (!JSONUtil.isEmpty(showArray)) {
      return showArray.optJSONObject(0).optInt("cmsid");
    }
    return 0;
  }
Beispiel #2
0
  private JSONArray loadCmsByPkCms(int start, int end, int length) {
    String query =
        "cmsid:" + start + "-" + end + " type:topic state:published publishtime:{before1month}-";

    Map<String, String> params = new LinkedHashMap<String, String>();

    params.put("pn", "1");
    params.put("pl", "2");
    params.put("fd", "title desc cmsurl thumburl publishtime");
    params.put("ob", "publishtime:desc");
    params.put("cl", "search_result");

    JSONObject resource = NovaMiddleResource.search("cms", "cms", query, params);

    return JSONUtil.getProperty(resource, JSONArray.class, "results");
  }