public abstract class AbstractSwordInstaller extends AbstractBookList implements Installer, Comparable<AbstractSwordInstaller>
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
protected String |
catalogDirectory
The directory containing the catalog of all books on the
host . |
protected static String |
CONF_DIR
The sword conf directory
|
protected static String |
DOWNLOAD_PREFIX
When we cache a download index
|
protected Map<String,Book> |
entries
A map of the books in this download area
|
protected static String |
FILE_LIST_GZ
The sword index file
|
protected String |
host
The remote hostname.
|
protected String |
indexDirectory
The directory containing the catalog of all books on the
host . |
protected boolean |
loaded
Do we need to reload the index file
|
protected static org.slf4j.Logger |
log
The log stream
|
protected String |
packageDirectory
The directory containing zipped books on the
host . |
protected String |
proxyHost
The remote proxy hostname.
|
protected Integer |
proxyPort
The remote proxy port.
|
protected static String |
SEARCH_DIR
The relative path of the dir holding the search index files
|
protected static String |
ZIP_SUFFIX
The suffix of zip books on this server
|
Constructor and Description |
---|
AbstractSwordInstaller()
Build a default AbstractSwordInstaller
|
Modifier and Type | Method and Description |
---|---|
void |
close()
remove the cached book list to clear memory
|
int |
compareTo(AbstractSwordInstaller myClass) |
protected abstract void |
download(Progress job,
String dir,
String file,
URI dest)
Utility to download a file from a remote site
|
void |
downloadSearchIndex(Book book,
URI localDest)
Download a search index for the given Book.
|
boolean |
equals(Object object) |
Book |
getBook(String name)
Get a Book matching the name from the local cache.
|
List<Book> |
getBooks()
Get a list of BookMetaData objects that represent downloadable books.
|
List<Book> |
getBooks(BookFilter filter)
Get a filtered list of all the Books.
|
protected URI |
getCachedIndexDir()
The URL for the cached index file for this installer
|
protected URI |
getCachedIndexFile()
The URL for the cached index file for this installer
|
String |
getCatalogDirectory() |
String |
getHost() |
String |
getIndexDirectory() |
String |
getInstallerDefinition()
Accessor for the URI
|
String |
getPackageDirectory() |
String |
getProxyHost() |
Integer |
getProxyPort() |
private static String |
getTempFileExtension(String host,
String catalogDir)
What are we using as a temp filename?
|
int |
hashCode() |
void |
install(Book book)
Download and install a book locally.
|
boolean |
isNewer(Book book)
Return true if the book is not installed or there is a newer version to
install.
|
protected void |
loadCachedIndex()
Load the cached index file into memory
|
void |
reloadBookList()
Re-fetch a list of names from the remote source.
|
void |
setCatalogDirectory(String catologDirectory) |
void |
setHost(String newHost) |
void |
setIndexDirectory(String indexDirectory) |
void |
setPackageDirectory(String newDirectory) |
void |
setProxyHost(String newProxyHost) |
void |
setProxyPort(Integer newProxyPort) |
protected void |
unpack(URI cacheDir,
URI cache)
Unpack the cached index file to disk
|
addBooksListener, fireBooksChanged, removeBooksListener
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getSize, getType, toRemoteURI
addBooksListener, removeBooksListener
protected String host
protected String proxyHost
protected Integer proxyPort
protected String packageDirectory
host
.protected String catalogDirectory
host
.protected String indexDirectory
host
.protected boolean loaded
protected static final String FILE_LIST_GZ
protected static final String CONF_DIR
protected static final String ZIP_SUFFIX
protected static final String SEARCH_DIR
protected static final String DOWNLOAD_PREFIX
protected static final org.slf4j.Logger log
public AbstractSwordInstaller()
protected abstract void download(Progress job, String dir, String file, URI dest) throws InstallException
job
- The way of noting progressdir
- The directory from which to download the filefile
- The file to downloadInstallException
public String getInstallerDefinition()
Installer
getInstallerDefinition
in interface Installer
public boolean isNewer(Book book)
Installer
public List<Book> getBooks()
Installer
getBooks
in interface BookList
getBooks
in interface Installer
Installer.reloadBookList()
public List<Book> getBooks(BookFilter filter)
BookList
getBooks
in interface BookList
getBooks
in class AbstractBookList
filter
- the filter to apply to the list of booksBookFilters
public Book getBook(String name)
Installer
public void install(Book book)
Installer
public void reloadBookList() throws InstallException
Installer
reloadBookList
in interface Installer
InstallException
public void downloadSearchIndex(Book book, URI localDest) throws InstallException
Installer
downloadSearchIndex
in interface Installer
book
- The book to download a search index for.localDest
- A temporary URI for downloading to. Passed to the BookIndexer
for installation.InstallException
protected void unpack(URI cacheDir, URI cache) throws IOException
IOException
protected void loadCachedIndex() throws IOException, InstallException, BookException
IOException
InstallException
BookException
public void close()
public String getCatalogDirectory()
public void setCatalogDirectory(String catologDirectory)
catologDirectory
- the catologDirectory to setpublic String getPackageDirectory()
public void setPackageDirectory(String newDirectory)
newDirectory
- The directory to set.public String getIndexDirectory()
public void setIndexDirectory(String indexDirectory)
indexDirectory
- the indexDirectory to setpublic String getHost()
public void setHost(String newHost)
newHost
- The host to set.public String getProxyHost()
public void setProxyHost(String newProxyHost)
newProxyHost
- The proxyHost to set.public Integer getProxyPort()
public void setProxyPort(Integer newProxyPort)
newProxyPort
- The proxyPort to set.protected URI getCachedIndexDir() throws InstallException
InstallException
protected URI getCachedIndexFile() throws InstallException
InstallException
private static String getTempFileExtension(String host, String catalogDir)
public int compareTo(AbstractSwordInstaller myClass)
compareTo
in interface Comparable<AbstractSwordInstaller>