| | |
| | | } |
| | | |
| | | // If a ".startok" file already exists, then move it to an ".old" file. |
| | | // renameFile() deletes an existing ".old" file and reports a failure to do so. |
| | | File oldFile = new File(oldFilePath); |
| | | try |
| | | { |
| | | if (oldFile.exists()) |
| | | { |
| | | oldFile.delete(); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | |
| | | File startOKFile = new File(startOKFilePath); |
| | | try |
| | | { |
| | | if (startOKFile.exists()) |
| | | { |
| | | startOKFile.renameTo(oldFile); |
| | | renameFile(startOKFile, oldFile); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | // Rename the temp file to the ".startok" file. |
| | | try |
| | | { |
| | | tempFile.renameTo(startOKFile); |
| | | renameFile(tempFile, startOKFile); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | // Move the current config file out of the way and replace it with the updated version. |
| | | File oldSource = new File(sourceFile.getAbsolutePath() + ".prechanges"); |
| | | if (oldSource.exists()) |
| | | { |
| | | oldSource.delete(); |
| | | } |
| | | sourceFile.renameTo(oldSource); |
| | | new File(tempFilePath).renameTo(sourceFile); |
| | | renameFile(sourceFile, oldSource); |
| | | renameFile(new File(tempFilePath), sourceFile); |
| | | |
| | | // Move the changes file out of the way so it doesn't get applied again. |
| | | File newChanges = new File(changesFile.getAbsolutePath() + ".applied"); |
| | | if (newChanges.exists()) |
| | | { |
| | | newChanges.delete(); |
| | | } |
| | | changesFile.renameTo(newChanges); |
| | | renameFile(changesFile, newChanges); |
| | | } |
| | | |
| | | private void applyConfigChangesIfNeeded(File configFileToUse) throws InitializationException |