Package org.exist.collections

Examples of org.exist.collections.Collection


            TransactionManager transact = pool.getTransactionManager();
            Txn transaction = transact.beginTransaction();
            broker = pool.get(pool.getSecurityManager().getSystemSubject());

            Collection root = broker.getOrCreateCollection(transaction, TEST_COLLECTION_URI);
            broker.saveCollection(transaction, root);

            IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create("test.xml"), TEST_DOC);
            root.store(transaction, broker, info, TEST_DOC, false);

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


        try {
            TransactionManager transact = pool.getTransactionManager();
            Txn transaction = transact.beginTransaction();
            broker = pool.get(pool.getSecurityManager().getSystemSubject());

            Collection root = broker.getOrCreateCollection(transaction, TEST_COLLECTION_URI);
            broker.removeCollection(transaction, root);
            transact.commit(transaction);
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
View Full Code Here

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

            Collection root = broker.getCollection(col1uri);
          assertNotNull(root);

            SystemExport sysexport = new SystemExport( broker, null, null, true );
            file = sysexport.export( "backup", false, false, null );
        } finally {
          pool.release(broker);
        }
     
      clean();
     
      //check that it clean
      broker = null;
        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());

            Collection col = broker.getCollection(col1uri);
            assertNull(col);
        } finally {
          pool.release(broker);
        }

      SystemImport restore = new SystemImport(pool);
    RestoreListener listener = new DefaultRestoreListener();
    restore.restore(listener, "admin", "", "", file, "xmldb:exist://");

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

            Collection col = broker.getCollection(col1uri);
          assertNotNull(col);
         
          DocumentImpl doc = getDoc(broker, col, doc01uri.lastSegment());
          assertEquals(XML1, serializer(broker, doc));
View Full Code Here

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

            Collection root = broker.getOrCreateCollection(transaction, col1uri);
            assertNotNull(root);
            broker.saveCollection(transaction, root);

            CollectionConfigurationManager mgr = pool.getConfigurationManager();
            mgr.addConfiguration(transaction, broker, root, COLLECTION_CONFIG);

            System.out.println("store "+doc01uri);
            IndexInfo info = root.validateXMLResource(transaction, broker, doc01uri.lastSegment(), XML1);
            assertNotNull(info);
            root.store(transaction, broker, info, XML1, false);

            System.out.println("store "+doc02uri);
            info = root.validateXMLResource(transaction, broker, doc02uri.lastSegment(), XML2);
            assertNotNull(info);
            root.store(transaction, broker, info, XML2, false);

            System.out.println("store "+doc03uri);
            info = root.validateXMLResource(transaction, broker, doc03uri.lastSegment(), XML3);
            assertNotNull(info);
            root.store(transaction, broker, info, XML3, false);

            System.out.println("store "+doc11uri);
            root.addBinaryResource(transaction, broker, doc11uri.lastSegment(), BINARY.getBytes(), null);

            transact.commit(transaction);
        } catch (Exception e) {
            e.printStackTrace();
            transact.abort(transaction);
View Full Code Here

      pool2 = BrokerPool.getInstance("db2");
      pool2.registerShutdownListener(new ShutdownListenerImpl());
      user2 = pool1.getSecurityManager().getSystemSubject();
      DBBroker broker2 = pool2.get(user2);

      Collection top1 = broker1.getCollection(XmldbURI.create("xmldb:exist:///"));
      assertTrue(top1!=null);
      top1.getLock().release(Lock.READ_LOCK);
      pool1.release(broker1);
     
      Collection top2 = broker2.getCollection(XmldbURI.create("xmldb:exist:///"));
      assertTrue(top2!=null);
      top2.getLock().release(Lock.READ_LOCK);
      pool2.release(broker2);
        
   }
View Full Code Here

      throws Exception
   {
      System.out.println("Putting documents.");
      DBBroker broker1 = pool1.get(user1);
      Txn transaction1 = pool1.getTransactionManager().beginTransaction();
      Collection top1 = storeBin(broker1,transaction1,"1");
      pool1.getTransactionManager().commit(transaction1);
      top1.release(Lock.READ_LOCK);
      pool1.release(broker1);
     
      DBBroker broker2 = pool2.get(user1);
      Txn transaction2 = pool2.getTransactionManager().beginTransaction();
      Collection top2 = storeBin(broker2,transaction2,"2");
      pool2.getTransactionManager().commit(transaction2);
      top2.release(Lock.READ_LOCK);
      pool2.release(broker2);
   }
View Full Code Here

   public Collection storeBin(DBBroker broker, Txn txn,String suffix)
      throws Exception
   {
      String data = bin+suffix;
      System.out.println("Stored: "+data);
      Collection top = broker.getCollection(XmldbURI.create("xmldb:exist:///"));
      top.addBinaryResource(txn,broker,XmldbURI.create("xmldb:exist:///bin"),data.getBytes(),"text/plain");
      return top;
   }
View Full Code Here

   public boolean getBin(DBBroker broker,String suffix)
      throws Exception
   {
      BinaryDocument binDoc = null;
      try {
         Collection top = broker.getCollection(XmldbURI.create("xmldb:exist:///"));
         System.out.println("count="+top.getDocumentCount(broker));
         MutableDocumentSet docs = new DefaultDocumentSet();
         top.getDocuments(broker,docs);
         XmldbURI [] uris = docs.getNames();
         for (int i=0; i<uris.length; i++) {
            System.out.println(i+": "+uris[i].toString());
         }
         //binDoc = (BinaryDocument)broker.getXMLResource(XmldbURI.create("xmldb:exist:///bin"),Lock.READ_LOCK);
         binDoc = (BinaryDocument)top.getDocument(broker,XmldbURI.create("xmldb:exist:///bin"));
         top.release(Lock.READ_LOCK);
         assertTrue(binDoc!=null);
         ByteArrayOutputStream os = new ByteArrayOutputStream();
         broker.readBinaryResource(binDoc,os);
         String comp = os.size()>0 ? new String(os.toByteArray()) : "";
         System.out.println("Got: "+comp);
View Full Code Here

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

            Collection root = broker.getOrCreateCollection(transaction, col1uri);
            assertNotNull(root);
            broker.removeCollection(transaction, root);

            transact.commit(transaction);
        } catch (Exception e) {
View Full Code Here

      DBBroker broker = null;   
      try {
            pool = BrokerPool.getInstance();
            Subject admin = pool.getSecurityManager().authenticate("admin", "");
            broker = pool.get(admin);
            Collection collection = broker.getOrCreateCollection(null, TestConstants.TEST_COLLECTION_URI);
            IndexInfo info = collection.validateXMLResource(null, broker, TestConstants.TEST_XML_URI, XML);
            //TODO : unlock the collection here ?
            collection.store(null, broker, info, XML, false);
            @SuppressWarnings("unused")
      org.exist.dom.DocumentImpl doc = info.getDocument();
            broker.flush();
            broker.saveCollection(null, collection);
        } 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.