コード例 #1
0
  /**
   * Returns a Page of DocumentPackages, that last updated in time range, which represents a
   * paginated query response. Important once you have many DocumentPackages.
   *
   * @param status Returned DocumentPackages must have their status set to this value to be included
   *     in the result set
   * @param request Identifying which page of results to return
   * @param from Date range starting from this date included
   * @param to Date range ending of this date included
   * @return List of DocumentPackages that populate the specified page
   */
  public Page<DocumentPackage> getUpdatedPackagesWithinDateRange(
      PackageStatus status, PageRequest request, Date from, Date to) {
    String fromDate = DateHelper.dateToIsoUtcFormat(from);
    String toDate = DateHelper.dateToIsoUtcFormat(to);

    String path =
        template
            .urlFor(UrlTemplate.PACKAGE_LIST_STATUS_DATE_RANGE_PATH)
            .replace("{status}", new PackageStatusConverter(status).toAPIPackageStatus())
            .replace("{from}", Integer.toString(request.getFrom()))
            .replace("{to}", Integer.toString(request.to()))
            .replace("{lastUpdatedStartDate}", fromDate)
            .replace("{lastUpdatedEndDate}", toDate)
            .build();

    try {
      String response = client.get(path);
      Result<Package> results =
          JacksonUtil.deserialize(response, new TypeReference<Result<Package>>() {});
      return convertToPage(results, request);
    } catch (RequestException e) {
      throw new EslServerException("Could not get package list.", e);
    } catch (Exception e) {
      e.printStackTrace();
      throw new EslException("Could not get package list. Exception: " + e.getMessage());
    }
  }
コード例 #2
0
  public Page<DocumentPackage> getTemplates(PageRequest request) {
    String path =
        template
            .urlFor(UrlTemplate.TEMPLATE_LIST_PATH)
            .replace("{from}", Integer.toString(request.getFrom()))
            .replace("{to}", Integer.toString(request.to()))
            .build();

    try {
      String response = client.get(path);
      Result<Package> results =
          JacksonUtil.deserialize(response, new TypeReference<Result<Package>>() {});

      return convertToPage(results, request);
    } catch (RequestException e) {
      throw new EslServerException("Could not get template list.", e);
    } catch (Exception e) {
      throw new EslException("Could not get template list. Exception: " + e.getMessage());
    }
  }