* @param target
*/
private void scanDirectory(File directory, XmldbURI target, boolean inRootDir) {
final TransactionManager mgr = broker.getBrokerPool().getTransactionManager();
final Txn txn = mgr.beginTransaction();
Collection collection = null;
try {
collection = broker.getOrCreateCollection(txn, target);
setPermissions(true, null, collection.getPermissionsNoLock());
broker.saveCollection(txn, collection);
mgr.commit(txn);
} catch (final Exception e) {
mgr.abort(txn);
} finally {
mgr.close(txn);
}
try {
// lock the collection while we store the files
// TODO: could be released after each operation
collection.getLock().acquire(Lock.WRITE_LOCK);
storeFiles(directory, collection, inRootDir);
} catch (final LockException e) {
e.printStackTrace();
} finally {
collection.getLock().release(Lock.WRITE_LOCK);
}
// scan sub directories
final File[] files = directory.listFiles();
for (final File file : files) {