protected boolean validateFiles ( final ContentSpec contentSpec ) { final FileList fileList = contentSpec . getFileList ( ) ; boolean valid = true ; if ( fileList != null && ! fileList . getValue ( ) . isEmpty ( ) ) { for ( final File file : fileList . getValue ( ) ) { FileWrapper fileWrapper = null ; try { fileWrapper = fileProvider . getFile ( file . getId ( ) , file . getRevision ( ) ) ; } catch ( NotFoundException e ) { log . debug ( "Could not find file for id " + file . getId ( ) ) ; } if ( fileWrapper == null ) { log . error ( String . format ( ProcessorConstants . ERROR_FILE_ID_NONEXIST_MSG , fileList . getLineNumber ( ) , file . getText ( ) ) ) ; valid = false ; } else if ( file . getTitle ( ) != null ) { // Make sure the titles sync up, as a title was specified. if ( ! fileWrapper . getFilename ( ) . equals ( file . getTitle ( ) ) ) { final String errorMsg = String . format ( ProcessorConstants . ERROR_FILE_TITLE_NO_MATCH_MSG , fileList . getLineNumber ( ) , file . getTitle ( ) , fileWrapper . getFilename ( ) ) ; if ( processingOptions . isStrictTitles ( ) ) { log . error ( errorMsg ) ; valid = false ; } else { log . warn ( errorMsg ) ; file . setTitle ( fileWrapper . getFilename ( ) ) ; } } } else { // The short format was used if the title is null, so add it file . setTitle ( fileWrapper . getFilename ( ) ) ; } } } return valid ; }
Checks to make sure that the files specified in a content spec are valid and exist .