Package org.exist.collections

Examples of org.exist.collections.Collection$DocumentEntry


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

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

            Collection config = broker.getOrCreateCollection(transaction,
                XmldbURI.create(CollectionConfigurationManager.CONFIG_COLLECTION + "/db"));
            assertNotNull(config);
            broker.removeCollection(transaction, config);

            transact.commit(transaction);
View Full Code Here


            transact = pool.getTransactionManager();
            assertNotNull(transact);
            transaction = transact.beginTransaction();
            assertNotNull(transaction);

            Collection root = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
            assertNotNull(root);
            CollectionConfigurationManager mgr = pool.getConfigurationManager();
            mgr.addConfiguration(transaction, broker, root, config);

            IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create("test_matches.xml"), xml);
            assertNotNull(info);
            root.store(transaction, broker, info, xml, false);
           
            transact.commit(transaction);
        } catch (Exception e) {
          transact.abort(transaction);
          e.printStackTrace();
View Full Code Here

     * Return the analyzer to be used for the given field or qname. Either field
     * or qname should be specified.
     */
    private Analyzer getAnalyzer(QName qname, String fieldName, DocumentSet docs) {
        for (Iterator<Collection> i = docs.getCollectionIterator(); i.hasNext(); ) {
            Collection collection = i.next();
            IndexSpec idxConf = collection.getIndexConfiguration(broker);
            if (idxConf != null) {
                RangeIndexConfig config = (RangeIndexConfig) idxConf.getCustomIndexSpec(RangeIndex.ID);
                if (config != null) {
                    Analyzer analyzer = config.getAnalyzer(qname, fieldName);
                    if (analyzer != null)
View Full Code Here

     * Return the analyzer to be used for the given field or qname. Either field
     * or qname should be specified.
     */
    private boolean isCaseSensitive(QName qname, String fieldName, DocumentSet docs) {
        for (Iterator<Collection> i = docs.getCollectionIterator(); i.hasNext(); ) {
            Collection collection = i.next();
            IndexSpec idxConf = collection.getIndexConfiguration(broker);
            if (idxConf != null) {
                RangeIndexConfig config = (RangeIndexConfig) idxConf.getCustomIndexSpec(RangeIndex.ID);
                if (config != null && !config.isCaseSensitive(qname, fieldName)) {
                    return false;
                }
View Full Code Here

 
  private DocumentTrigger fireTriggerBefore(Transaction tx) throws TriggerException {
    if (!(item instanceof NodeProxy)) return null;
   
    DocumentImpl docimpl = ((NodeProxy) item).getDocument();
    Collection col = docimpl.getCollection();
   
    DocumentTrigger trigger = new DocumentTriggers(tx.broker, null, col, col.getConfiguration(tx.broker));
     
    trigger.beforeUpdateDocument(tx.broker, tx.tx, docimpl);

    return trigger;
  }
View Full Code Here

      reportError(output, "Failed to write to output directory: " + targetDir.getAbsolutePath());
      return;
    }
   
    List<XmldbURI> subcollections = null;
    Collection collection = null;
    try {
      collection = context.getBroker().openCollection(collectionPath, Lock.READ_LOCK);
      if (collection == null) {
        reportError(output, "Collection not found: " + collectionPath);
        return;
      }
      for (Iterator<DocumentImpl> i = collection.iterator(context.getBroker()); i.hasNext(); ) {
        DocumentImpl doc = i.next();
        if (startDate == null || doc.getMetadata().getLastModified() > startDate.getTime()) {
          if (doc.getResourceType() == DocumentImpl.BINARY_FILE) {
            saveBinary(targetDir, (BinaryDocument) doc, output);
          } else {
            saveXML(targetDir, doc, output);
          }
        }
      }
     
      subcollections = new ArrayList<>(collection.getChildCollectionCount(context.getBroker()));
      for (Iterator<XmldbURI> i = collection.collectionIterator(context.getBroker()); i.hasNext(); ) {
        subcollections.add(i.next());
      }
    } finally {
      if (collection != null)
        collection.getLock().release(Lock.READ_LOCK);
    }
   
    for (XmldbURI childURI : subcollections) {
      File childDir = new File(targetDir, childURI.lastSegment().toString());
      saveCollection(collectionPath.append(childURI), childDir, startDate, output);
View Full Code Here

            name = args[1].getStringValue();
            source = new BinarySource(data, true);
        } else {
            String uri = args[0].getStringValue();
            if (uri.startsWith(XmldbURI.XMLDB_URI_PREFIX)) {
                Collection collection = null;
                DocumentImpl doc = null;
                try {
                    XmldbURI resourceURI = XmldbURI.xmldbUriFor(uri);
                    collection = context.getBroker().openCollection(resourceURI.removeLastSegment(), Lock.READ_LOCK);
                    if (collection == null) {
                        LOG.warn("collection not found: " + resourceURI.getCollectionPath());
                        return Sequence.EMPTY_SEQUENCE;
                    }
                    doc = collection.getDocumentWithLock(context.getBroker(), resourceURI.lastSegment(), Lock.READ_LOCK);
                    if (doc == null)
                        return Sequence.EMPTY_SEQUENCE;
                    if (doc.getResourceType() != DocumentImpl.BINARY_FILE ||
                            !doc.getMetadata().getMimeType().equals("application/xquery")) {
                        throw new XPathException(this, "XQuery resource: " + uri + " is not an XQuery or " +
                                "declares a wrong mime-type");
                    }
                    source = new DBSource(context.getBroker(), (BinaryDocument) doc, false);
                    name = doc.getFileURI().toString();
                } catch (URISyntaxException e) {
                    throw new XPathException(this, "invalid module uri: " + uri + ": " + e.getMessage(), e);
                } catch (LockException e) {
                    throw new XPathException(this, "internal lock error: " + e.getMessage());
                } catch(PermissionDeniedException pde) {
                    throw new XPathException(this, pde.getMessage(), pde);
                } finally {
                    if (doc != null)
                        doc.getUpdateLock().release(Lock.READ_LOCK);
                    if(collection != null)
                        collection.release(Lock.READ_LOCK);
                }
            } else {
                // first check if the URI points to a registered module
                String location = context.getModuleLocation(uri);
                if (location != null)
View Full Code Here

     * Return the analyzer to be used for the given field or qname. Either field
     * or qname should be specified.
     */
    protected Analyzer getAnalyzer(String field, QName qname, DBBroker broker, DocumentSet docs) {
        for (Iterator<Collection> i = docs.getCollectionIterator(); i.hasNext(); ) {
            Collection collection = i.next();
            IndexSpec idxConf = collection.getIndexConfiguration(broker);
            if (idxConf != null) {
                LuceneConfig config = (LuceneConfig) idxConf.getCustomIndexSpec(LuceneIndex.ID);
                if (config != null) {
                    Analyzer analyzer;
                    if (field == null)
View Full Code Here

    }

    protected QueryParserWrapper getQueryParser(String field, Analyzer analyzer, DocumentSet docs) {
        if (docs != null) {
            for (Iterator<Collection> i = docs.getCollectionIterator(); i.hasNext(); ) {
                Collection collection = i.next();
                IndexSpec idxConf = collection.getIndexConfiguration(broker);
                if (idxConf != null) {
                    LuceneConfig config = (LuceneConfig) idxConf.getCustomIndexSpec(LuceneIndex.ID);
                    if (config != null) {
                        QueryParserWrapper parser = config.getQueryParser(field, analyzer);
                        if (parser != null) {
View Full Code Here

    DBBroker broker = acquireBroker();
    try {
                    if (broker.getCollection(XmldbURI.create(path)) != null) return true;
                    String folderPath = path.substring(0, i);
                    String name = path.substring(i+1);     
                    Collection collection = broker.openCollection(XmldbURI.create(folderPath), Lock.NO_LOCK);
                    if (collection == null) return false;
                    return collection.getDocument(broker, XmldbURI.create(name)) != null;
                } catch(PermissionDeniedException pde) {
                    throw new DatabaseException(pde.getMessage(), pde);
                } finally {
      releaseBroker(broker);
    }
View Full Code Here

TOP

Related Classes of org.exist.collections.Collection$DocumentEntry

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.