final void compress ( final File backupFile , final AppenderRollingProperties properties ) { if ( this . isCompressed ( backupFile ) ) { LogLog . debug ( "Backup log file " + backupFile . getName ( ) + " is already compressed" ) ; return ; // try not to do unnecessary work } final long lastModified = backupFile . lastModified ( ) ; if ( 0L == lastModified ) { LogLog . debug ( "Backup log file " + backupFile . getName ( ) + " may have been scavenged" ) ; return ; // backup file may have been scavenged } final File deflatedFile = this . createDeflatedFile ( backupFile ) ; if ( deflatedFile == null ) { LogLog . debug ( "Backup log file " + backupFile . getName ( ) + " may have been scavenged" ) ; return ; // an error occurred creating the file } if ( this . compress ( backupFile , deflatedFile , properties ) ) { deflatedFile . setLastModified ( lastModified ) ; FileHelper . getInstance ( ) . deleteExisting ( backupFile ) ; LogLog . debug ( "Compressed backup log file to " + deflatedFile . getName ( ) ) ; } else { FileHelper . getInstance ( ) . deleteExisting ( deflatedFile ) ; // clean up LogLog . debug ( "Unable to compress backup log file " + backupFile . getName ( ) ) ; } }
Template method responsible for file compression checks file creation and delegation to specific strategy implementations .