| 1 | |
package org.jtheque.films.services.impl.utils.file.imports; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 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 | |
|
| 30 | |
|
| 31 | |
|
| 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 | |
} |