Package org.exist.collections

Examples of org.exist.collections.Collection


      throws SVNException {
    System.out.println("addDir");

    currentPath = path;

    Collection child;

    try {
      child = broker.getOrCreateCollection(transaction, myRootDirectory
          .getURI().append(path));
      broker.saveCollection(transaction, child);
View Full Code Here


    TransactionManager mgr = pool.getTransactionManager();
    Txn transaction = mgr.beginTransaction();       
    System.out.println("Transaction started ...");
   
    try {
      Collection root = broker.getOrCreateCollection(transaction, TEST_COLLECTION);
      broker.saveCollection(transaction, root);
     
      IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create(docName), data);
      //TODO : unlock the collection here ?
      root.store(transaction, broker, info, data, false);
    
      mgr.commit(transaction);
     
      DocumentImpl doc = root.getDocument(broker, XmldbURI.create(docName));
        broker.getSerializer().serialize(doc);
    } catch (IOException e) {
      mgr.abort(transaction);
      fail();
    }
View Full Code Here

        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);                      
            TransactionManager transact = pool.getTransactionManager();
            assertNotNull(transact);
            Collection test = storeDocs(broker, transact);
            Txn transaction;
           
            transaction = transact.beginTransaction();
            System.out.println("Transaction started ...");
View Full Code Here

        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);
            TransactionManager transact = pool.getTransactionManager();
            assertNotNull(transact);
            Collection test = storeDocs(broker, transact);
            Txn transaction;

            transaction = transact.beginTransaction();
            System.out.println("Transaction started ...");

            System.out.println("Removing documents one by one ...");
            for (Iterator<DocumentImpl> i = test.iterator(broker); i.hasNext(); ) {
                DocumentImpl doc = i.next();
                broker.removeXMLResource(transaction, doc);
            }
            broker.saveCollection(transaction, test);
            transact.commit(transaction);
View Full Code Here

        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);
            TransactionManager transact = pool.getTransactionManager();
            assertNotNull(transact);
            Collection test = storeDocs(broker, transact);
            Txn transaction;

            transaction = transact.beginTransaction();
            System.out.println("Transaction started ...");

            System.out.println("Replacing resources ...");
            TestDataGenerator generator = new TestDataGenerator("xdb", COUNT);
            System.out.println("Generating " + COUNT + " files...");
            File[] files = generator.generate(broker, test, generateXQ);

            int j = 0;
            for (Iterator<DocumentImpl> i = test.iterator(broker); i.hasNext() && j < files.length; j++) {
                DocumentImpl doc = i.next();
                InputSource is = new InputSource(files[j].toURI().toASCIIString());
                assertNotNull(is);
                IndexInfo info = test.validateXMLResource(transaction, broker, doc.getURI(), is);
                assertNotNull(info);
                test.store(transaction, broker, info, is, false);
            }
            generator.releaseAll();
            transact.commit(transaction);
            System.out.println("Transaction committed ...");
      } catch (Exception e) {
View Full Code Here

    private Collection storeDocs(DBBroker broker, TransactionManager transact) throws Exception {
        Txn transaction = transact.beginTransaction();
        assertNotNull(transaction);
        System.out.println("Transaction started ...");

        Collection test = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
        assertNotNull(test);
        broker.saveCollection(transaction, test);

        CollectionConfigurationManager mgr = broker.getBrokerPool().getConfigurationManager();
        mgr.addConfiguration(transaction, broker, test, COLLECTION_CONFIG);

        InputSource is = new InputSource(new File("samples/shakespeare/hamlet.xml").toURI().toASCIIString());
        assertNotNull(is);
        IndexInfo info = test.validateXMLResource(transaction, broker, XmldbURI.create("hamlet.xml"), is);
        assertNotNull(info);
        test.store(transaction, broker, info, is, false);
        transact.commit(transaction);
        System.out.println("Transaction commited ...");

        transaction = transact.beginTransaction();
        TestDataGenerator generator = new TestDataGenerator("xdb", COUNT);
        System.out.println("Generating " + COUNT + " files...");
        File[] files = generator.generate(broker, test, generateXQ);
        for (int i = 0; i < files.length; i++) {
            File file = files[i];
            is = new InputSource(file.toURI().toASCIIString());
            assertNotNull(is);
            info = test.validateXMLResource(transaction, broker, XmldbURI.create(file.getName()), is);
            assertNotNull(info);
            test.store(transaction, broker, info, is, false);
        }
        generator.releaseAll();
        transact.commit(transaction);
        System.out.println("Transaction commited ...");
        return test;
View Full Code Here

   *
   * @throws TriggerException
   */
  private void prepareTrigger(Txn transaction, DocumentImpl doc) throws TriggerException {
           
      final Collection col = doc.getCollection();
         
            final DocumentTrigger trigger = new DocumentTriggers(broker, col);
           
            trigger.beforeUpdateDocument(broker, transaction, doc);
            triggers.put(doc.getDocId(), trigger);
View Full Code Here

            transact = pool.getTransactionManager();
           
            transaction = transact.beginTransaction();           
            System.out.println("Transaction started ...");
           
            Collection root = broker.getOrCreateCollection(transaction, TEST_COLLECTION_URI);
            broker.saveCollection(transaction, root);
           
            Collection test = broker.getOrCreateCollection(transaction, TEST_COLLECTION_URI.append("test2"));
            broker.saveCollection(transaction, test);
           
            transact.commit(transaction);
            System.out.println("Transaction commited ...");
        } catch (Exception e) {
View Full Code Here

            BTree btree = ((NativeBroker)broker).getStorage(NativeBroker.COLLECTIONS_DBX_ID);
            Writer writer = new StringWriter();
            btree.dump(writer);
            System.out.println(writer.toString());
           
            Collection test = broker.getCollection(TEST_COLLECTION_URI.append("test2"));
            assertNotNull(test);
            System.out.println("Contents of collection " + test.getURI() + ":");
            for (Iterator<DocumentImpl> i = test.iterator(broker); i.hasNext(); ) {
                DocumentImpl next = i.next();
                System.out.println("- " + next.getURI());
            }
        } catch (Exception e) {           
            fail(e.getMessage());             
View Full Code Here

        DBBroker broker = null;
        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);

            Collection root = broker.getCollection(TestConstants.TEST_COLLECTION_URI);
            assertNotNull(root);

            binaryDoc = (BinaryDocument)root.getDocument(broker, uri);

        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        } finally {
View Full Code Here

TOP

Related Classes of org.exist.collections.Collection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.