1 package org.readium.r2_streamer.fetcher;
3 import org.readium.r2_streamer.model.container.Container;
4 import org.readium.r2_streamer.model.publication.EpubPublication;
6 import java.io.InputStream;
9 * Created by Shrikant Badwaik on 27-Jan-17.
12 public class EpubFetcher implements Fetcher {
13 private final String TAG = "EpubFetcher";
14 public Container container;
15 public EpubPublication publication;
16 private String rootFileDirectory;
18 public EpubFetcher(Container container, EpubPublication publication) throws EpubFetcherException {
19 this.container = container;
20 this.publication = publication;
22 String rootPath = publication.internalData.get("rootfile");
23 if (rootPath != null) {
24 this.rootFileDirectory = rootPath;
26 throw new EpubFetcherException("No rootFile in internalData, unable to get path to publication");
31 public String getData(String path) throws EpubFetcherException {
32 String data = container.rawData(path);
34 System.out.println(TAG + " file is missing " + path);
35 throw new EpubFetcherException(path + " file is missing");
41 public int getDataSize(String path) throws EpubFetcherException {
42 int dataSize = container.rawDataSize(path);
44 System.out.println(TAG + " file is missing " + path);
45 throw new EpubFetcherException(path + "file is missing");
51 public InputStream getDataInputStream(String path) throws EpubFetcherException {
52 InputStream dataInputStream = container.rawDataInputStream(path);
53 if (dataInputStream == null) {
54 System.out.println(TAG + " file is missing " + path);
55 throw new EpubFetcherException(path + "file is missing");
57 return dataInputStream;