}
try {
// In case home has been specified as relative path convert it to absolute path
dbrootDir = new File(home, dbroot).getCanonicalFile();
} catch (IOException e) {
throw new XindiceException("Can't get canonical path", e);
}
}
setCollectionRoot(dbrootDir);
if (log.isInfoEnabled()) {
log.info("Database points to " + dbrootDir.getAbsolutePath());
}
// Put a lock (at least attempt to) on the database
// FIXME: Use JDK1.4 FileLock
File lock = new File(getCollectionRoot(), "db.lock");
try {
if (lock.exists() && !lock.delete()) {
throw new IOException("Could not delete lock file.");
}
this.lock = new FileOutputStream(lock);
this.lock.write(new Date().toString().getBytes());
} catch (IOException e) {
throw new XindiceException("Unable to open lock file " + lock + ". " +
"Make sure database is not open by another process. " +
"Exception: " + e);
}
// Now we are ready to open it up