Пример #1
0
  void successfulBoot() throws ConfigurationPersistenceException {
    synchronized (this) {
      if (doneBootup.get()) {
        return;
      }

      final File copySource;
      if (persistOriginal) {
        copySource = mainFile;
      } else {
        copySource = new File(mainFile.getParentFile(), mainFile.getName() + ".boot");
        FilePersistenceUtils.deleteFile(copySource);
      }

      try {
        if (!bootFile.equals(copySource)) {
          FilePersistenceUtils.copyFile(bootFile, copySource);
        }

        createHistoryDirectory();

        final File historyBase = new File(historyRoot, mainFile.getName());
        lastFile = addSuffixToFile(historyBase, LAST);
        final File boot = addSuffixToFile(historyBase, BOOT);
        final File initial = addSuffixToFile(historyBase, INITIAL);

        if (!initial.exists()) {
          FilePersistenceUtils.copyFile(copySource, initial);
        }

        FilePersistenceUtils.copyFile(copySource, lastFile);
        FilePersistenceUtils.copyFile(copySource, boot);
      } catch (IOException e) {
        throw MESSAGES.failedToCreateConfigurationBackup(e, bootFile);
      } finally {
        if (!persistOriginal) {
          // Delete the temporary file
          try {
            FilePersistenceUtils.deleteFile(copySource);
          } catch (Exception ignore) {
          }
        }
      }
      doneBootup.set(true);
    }
  }
Пример #2
0
 String snapshot() throws ConfigurationPersistenceException {
   String name = getTimeStamp(new Date()) + mainFileName;
   File snapshot = new File(snapshotsDirectory, name);
   try {
     FilePersistenceUtils.copyFile(mainFile, snapshot);
   } catch (IOException e) {
     throw MESSAGES.failedToTakeSnapshot(e, mainFile, snapshot);
   }
   return snapshot.toString();
 }
Пример #3
0
 void fileWritten() throws ConfigurationPersistenceException {
   if (!doneBootup.get() || !persistOriginal) {
     return;
   }
   try {
     FilePersistenceUtils.copyFile(mainFile, lastFile);
   } catch (IOException e) {
     throw MESSAGES.failedToBackup(e, mainFile);
   }
 }