コード例 #1
0
ファイル: WSAuditBean.java プロジェクト: mindis/nuxeo
  @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;
  }