Coverage Report - org.jtheque.films.services.impl.utils.file.imports.JTFEImporter
 
Classes in this File Line Coverage Branch Coverage Complexity
JTFEImporter
0 %
0/11
0 %
0/6
2.5
 
 1  
 package org.jtheque.films.services.impl.utils.file.imports;
 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.language.ILanguageManager;
 21  
 import org.jtheque.films.services.impl.utils.file.jt.JTFEFile;
 22  
 import org.jtheque.films.services.impl.utils.file.jt.JTFFile;
 23  
 import org.jtheque.films.services.impl.utils.file.jt.reader.JTFEFileReader;
 24  
 import org.jtheque.films.services.impl.utils.file.jt.reader.JTZippedFileReader;
 25  
 import org.jtheque.films.utils.Constants.Files.FileType;
 26  
 import org.jtheque.utils.io.FileException;
 27  
 
 28  
 /**
 29  
  * An importer for JTFE file.
 30  
  *
 31  
  * @author Baptiste Wicht
 32  
  */
 33  0
 public final class JTFEImporter implements Importer {
 34  
     @Override
 35  
     public boolean canImportFrom(FileType fileType) {
 36  0
         return fileType == FileType.JTFE;
 37  
     }
 38  
 
 39  
     @Override
 40  
     public void importFrom(String filePath) throws FileException {
 41  0
         JTZippedFileReader reader = new JTFEFileReader();
 42  
 
 43  0
         JTFEFile file = (JTFEFile) reader.readFile(filePath);
 44  
 
 45  0
         if (file.isValid()) {
 46  0
             JTFImporter importer = (JTFImporter) ImporterFactory.getImporter(FileType.JTF);
 47  
 
 48  0
             for (JTFFile jtf : file.getFiles()) {
 49  0
                 importer.importFrom(jtf);
 50  
             }
 51  0
         } else {
 52  0
             throw new FileException(Managers.getManager(ILanguageManager.class).getMessage("errors.file.structureerror"));
 53  
         }
 54  0
     }
 55  
 }