Coverage Report - org.jtheque.films.services.impl.utils.file.jt.reader.JTFEFileReader
 
Classes in this File Line Coverage Branch Coverage Complexity
JTFEFileReader
0 %
0/13
0 %
0/4
3
 
 1  
 package org.jtheque.films.services.impl.utils.file.jt.reader;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jtheque.core.managers.Managers;
 20  
 import org.jtheque.core.managers.error.IErrorManager;
 21  
 import org.jtheque.core.utils.file.jt.JTFileReader;
 22  
 import org.jtheque.core.utils.file.jt.able.JTFile;
 23  
 import org.jtheque.films.services.impl.utils.file.jt.JTFEFile;
 24  
 import org.jtheque.films.services.impl.utils.file.jt.JTFFile;
 25  
 import org.jtheque.utils.io.FileException;
 26  
 import org.jtheque.utils.io.FileUtils;
 27  
 
 28  
 import java.io.BufferedInputStream;
 29  
 import java.io.File;
 30  
 import java.util.ArrayList;
 31  
 import java.util.Collection;
 32  
 
 33  
 /**
 34  
  * A reader for JTFE file.
 35  
  *
 36  
  * @author Baptiste Wicht
 37  
  */
 38  0
 public final class JTFEFileReader extends JTZippedFileReader {
 39  
     @Override
 40  
     public JTFile readFile(BufferedInputStream stream) throws FileException {
 41  0
         JTFEFile file = new JTFEFile();
 42  
 
 43  0
         Collection<File> files = FileUtils.unzip(stream, Managers.getCore().getFolders().getTempFolderPath());
 44  0
         Collection<JTFFile> jFiles = new ArrayList<JTFFile>(10);
 45  
 
 46  0
         JTFileReader reader = new JTFFileReader();
 47  
 
 48  0
         for (File f : files) {
 49  0
             JTFFile jtFile = (JTFFile) reader.readFile(f);
 50  
 
 51  0
             jFiles.add(jtFile);
 52  
 
 53  0
             if (!f.delete()) {
 54  0
                 Managers.getManager(IErrorManager.class).addInternationalizedError("errors.jtfe.delete", f.getAbsolutePath());
 55  
             }
 56  0
         }
 57  
 
 58  0
         file.setFiles(jFiles);
 59  
 
 60  0
         return file;
 61  
     }
 62  
 }