protected void handleGenerateHash ( Option option ) { String hashFileLocation = option . getValue ( ) ; reportable . output ( "Generating checksum for file: " + hashFileLocation ) ; File hashFile = new File ( hashFileLocation ) ; if ( ! hashFile . exists ( ) || ! hashFile . canRead ( ) ) { reportable . error ( "File cannot be read" ) ; bail ( GENERAL_FAILURE ) ; } String hashContents = null ; try { hashContents = FileUtils . readFileToString ( hashFile ) ; } catch ( IOException e ) { reportable . error ( "Unable to read file" ) ; reportable . error ( "Reason: " + e . getMessage ( ) ) ; bail ( GENERAL_FAILURE ) ; } Hasher hasher = Hasher . INSTANCE ; try { String generatedhash = hasher . hashValue ( hashContents ) ; reportable . output ( "Checksum: " + generatedhash ) ; } catch ( Exception e ) { reportable . error ( "Unable to created checksum" ) ; reportable . error ( "Reason: " + e . getMessage ( ) ) ; bail ( GENERAL_FAILURE ) ; } }
Handle the generate hash option .