Package org.exist.collections

Examples of org.exist.collections.IndexInfo


      InputStream is = null;
      try {
        if (mimeType.isXMLType()) {
          // store as xml resource
          is = new FileInputStream(currentFile);
          IndexInfo info = currentDirectory.validateXMLResource(
              transaction, broker, fileName, new InputSource(
                  new InputStreamReader(is)));
//                  new InputStreamReader(is, charset)));
          is.close();
          info.getDocument().getMetadata().setMimeType(
              mimeType.getName());
          is = new FileInputStream(currentFile);
          currentDirectory
              .store(transaction, broker, info, new InputSource(
                  new InputStreamReader(is)), false);
View Full Code Here


   
    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);
     
View Full Code Here

            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);
View Full Code Here

        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 ...");
View Full Code Here

          broker = pool.get(pool.getSecurityManager().getSystemSubject());
          assertNotNull(broker);           
            TransactionManager mgr = pool.getTransactionManager();
            assertNotNull(mgr);
           
            IndexInfo info = init(broker, mgr);
            assertNotNull(info);
            MutableDocumentSet docs = new DefaultDocumentSet();
            docs.add(info.getDocument());
            XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST);
            assertNotNull(proc);
           
            Txn transaction = mgr.beginTransaction();
            assertNotNull(transaction);
View Full Code Here

           
            File files[] = dir.listFiles();
            assertNotNull(files);
           
            File f;
            IndexInfo info;
           
            BinaryDocument doc = test2.addBinaryResource(transaction, broker, TestConstants.TEST_BINARY_URI, "Some text data".getBytes(), null);
            assertNotNull(doc);
           
            // store some documents. Will be replaced below
View Full Code Here

            String existHome = System.getProperty("exist.home");
            File existDir = existHome==null ? new File(".") : new File(existHome);
      File f = new File(existDir,"samples/shakespeare/r_and_j.xml");
      assertNotNull(f);
      IndexInfo info = test2.validateXMLResource(transaction, broker, TestConstants.TEST_XML_URI, new InputSource(f.toURI().toASCIIString()));
      assertNotNull(info);
      test2.store(transaction, broker, info, new InputSource(f.toURI().toASCIIString()), false);

            System.out.println("Moving document test.xml to new_test.xml ...");
      broker.moveResource(transaction, info.getDocument(), root, XmldbURI.create("new_test.xml"));
      broker.saveCollection(transaction, root);

      transact.commit(transaction);
      System.out.println("Transaction commited ...");
    } catch (Exception e) {
View Full Code Here

            String existHome = System.getProperty("exist.home");
            File existDir = existHome==null ? new File(".") : new File(existHome);
      File f = new File(existDir,"samples/shakespeare/r_and_j.xml");
      assertNotNull(f);
            IndexInfo info = test2.validateXMLResource(transaction, broker, XmldbURI.create("new_test2.xml"),
          new InputSource(f.toURI().toASCIIString()));
      test2.store(transaction, broker, info, new InputSource(f.toURI()
          .toASCIIString()), false);

      transact.commit(transaction);

      transaction = transact.beginTransaction();

      broker.moveResource(transaction, info.getDocument(), root,
          XmldbURI.create("new_test2.xml"));
      broker.saveCollection(transaction, root);

      pool.getTransactionManager().getJournal().flushToLog(true);
    } finally {
View Full Code Here

            if (pool != null) pool.release(broker);
        }
    }

    protected IndexInfo init(DBBroker broker, TransactionManager mgr) {
      IndexInfo info = null;
      Txn transaction = null;
      try {
       
        transaction = mgr.beginTransaction();       
          System.out.println("Transaction started ...");
View Full Code Here

            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);           
            TransactionManager mgr = pool.getTransactionManager();
            assertNotNull(mgr);
           
            IndexInfo info = init(broker, mgr);
            assertNotNull(info);
            MutableDocumentSet docs = new DefaultDocumentSet();
            docs.add(info.getDocument());
            XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST);
            assertNotNull(proc);
           
            Txn transaction = mgr.beginTransaction();
            assertNotNull(transaction);
            System.out.println("Transaction started ...");
           
            String xupdate;
            Modification modifications[];
           
            // append some new element to records
            for (int i = 1; i <= 200; i++) {
                xupdate =
                    "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
                    "   <xu:append select=\"/products\">" +
                    "       <product>" +
                    "           <xu:attribute name=\"id\"><xu:value-of select=\"count(/products/product) + 1\"/></xu:attribute>" +
                    "           <description>Product " + i + "</description>" +
                    "           <price>" + (i * 2.5) + "</price>" +
                    "           <stock>" + (i * 10) + "</stock>" +
                    "       </product>" +
                    "   </xu:append>" +
                    "</xu:modifications>";
                proc.setBroker(broker);
                proc.setDocumentSet(docs);
                modifications = proc.parse(new InputSource(new StringReader(xupdate)));
                assertNotNull(modifications);
                modifications[0].process(transaction);
                proc.reset();
            }
           
            DOMFile domDb = ((NativeBroker) broker).getDOMFile();
            assertNotNull(domDb);
            System.out.println(domDb.debugPages(info.getDocument(), false));
           
            mgr.commit(transaction);
            System.out.println("Transaction commited ...");
           
            // the following transaction will not be committed and thus undone during recovery
View Full Code Here

TOP

Related Classes of org.exist.collections.IndexInfo

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.