Package org.exist.collections

Examples of org.exist.collections.IndexInfo


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


                } else {
                  vCollection.removeXMLResource(transaction, broker, lastRev.getFileURI());
                }
              }

              IndexInfo info = vCollection.validateXMLResource(transaction, broker, diffUri, editscript);
              vCollection.store(transaction, broker, info, editscript, false);
            }
          } catch (Exception e) {
            LOG.warn("Caught exception in VersioningTrigger: " + e.getMessage(), e);
          } finally {
View Full Code Here

                } else {
                  vCollection.removeXMLResource(transaction, broker, lastRev.getFileURI());
                }
              }

              IndexInfo info = vCollection.validateXMLResource(transaction, broker, diffUri, editscript);
              vCollection.store(transaction, broker, info, editscript, false);                   
            }
          } catch (Exception e) {
            LOG.warn("Caught exception in VersioningTrigger: " + e.getMessage(), e);
          } finally {
View Full Code Here

        final Txn transaction = transact.beginTransaction();
        try {
            final long startTime = System.currentTimeMillis();
            broker = factory.getBrokerPool().get(user);
        
            IndexInfo info = null;
            InputSource source = null;
            Collection collection = null;
            try {
              collection = broker.openCollection(docUri.removeLastSegment(), Lock.WRITE_LOCK);
              if (collection == null) {
                  transact.abort(transaction);
                  throw new EXistException("Collection " + docUri.removeLastSegment() + " not found");
              }
 
              if (overwrite == 0) {
                  final DocumentImpl old = collection.getDocument(broker, docUri.lastSegment());
                  //TODO : register the lock within the transaction ?
                  if (old != null) {
                      transact.abort(transaction);
                      throw new PermissionDeniedException("Document exists and overwrite is not allowed");
                  }
              }
             
              final InputStream is = new ByteArrayInputStream(xml);
              source = new InputSource(is);
              info = collection.validateXMLResource(transaction, broker, docUri.lastSegment(), source);
              final MimeType mime = MimeTable.getInstance().getContentTypeFor(docUri.lastSegment());
              if (mime != null && mime.isXMLType()){
                info.getDocument().getMetadata().setMimeType(mime.getName());
              }
              if (created != null)
                  {info.getDocument().getMetadata().setCreated( created.getTime());}           
             
              if (modified != null)
                  {info.getDocument().getMetadata().setLastModified( modified.getTime());}
             
            } finally {
              if (collection != null)
                {collection.release(Lock.WRITE_LOCK);}
            }
View Full Code Here

      final boolean treatAsXML=(isXML!=null && isXML.booleanValue()) || (isXML==null && mime.isXMLType());
      try {
        broker = factory.getBrokerPool().get(user);
        Collection collection = null;
        IndexInfo info = null;

        try {

          collection = broker.openCollection(docUri.removeLastSegment(), Lock.WRITE_LOCK);
          if (collection == null) {
            transact.abort(transaction);
            throw new EXistException("Collection " + docUri.removeLastSegment() + " not found");
          }

          if (overwrite == 0) {
            final DocumentImpl old = collection.getDocument(broker, docUri.lastSegment());
            if (old != null) {
              transact.abort(transaction);
              throw new PermissionDeniedException("Old document exists and overwrite is not allowed");
            }
          }

          //XML
          if(treatAsXML) {
            info = collection.validateXMLResource(transaction, broker, docUri.lastSegment(), source);
            if (created != null)
              {info.getDocument().getMetadata().setCreated(created.getTime());}                 
            if (modified != null)
              {info.getDocument().getMetadata().setLastModified(modified.getTime());}                 
          } else {
            final InputStream is = source.getByteStream();
            doc = collection.addBinaryResource(transaction, broker, docUri.lastSegment(), is,
                mime.getName(), source.getByteStreamLength());
            is.close();
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[];
           
            xupdate =
                "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
                "   <xu:append select=\"/products\">" +
                "       <product id=\"1\">" +
                "           <description>Product 1</description>" +
                "           <price>24.30</price>" +
                "           <stock>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();
           
            // 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:insert-before select=\"/products/product[1]\">" +
                    "       <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:insert-before>" +
                    "</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

            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

            broker.saveCollection(transaction, root);

            File files[] = dir.listFiles();
            assertNotNull(files);
            File f;
            IndexInfo info;
            for (int i = 0; i < files.length; i++) {
                f = files[i];
                MimeType mime = MimeTable.getInstance().getContentTypeFor(f.getName());
                if (mime == null || mime.isXMLType()) {
                    try {
View Full Code Here

           
            Collection test2 = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI2);
            assertNotNull(test2);
            broker.saveCollection(transaction, test2);
           
            IndexInfo info = test2.validateXMLResource(transaction, broker, TestConstants.TEST_XML_URI, TEST_XML);
            assertNotNull(info);
            //TODO : unlock the collection here ?
           
            test2.store(transaction, broker, info, TEST_XML, false);
           
            transact.commit(transaction);
            System.out.println("Transaction commited ...");
           
            transaction = transact.beginTransaction();
            assertNotNull(transaction);
            System.out.println("Transaction started ...");
           
            MutableDocumentSet docs = new DefaultDocumentSet();
            docs.add(info.getDocument());
            XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST);
            assertNotNull(proc);
           
            String xupdate;
            Modification modifications[];
View Full Code Here

            Writer writer = new StringWriter();
            domDb.dump(writer);
            System.out.println(writer.toString());
           
            File f;
            IndexInfo info;
           
            // store some documents. Will be replaced below
            File dir = new File(xmlDir);
            assertNotNull(dir);
            File[] docs = dir.listFiles();
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.