protected void addAdditionalFilesToBook ( final BuildData buildData ) throws BuildProcessingException { final FileProvider fileProvider = providerFactory . getProvider ( FileProvider . class ) ; final ContentSpec contentSpec = buildData . getContentSpec ( ) ; if ( contentSpec . getFiles ( ) != null ) { log . info ( "\tDownloading Additional Files" ) ; for ( final org . jboss . pressgang . ccms . contentspec . File file : contentSpec . getFiles ( ) ) { try { final FileWrapper fileEntity = fileProvider . getFile ( file . getId ( ) , file . getRevision ( ) ) ; // Find the file that matches this locale. If the locale isn't found then use the default locale LanguageFileWrapper languageFileFile = null ; if ( fileEntity . getLanguageFiles ( ) != null && fileEntity . getLanguageFiles ( ) . getItems ( ) != null ) { final List < LanguageFileWrapper > languageFiles = fileEntity . getLanguageFiles ( ) . getItems ( ) ; for ( final LanguageFileWrapper languageFile : languageFiles ) { if ( languageFile . getLocale ( ) . getValue ( ) . equals ( buildData . getBuildLocale ( ) ) ) { languageFileFile = languageFile ; } else if ( languageFile . getLocale ( ) . getValue ( ) . equals ( buildData . getDefaultLocale ( ) ) && languageFileFile == null ) { languageFileFile = languageFile ; } } } if ( languageFileFile != null && languageFileFile . getFileData ( ) != null ) { // Determine the file path final String filePath ; if ( ! isNullOrEmpty ( fileEntity . getFilePath ( ) ) ) { if ( fileEntity . getFilePath ( ) . endsWith ( "/" ) || fileEntity . getFilePath ( ) . endsWith ( "\\" ) ) { filePath = fileEntity . getFilePath ( ) ; } else { filePath = fileEntity . getFilePath ( ) + "/" ; } } else { filePath = "" ; } // Explode the ZIP archive if requested if ( fileEntity . isExplodeArchive ( ) ) { try { final Map < String , byte [ ] > files = ZipUtilities . unzipFile ( languageFileFile . getFileData ( ) , false ) ; for ( final Entry < String , byte [ ] > entry : files . entrySet ( ) ) { addToZip ( buildData . getBookFilesFolder ( ) + filePath + entry . getKey ( ) , entry . getValue ( ) , buildData ) ; } } catch ( IOException e ) { throw new BuildProcessingException ( e ) ; } } else { addToZip ( buildData . getBookFilesFolder ( ) + filePath + fileEntity . getFilename ( ) , languageFileFile . getFileData ( ) , buildData ) ; } } else { throw new BuildProcessingException ( "File ID " + fileEntity . getId ( ) + " has no language files!" ) ; } } catch ( NotFoundException e ) { throw new BuildProcessingException ( "File ID " + file . getId ( ) + " could not be found!" ) ; } } } }
Adds the additional files defined in a content spec to the book .