コード例 #1
0
 private synchronized void addFailedRecord(
     PollTableEntry pollTableEntry, FileObject failedObject, String timeString) {
   try {
     String record =
         failedObject.getName().getBaseName() + VFSConstants.FAILED_RECORD_DELIMITER + timeString;
     String recordFile =
         pollTableEntry.getFailedRecordFileDestination()
             + pollTableEntry.getFailedRecordFileName();
     File failedRecordFile = new File(recordFile);
     if (!failedRecordFile.exists()) {
       FileUtils.writeStringToFile(failedRecordFile, record);
       if (log.isDebugEnabled()) {
         log.debug("Added fail record '" + record + "' into the record file '" + recordFile + "'");
       }
     } else {
       List<String> content = FileUtils.readLines(failedRecordFile);
       if (!content.contains(record)) {
         content.add(record);
       }
       FileUtils.writeLines(failedRecordFile, content);
     }
   } catch (IOException e) {
     log.fatal("Failure while writing the failed records!", e);
   }
 }
コード例 #2
0
 private boolean isFailedRecord(FileObject fileObject, PollTableEntry entry) {
   String failedFile = entry.getFailedRecordFileDestination() + entry.getFailedRecordFileName();
   File file = new File(failedFile);
   if (file.exists()) {
     try {
       List list = FileUtils.readLines(file);
       for (Object aList : list) {
         String str = (String) aList;
         StringTokenizer st = new StringTokenizer(str, VFSConstants.FAILED_RECORD_DELIMITER);
         String fileName = st.nextToken();
         if (fileName != null && fileName.equals(fileObject.getName().getBaseName())) {
           return true;
         }
       }
     } catch (IOException e) {
       log.fatal("Error while reading the file '" + failedFile + "'", e);
     }
   }
   return false;
 }