use of org.exist.collections.CollectionConfigurationManager in project exist by eXist-db.
the class LuceneIndexTest method configureAndStore.
private DocumentSet configureAndStore(String configuration, final String[] sampleNames) throws EXistException, CollectionConfigurationException, PermissionDeniedException, SAXException, TriggerException, LockException, IOException {
final MutableDocumentSet docs = new DefaultDocumentSet();
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final TransactionManager transact = pool.getTransactionManager();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
final Txn transaction = transact.beginTransaction()) {
if (configuration != null) {
final CollectionConfigurationManager mgr = pool.getConfigurationManager();
mgr.addConfiguration(transaction, broker, root, configuration);
}
for (final String sampleName : sampleNames) {
broker.storeDocument(transaction, XmldbURI.create(sampleName), new InputStreamSupplierInputSource(() -> SAMPLES.getShakespeareSample(sampleName)), MimeType.XML_TYPE, root);
docs.add(root.getDocument(broker, XmldbURI.create(sampleName)));
}
transact.commit(transaction);
}
return docs;
}
use of org.exist.collections.CollectionConfigurationManager in project exist by eXist-db.
the class GMLIndexTest method setup.
@BeforeClass
public static void setup() throws EXistException, PermissionDeniedException, IOException, SAXException, CollectionConfigurationException, URISyntaxException, LockException {
final BrokerPool pool = server.getBrokerPool();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
final Txn transaction = pool.getTransactionManager().beginTransaction();
final Collection testCollection = broker.getOrCreateCollection(transaction, TEST_COLLECTION_URI)) {
final CollectionConfigurationManager mgr = pool.getConfigurationManager();
mgr.addConfiguration(transaction, broker, testCollection, COLLECTION_CONFIG);
for (int i = 0; i < FILES.length; i++) {
final URL url = GMLIndexTest.class.getResource("/" + FILES[i]);
broker.storeDocument(transaction, XmldbURI.create(FILES[i]), new FileInputSource(Paths.get(url.toURI())), MimeType.XML_TYPE, testCollection);
}
transaction.commit();
}
}
use of org.exist.collections.CollectionConfigurationManager in project exist by eXist-db.
the class MatchListenerTest method configureAndStore.
private void configureAndStore(String config, String xml) throws PermissionDeniedException, IOException, SAXException, EXistException, LockException, CollectionConfigurationException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final TransactionManager transact = pool.getTransactionManager();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
final Txn transaction = transact.beginTransaction()) {
final Collection root = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
assertNotNull(root);
final CollectionConfigurationManager mgr = pool.getConfigurationManager();
mgr.addConfiguration(transaction, broker, root, config);
broker.storeDocument(transaction, XmldbURI.create("test_matches.xml"), new StringInputSource(xml), MimeType.XML_TYPE, root);
transact.commit(transaction);
}
}
use of org.exist.collections.CollectionConfigurationManager in project exist by eXist-db.
the class CustomIndexTest method setUp.
@Before
public void setUp() throws DatabaseConfigurationException, EXistException, PermissionDeniedException, IOException, SAXException, CollectionConfigurationException, LockException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final TransactionManager transact = pool.getTransactionManager();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
final Txn transaction = transact.beginTransaction()) {
Collection root = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
assertNotNull(root);
broker.saveCollection(transaction, root);
CollectionConfigurationManager mgr = pool.getConfigurationManager();
mgr.addConfiguration(transaction, broker, root, COLLECTION_CONFIG);
docs = new DefaultDocumentSet();
broker.storeDocument(transaction, XmldbURI.create("test_string.xml"), new StringInputSource(XML), MimeType.XML_TYPE, root);
docs.add(root.getDocument(broker, XmldbURI.create("test_string.xml")));
broker.storeDocument(transaction, XmldbURI.create("test_string2.xml"), new StringInputSource(XML2), MimeType.XML_TYPE, root);
docs.add(root.getDocument(broker, XmldbURI.create("test_string2.xml")));
transact.commit(transaction);
}
}
use of org.exist.collections.CollectionConfigurationManager in project exist by eXist-db.
the class RpcConnection method configureCollection.
private boolean configureCollection(final XmldbURI collUri, final String configuration) throws EXistException, PermissionDeniedException {
withDb((broker, transaction) -> {
final Collection colRef = this.<Collection>readCollection(broker, transaction, collUri).apply((collection, broker1, transaction1) -> collection);
final CollectionConfigurationManager mgr = factory.getBrokerPool().getConfigurationManager();
try {
mgr.addConfiguration(transaction, broker, colRef, configuration);
} catch (final CollectionConfigurationException e) {
throw new EXistException(e.getMessage());
}
return null;
});
LOG.info("Configured '{}'", collUri);
return true;
}
Aggregations