public void installDownloadedIndex(Book book, URI tempDest) throws BookException { try { URI storage = getStorageArea(book); File zip = NetUtil.getAsFile(tempDest); IOUtil.unpackZip(zip, NetUtil.getAsFile(storage)); //todo Index.Version management?? } catch (IOException ex) { // TRANSLATOR: The search index could not be moved to it's final location. throw new BookException(JSMsg.gettext("Installation failed."), ex); } }
/** * Read an existing index and use it. * * @param book the book * @param storage * @throws BookException * If we fail to read the index files */ public LuceneIndex(Book book, URI storage) throws BookException { this.book = book; try { this.path = NetUtil.getAsFile(storage).getCanonicalPath(); } catch (IOException ex) { // TRANSLATOR: Error condition: Could not initialize a search index. throw new BookException(JSMsg.gettext("Failed to initialize Lucene search engine."), ex); } initDirectoryAndSearcher(); }
public void scheduleIndexCreation(final Book book) { book.setIndexStatus(IndexStatus.SCHEDULED); IndexStatus finalStatus = IndexStatus.UNDONE; try { URI storage = getStorageArea(book); Index index = new LuceneIndex(book, storage, this.policy); //todo update Installed IndexVersion for newly created index // todo implement: Installed.Index.Version.Book.XXX value add/update in metadata file after creation, use value getLatestIndexVersion(book) // We were successful if the directory exists. if (NetUtil.getAsFile(storage).exists()) { finalStatus = IndexStatus.DONE; INDEXES.put(book, index); //update IndexVersion InstalledIndex.instance().storeLatestVersionAsInstalledIndexMetadata(book); } } catch (IOException e) { Reporter.informUser(LuceneIndexManager.this, e); } catch (BookException e) { Reporter.informUser(LuceneIndexManager.this, e); } finally { book.setIndexStatus(finalStatus); } }
File storage = NetUtil.getAsFile(getStorageArea(book)); String finalCanonicalPath = storage.getCanonicalPath(); tempPath = new File(finalCanonicalPath + '.' + IndexStatus.CREATING.toString());
File finalPath = null; try { finalPath = NetUtil.getAsFile(storage); this.path = finalPath.getCanonicalPath(); } catch (IOException ex) {
File tempFile = NetUtil.getAsFile(temp); if (!FileManager.copyFile(tempFile, target)) { Log.e(TAG, "Download Error renaming temp file "+tempFile+" to:"+target);
IOUtil.unpackZip(NetUtil.getAsFile(temp), dldir, true, SwordConstants.DIR_CONF, SwordConstants.DIR_DATA); File jswordHome = NetUtil.getAsFile(CWProject.instance().getWritableProjectDir()); IOUtil.unpackZip(NetUtil.getAsFile(temp), jswordHome, false, SwordConstants.DIR_CONF, SwordConstants.DIR_DATA);