private DocumentSet configureAndStore(String configuration, String directory) {
DBBroker broker = null;
TransactionManager transact = null;
Txn transaction = null;
MutableDocumentSet docs = new DefaultDocumentSet();
try {
broker = pool.get(pool.getSecurityManager().getSystemSubject());
assertNotNull(broker);
transact = pool.getTransactionManager();
assertNotNull(transact);
transaction = transact.beginTransaction();
assertNotNull(transaction);
if (configuration != null) {
CollectionConfigurationManager mgr = pool.getConfigurationManager();
mgr.addConfiguration(transaction, broker, root, configuration);
}
File file = new File(directory);
File[] files = file.listFiles();
MimeTable mimeTab = MimeTable.getInstance();
for (int j = 0; j < files.length; j++) {
MimeType mime = mimeTab.getContentTypeFor(files[j].getName());
if(mime != null && mime.isXMLType()) {
System.out.println("Storing document " + files[j].getName());
InputSource is = new InputSource(files[j].getAbsolutePath());
IndexInfo info =
root.validateXMLResource(transaction, broker, XmldbURI.create(files[j].getName()), is);
assertNotNull(info);
is = new InputSource(files[j].getAbsolutePath());
root.store(transaction, broker, info, is, false);
docs.add(info.getDocument());
}
}
transact.commit(transaction);
} catch (Exception e) {
if (transact != null)