| 1 | |
package org.jtheque.films.services.impl.utils.web.analyzers; |
| 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.log.ILoggingManager; |
| 21 | |
import org.jtheque.films.persistence.od.able.Film; |
| 22 | |
import org.jtheque.utils.io.FileException; |
| 23 | |
import org.jtheque.utils.io.FileUtils; |
| 24 | |
|
| 25 | |
import java.io.File; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
final class AnalyzerUtils { |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
private AnalyzerUtils() { |
| 37 | 0 | super(); |
| 38 | 0 | } |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
public static void downloadMiniature(Film film, String path) { |
| 47 | 0 | File folder = new File(Managers.getCore().getFolders().getApplicationFolder().getAbsolutePath() + |
| 48 | |
"/miniatures"); |
| 49 | |
|
| 50 | 0 | boolean ok = true; |
| 51 | |
|
| 52 | 0 | if (!folder.exists()) { |
| 53 | 0 | ok = folder.mkdirs(); |
| 54 | |
} |
| 55 | |
|
| 56 | 0 | if (ok) { |
| 57 | 0 | String destinationPath = org.jtheque.films.utils.FileUtils.prepareFilePath( |
| 58 | |
Managers.getCore().getFolders().getApplicationFolder().getAbsolutePath() + |
| 59 | |
"/miniatures/" + film.getTitle() + ".jpg"); |
| 60 | |
|
| 61 | |
try { |
| 62 | 0 | FileUtils.downloadFile(path, destinationPath); |
| 63 | 0 | } catch (FileException e) { |
| 64 | 0 | Managers.getManager(ILoggingManager.class).getLogger(AnalyzerUtils.class).error(e); |
| 65 | 0 | } |
| 66 | |
|
| 67 | 0 | film.setImage(destinationPath); |
| 68 | |
} |
| 69 | 0 | } |
| 70 | |
} |