@Override public boolean isEntryValid(final File f, final boolean isLogging, final Logger logger) { final boolean result = ( ! isEntryMarkerFile(f)) && ( ! staleEntryNames.contains(archiveURI.relativize(f.toURI()).getPath())); if ( ! result && ! isEntryMarkerFile(f) && isLogging) { logger.log(Level.WARNING, "enterprise.deployment.filePredatesArchive", new Object[] {archiveURI.relativize(f.toURI()).toASCIIString(), archiveFile.getAbsolutePath()}); } return result; }
private StaleFileManagerImpl(final File archive) throws FileNotFoundException, IOException { archiveFile = archive; archiveURI = archive.toURI(); markerFile = StaleFileManager.Util.markerFile(archive); staleEntryNames = readStaleEntryNames(markerFile); }
/** * Factory method for a StaleFileManager. * <p> * Callers should invoke this method only after they have finished with * the FileArchive and have tried to delete it. If the directory * for the archive remains then it contains one or more stale files * that could not be deleted, and the factory method returns a * instance that tracks the stale files. If the directory no longer * exists then the delete succeeded, there are * @param archive the directory to contain the archive * @return StaleFileManager for the FileArchive to use */ public static StaleFileManager getInstance(final File archive) throws IOException { if (archive.exists()) { return new StaleFileManagerImpl(archive); } else { return new StaleFileManagerImplNoop(); } } }
/** * Records that the specified file is valid. * <p> * If the file had previously been marked as stale, it will no longer be * considered stale. * @param f the File which is now valid */ @Override public void recordValidEntry(File f) { if (updateStaleEntry(f, "FileArchive.StaleFileManager marking formerly stale entry {0} as active")) { /* * Process not only the file itself but the directories from the * file to the owning archive, since the directories are now * implicitly valid as well. */ do { f = f.getParentFile(); updateStaleEntry(f, "FileArchive.StaleFileManager marking formerly stale ancestor {0} as active"); } while ( ! f.equals(archiveFile)); flush(); } }
@Override public void recordDeletedEntry(File f) { if (updateStaleEntry(f, "FileArchive.StaleFileManager recording deletion of entry {0}")) { /* * If there are no other stale files in the same directory as * the file just deleted, then remove the directory from * the stale files collection and check its ancestors. */ do { if (isStaleEntryInDir(f.getParentFile())) { return; } updateStaleEntry(f, "FileArchive.StaleFileManager recording that formerly stale directory {0} is no longer stale"); f = f.getParentFile(); } while ( ! f.equals(archiveFile)); flush(); } }
@Override public boolean isEntryValid(final File f, final boolean isLogging) { return isEntryValid(f, isLogging, logger); }