Search in sources :

Example 6 with CollectionConfigurationManager

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;
}
Also used : MutableDocumentSet(org.exist.dom.persistent.MutableDocumentSet) DBBroker(org.exist.storage.DBBroker) DefaultDocumentSet(org.exist.dom.persistent.DefaultDocumentSet) TransactionManager(org.exist.storage.txn.TransactionManager) Txn(org.exist.storage.txn.Txn) CollectionConfigurationManager(org.exist.collections.CollectionConfigurationManager) BrokerPool(org.exist.storage.BrokerPool)

Example 7 with CollectionConfigurationManager

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();
    }
}
Also used : DBBroker(org.exist.storage.DBBroker) FileInputSource(org.exist.util.FileInputSource) Collection(org.exist.collections.Collection) Txn(org.exist.storage.txn.Txn) CollectionConfigurationManager(org.exist.collections.CollectionConfigurationManager) BrokerPool(org.exist.storage.BrokerPool) URL(java.net.URL)

Example 8 with CollectionConfigurationManager

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);
    }
}
Also used : DBBroker(org.exist.storage.DBBroker) StringInputSource(org.exist.util.StringInputSource) TransactionManager(org.exist.storage.txn.TransactionManager) Collection(org.exist.collections.Collection) Txn(org.exist.storage.txn.Txn) CollectionConfigurationManager(org.exist.collections.CollectionConfigurationManager) BrokerPool(org.exist.storage.BrokerPool)

Example 9 with CollectionConfigurationManager

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);
    }
}
Also used : DBBroker(org.exist.storage.DBBroker) DefaultDocumentSet(org.exist.dom.persistent.DefaultDocumentSet) TransactionManager(org.exist.storage.txn.TransactionManager) Collection(org.exist.collections.Collection) Txn(org.exist.storage.txn.Txn) CollectionConfigurationManager(org.exist.collections.CollectionConfigurationManager) BrokerPool(org.exist.storage.BrokerPool)

Example 10 with CollectionConfigurationManager

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;
}
Also used : CollectionConfigurationException(org.exist.collections.CollectionConfigurationException) Collection(org.exist.collections.Collection) CollectionConfigurationManager(org.exist.collections.CollectionConfigurationManager) EXistException(org.exist.EXistException)

Aggregations

CollectionConfigurationManager (org.exist.collections.CollectionConfigurationManager)13 Txn (org.exist.storage.txn.Txn)11 Collection (org.exist.collections.Collection)10 BrokerPool (org.exist.storage.BrokerPool)9 DBBroker (org.exist.storage.DBBroker)9 TransactionManager (org.exist.storage.txn.TransactionManager)8 DefaultDocumentSet (org.exist.dom.persistent.DefaultDocumentSet)5 StringInputSource (org.exist.util.StringInputSource)5 MutableDocumentSet (org.exist.dom.persistent.MutableDocumentSet)3 EXistException (org.exist.EXistException)2 CollectionConfiguration (org.exist.collections.CollectionConfiguration)2 AtomicFSM (com.evolvedbinary.j8fu.fsm.AtomicFSM)1 FSM (com.evolvedbinary.j8fu.fsm.FSM)1 TransitionTable.transitionTable (com.evolvedbinary.j8fu.fsm.TransitionTable.transitionTable)1 AtomicLazyVal (com.evolvedbinary.j8fu.lazy.AtomicLazyVal)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Reference (java.lang.ref.Reference)1 Array (java.lang.reflect.Array)1