}
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
File lock = new File(getCollectionRoot(), "db.lock");
try {
this.lock = new FileOutputStream(lock);
if (this.lock.getChannel().tryLock() != null) {
this.lock.write(new Date().toString().getBytes());
} else {
throw new IOException("Unable to acquire file lock.");
}
} catch (IOException e) {
throw new XindiceException("Unable to open lock file " + lock + ". " +
"Make sure database is not open by another process.",
e);
}
// Now we are ready to open it up