Exemplo n.º 1
0
 static BatchInfo loadBatchInfo(InputStream in)
     throws PullParserException, IOException, ConnectionException {
   BatchInfo info = new BatchInfo();
   XmlInputStream xin = new XmlInputStream();
   xin.setInput(in, "UTF-8");
   info.load(xin, BulkConnection.typeMapper);
   return info;
 }
Exemplo n.º 2
0
  public BatchInfo getBatchInfo(String jobId, String batchId) throws AsyncApiException {
    try {
      String endpoint = getRestEndpoint() + "job/" + jobId + "/batch/" + batchId;
      URL url = new URL(endpoint);
      InputStream stream = doHttpGet(url);

      XmlInputStream xin = new XmlInputStream();
      xin.setInput(stream, "UTF-8");
      BatchInfo result = new BatchInfo();
      result.load(xin, typeMapper);
      return result;
    } catch (IOException e) {
      throw new AsyncApiException(
          "Failed to parse batch info ", AsyncExceptionCode.ClientInputError, e);
    } catch (PullParserException e) {
      throw new AsyncApiException(
          "Failed to parse batch info ", AsyncExceptionCode.ClientInputError, e);
    } catch (ConnectionException e) {
      throw new AsyncApiException(
          "Failed to parse batch info ", AsyncExceptionCode.ClientInputError, e);
    }
  }
Exemplo n.º 3
0
  @WebMethod
  public ModifiedDocumentDescriptor[] listModifiedDocuments(
      @WebParam(name = "sessionId") String sessionId,
      @WebParam(name = "dataRangeQuery") String dateRangeQuery) {
    initSession(sessionId);

    BatchInfo batchInfo = BatchHelper.getBatchInfo(sessionId, dateRangeQuery);

    List<LogEntry> logEntries =
        getLogsBean()
            .queryLogsByPage(
                null,
                batchInfo.getPageDateRange(),
                EVENT_DOCUMENT_CATEGORY,
                null,
                batchInfo.getNextPage(),
                batchInfo.getPageSize());
    if (logEntries.size() < batchInfo.getPageSize()) {
      // we are at the end of the batch
      // ==> reset the batch
      BatchHelper.resetBatchInfo(sessionId);
    } else {
      // set the batchInfo ready for next call
      batchInfo.prepareNextCall();
    }

    List<ModifiedDocumentDescriptor> ldocs = new ArrayList<ModifiedDocumentDescriptor>();
    Set<String> uuids = new HashSet<String>();
    for (LogEntry logEntry : logEntries) {
      if (!uuids.contains(logEntry.getDocUUID())) {
        uuids.add(logEntry.getDocUUID());
        ldocs.add(
            new ModifiedDocumentDescriptor(
                logEntry.getEventDate(), logEntry.getDocType(), logEntry.getDocUUID()));
      }
    }

    ModifiedDocumentDescriptor[] docs = new ModifiedDocumentDescriptor[ldocs.size()];
    ldocs.toArray(docs);

    return docs;
  }