Revision: 13709
http://gate.svn.sourceforge.net/gate/?rev=13709&view=rev
Author: ian_roberts
Date: 2011-04-20 12:08:59 +0000 (Wed, 20 Apr 2011)
Log Message:
-----------
Fix for relative path handling. Previously we were computing the relative path
to save in the marker file as a relative URI (forward slashes, spaces escaped
as %20, etc) but treating it as a native file path when reconstructing the
index location at open() time. This works on Unix-like platforms where there
are no spaces or other special characters in the directory paths but can fail
in other cases. Now open() reconstructs the absolute *URI* from the relative
one and then turns the result back into a File.
Modified Paths:
--------------
gate/trunk/src/gate/persist/LuceneDataStoreImpl.java
Modified: gate/trunk/src/gate/persist/LuceneDataStoreImpl.java
===================================================================
--- gate/trunk/src/gate/persist/LuceneDataStoreImpl.java 2011-04-20
01:25:04 UTC (rev 13708)
+++ gate/trunk/src/gate/persist/LuceneDataStoreImpl.java 2011-04-20
12:08:59 UTC (rev 13709)
@@ -24,6 +24,7 @@
import gate.event.CreoleEvent;
import gate.event.CreoleListener;
import gate.security.SecurityException;
+import gate.util.Files;
import gate.util.GateRuntimeException;
import gate.util.Strings;
import gate.util.persistence.PersistenceManager;
@@ -174,27 +175,21 @@
BufferedReader isr = new BufferedReader(fis);
currentProtocolVersion = isr.readLine();
String indexDirRelativePath = isr.readLine();
+
if(indexDirRelativePath != null
&& indexDirRelativePath.trim().length() > 1) {
-
- // compatibility check for old datastores
- if(indexDirRelativePath.startsWith("file:/")) {
- // old index
- indexURL = new URL(indexDirRelativePath);
+ URL storageDirURL = storageDir.toURI().toURL();
+ URL theIndexURL = new URL(storageDirURL, indexDirRelativePath);
+ // check if index directory exists
+ File indexDir = Files.fileFromURL(theIndexURL);
+ if(!indexDir.exists()) {
+ throw new PersistenceException("Index directory "
+ + indexDirRelativePath
+ + " could not be found for datastore at "
+ + storageDirURL);
}
- else {
- // index directory
- File indexDir = new File(storageDir, indexDirRelativePath);
- // check if index directory exists
- if(!indexDir.exists()) {
- throw new PersistenceException("Index directory "
- + indexDirRelativePath
- + " could not be found in the context of "
- + storageDir.getAbsolutePath());
- }
- indexURL = indexDir.toURI().toURL();
- }
+ indexURL = theIndexURL;
this.indexer = new LuceneIndexer(indexURL);
this.searcher = new LuceneSearcher();
((LuceneSearcher)this.searcher).setLuceneDatastore(this);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs