[jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/search/lucene s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Fri Mar 18 18:56:49 MST 2005
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene
In directory www.crosswire.org:/tmp/cvs-serv10359/java/jsword/org/crosswire/jsword/book/search/lucene
Modified Files:
LuceneIndexManager.java
Log Message:
Made Book the primary interface to a module and put BookMetaData within it. All of BookMetaData is accessible through the Book interface.
Index: LuceneIndexManager.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/LuceneIndexManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** LuceneIndexManager.java 8 Mar 2005 12:27:25 -0000 1.7
--- LuceneIndexManager.java 19 Mar 2005 01:56:47 -0000 1.8
***************
*** 7,10 ****
--- 7,11 ----
import java.util.Map;
+ import org.crosswire.common.util.FileUtil;
import org.crosswire.common.util.IOUtil;
import org.crosswire.common.util.Logger;
***************
*** 52,56 ****
try
{
! URL storage = getStorageArea(book.getBookMetaData());
URL longer = NetUtil.lengthenURL(storage, DIR_SEGMENTS);
return NetUtil.isFile(longer);
--- 53,57 ----
try
{
! URL storage = getStorageArea(book);
URL longer = NetUtil.lengthenURL(storage, DIR_SEGMENTS);
return NetUtil.isFile(longer);
***************
*** 73,77 ****
if (reply == null)
{
! URL storage = getStorageArea(book.getBookMetaData());
reply = new LuceneIndex(book, storage);
INDEXES.put(book, reply);
--- 74,78 ----
if (reply == null)
{
! URL storage = getStorageArea(book);
reply = new LuceneIndex(book, storage);
INDEXES.put(book, reply);
***************
*** 101,105 ****
try
{
! storage = getStorageArea(book.getBookMetaData());
Index index = new LuceneIndex(book, storage, true);
// We were successful if the directory exists.
--- 102,106 ----
try
{
! storage = getStorageArea(book);
Index index = new LuceneIndex(book, storage, true);
// We were successful if the directory exists.
***************
*** 126,134 ****
* @see org.crosswire.jsword.book.search.IndexManager#installDownloadedIndex(org.crosswire.jsword.book.Book, java.net.URL)
*/
! public void installDownloadedIndex(BookMetaData bmd, URL tempDest) throws BookException
{
try
{
! URL storage = getStorageArea(bmd);
File zip = NetUtil.getAsFile(tempDest);
IOUtil.unpackZip(zip, NetUtil.getAsFile(storage));
--- 127,135 ----
* @see org.crosswire.jsword.book.search.IndexManager#installDownloadedIndex(org.crosswire.jsword.book.Book, java.net.URL)
*/
! public void installDownloadedIndex(Book book, URL tempDest) throws BookException
{
try
{
! URL storage = getStorageArea(book);
File zip = NetUtil.getAsFile(tempDest);
IOUtil.unpackZip(zip, NetUtil.getAsFile(storage));
***************
*** 145,153 ****
public void deleteIndex(Book book) throws BookException
{
try
{
// TODO(joe): This needs some checks that it isn't being used
! URL storage = getStorageArea(book.getBookMetaData());
! NetUtil.delete(storage);
}
catch (IOException ex)
--- 146,163 ----
public void deleteIndex(Book book) throws BookException
{
+ // Lucene can build in the directory that currently exists,
+ // overwriting what is there. So we rename the directory,
+ // mark the operation as success and then try to delete the
+ // directory.
+ File tempPath = null;
try
{
// TODO(joe): This needs some checks that it isn't being used
! File storage = NetUtil.getAsFile(getStorageArea(book));
! String finalCanonicalPath = storage.getCanonicalPath();
! tempPath = new File(finalCanonicalPath + '.' + IndexStatus.CREATING.toString());
! FileUtil.delete(tempPath);
! storage.renameTo(tempPath);
! book.getBookMetaData().setIndexStatus(IndexStatus.UNDONE);
}
catch (IOException ex)
***************
*** 155,168 ****
throw new BookException(Msg.DELETE_FAILED, ex);
}
}
/**
* Determine where an index should be stored
! * @param bmd The book to be indexed
* @return A URL to store stuff in
* @throws IOException If there is a problem in finding where to store stuff
*/
! protected URL getStorageArea(BookMetaData bmd) throws IOException
{
String driverName = bmd.getDriverName();
String bookName = bmd.getInitials();
--- 165,181 ----
throw new BookException(Msg.DELETE_FAILED, ex);
}
+
+ FileUtil.delete(tempPath);
}
/**
* Determine where an index should be stored
! * @param book The book to be indexed
* @return A URL to store stuff in
* @throws IOException If there is a problem in finding where to store stuff
*/
! protected URL getStorageArea(Book book) throws IOException
{
+ BookMetaData bmd = book.getBookMetaData();
String driverName = bmd.getDriverName();
String bookName = bmd.getInitials();
More information about the jsword-svn
mailing list