Package org.exist.dom

Examples of org.exist.dom.MutableDocumentSet


                    }

                } else if (rootNS != null && rootNS.equals(XUpdateProcessor.XUPDATE_NS)) {

                    LOG.debug("Got xupdate request: " + content);
                    final MutableDocumentSet docs = new DefaultDocumentSet();
                    final Collection collection = broker.getCollection(pathUri);
                    if (collection != null) {
                        collection.allDocs(broker, docs, true);

                    } else {
                        final DocumentImpl xupdateDoc = broker.getResource(pathUri, Permission.READ);

                        if (xupdateDoc != null) {
                            docs.add(xupdateDoc);

                        } else {
                            broker.getAllXMLResources(docs);
                        }
                    }
View Full Code Here


            // sections in the query that can be safely cached
      //          if(cached != null) {
      //              result = cached;
      //              docs = cachedDocs;
      //          } else {
      MutableDocumentSet mdocs = new DefaultDocumentSet();
            try {
                context.getBroker().getAllXMLResources(mdocs);
            } catch(final PermissionDeniedException pde) {
                LOG.error(pde.getMessage(), pde);
                throw new XPathException(this, pde);
            }
      docs = mdocs;
      //          }
  } else {
      List<String> args = getParameterValues(contextSequence, contextItem);
      if(cachedArgs != null)
    {cacheIsValid = compareArguments(cachedArgs, args);}
      if(cacheIsValid) {
    result = cached;
    docs = cachedDocs;
      } else {
                MutableDocumentSet mdocs = new DefaultDocumentSet();
    for(int i = 0; i < args.size(); i++) {
        try {
      final String next = (String)args.get(i);
      XmldbURI nextUri = new AnyURIValue(next).toXmldbURI();
      if(nextUri.getCollectionPath().length() == 0) {
          throw new XPathException(this, "Invalid argument to " + XMLDBModule.PREFIX + ":document() function: empty string is not allowed here.");
      }
      if(nextUri.numSegments()==1) {                    
          nextUri = context.getBaseURI().toXmldbURI().resolveCollectionPath(nextUri);
      }
      final DocumentImpl doc = context.getBroker().getResource(nextUri, Permission.READ);
      if(doc == null) {
          if (context.isRaiseErrorOnFailedRetrieval()) {
        throw new XPathException(this, ErrorCodes.FODC0002, "can not access '" + nextUri + "'");
          }           
      }else {
          mdocs.add(doc);
      }
        } catch (final XPathException e) { //From AnyURIValue constructor
                        e.setLocation(line, column);
      logger.error("From AnyURIValue constructor:", e);
View Full Code Here

        return new StringValue(text.toString());
    }

    private void generateWordList() throws XPathException {
    try {
      MutableDocumentSet docs = new DefaultDocumentSet();
            docs = context.getBroker().getAllXMLResources(docs);
            final IndexWorker indexWorker = context.getBroker().getIndexController().getWorkerByIndexName("lucene-index");

            final Map options = new HashMap();
            options.put(OrderedValuesIndex.START_VALUE, "");
View Full Code Here

            if (childColl != null) {
                checkSub(broker, childColl);
            }
        }
   
    MutableDocumentSet childDocs = new DefaultDocumentSet();
    LockedDocumentMap lockedDocuments = new LockedDocumentMap();
    col.getDocuments(broker, childDocs, lockedDocuments, Lock.WRITE_LOCK);
   
    for (Iterator<DocumentImpl> itChildDocs = childDocs.getDocumentIterator(); itChildDocs.hasNext();) {
      DocumentImpl childDoc = itChildDocs.next();
     
      MetaData.get().addMetas(childDoc);
    }
  }
View Full Code Here

    if(policyCollection == null)
      {return null;}
    final int documentCount = policyCollection.getDocumentCount(broker);
    if(documentCount == 0)
      {return null;}
    final MutableDocumentSet documentSet = new DefaultDocumentSet(documentCount);
    return policyCollection.allDocs(broker, documentSet, recursive);
  }
View Full Code Here

   * @see org.xmldb.api.modules.XUpdateQueryService#updateResource(java.lang.String, java.lang.String)
   */
  public long updateResource(String resource, String xupdate)
    throws XMLDBException {
    final long start = System.currentTimeMillis();
    MutableDocumentSet docs = new DefaultDocumentSet();
        final TransactionManager transact = pool.getTransactionManager();
        final Txn transaction = transact.beginTransaction();
      final Subject preserveSubject = pool.getSubject();
    DBBroker broker = null;
    final org.exist.collections.Collection c = parent.getCollection();
    try {
      broker = pool.get(user);
      if (resource == null) {
        docs = c.allDocs(broker, docs, true);
      } else {
        final XmldbURI resourceURI = XmldbURI.xmldbUriFor(resource);
        final DocumentImpl doc = c.getDocument(broker, resourceURI);
        if(doc == null) {
                    transact.abort(transaction);
          throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "Resource not found: " + resource);
                }
        docs.add(doc);
      }
      if(processor == null)
        {processor = new XUpdateProcessor(broker, docs, parent.getAccessContext());}
      else {
        processor.setBroker(broker);
View Full Code Here

            Collection childColl = broker.getOrCreateCollection(null, XmldbURI.ROOT_COLLECTION_URI.append(childName));
           
            checkSub(broker, md, childColl);
        }
   
    MutableDocumentSet childDocs = new DefaultDocumentSet();
    LockedDocumentMap lockedDocuments = new LockedDocumentMap();
    col.getDocuments(broker, childDocs, lockedDocuments, Lock.WRITE_LOCK);
   
    for (Iterator<DocumentImpl> itChildDocs = childDocs.getDocumentIterator(); itChildDocs.hasNext();) {
      DocumentImpl childDoc = itChildDocs.next();
     
      Metas metas = md.addMetas(childDoc);
     
      if (metas != null) {
View Full Code Here

    try {
          boolean deadlockCaught;
            do {
                reservedBroker = brokerPool.get(user);
                deadlockCaught = false;
            MutableDocumentSet docs = null;
              try {
                  final org.exist.collections.Collection coll = collection.getCollection();
                  lockedDocuments = new LockedDocumentMap();
                  docs = new DefaultDocumentSet();
                  coll.allDocs(reservedBroker, docs, true, lockedDocuments, Lock.WRITE_LOCK);
              } catch (final LockException e) {
                  LOG.debug("Deadlock detected. Starting over again. Docs: " + docs.getDocumentCount() + "; locked: " +
                    lockedDocuments.size());
          lockedDocuments.unlock();
                    brokerPool.release(reservedBroker);
                    deadlockCaught = true;
                    } catch (final PermissionDeniedException e) {
View Full Code Here

TOP

Related Classes of org.exist.dom.MutableDocumentSet

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.