When embedding a Xindice database within another application on a Windows
system, setting the dbroot to an absolute pathname like "C:\..." fails with
a BTreeFiler exception that the database isn't open.
The problem is in Database.setConfig, which checks if the dbroot is an
absolute path by looking to see if the string starts with "/", which is
great on Unix, not so great on Windoze.
The attached patch fixes the bug.
Thanks for providing Xindice.
--
Sean Kelly
Independent Consultant
http://kelly.homeunix.com/
Index: Database.java
===================================================================
RCS file:
/home/cvspublic/xml-xindice/java/src/org/apache/xindice/core/Database.java,v
retrieving revision 1.2
diff -u -r1.2 Database.java
--- Database.java 26 Feb 2002 07:10:09 -0000 1.2
+++ Database.java 4 May 2002 14:44:26 -0000
@@ -120,12 +120,11 @@
name = config.getAttribute(NAME);
setCanonicalName('/' + getName());
- String dbroot = config.getAttribute(DBROOT);
- if ( ! dbroot.startsWith("/") ) {
- dbroot = System.getProperty( PROP_XINDICE_HOME ) +
- "/" + dbroot;
- }
- setCollectionRoot(new File(dbroot));
+ File dbrootDir = new File(dbroot);
+ if (!dbrootDir.isAbsolute())
+ dbrootDir = new File(System.getProperty( PROP_XINDICE_HOME ),
+ dbroot);
+ setCollectionRoot(dbrootDir);
// Create the security manager so that it exists for loading the system
// collections.