Package org.exist.dom

Examples of org.exist.dom.StoredNode


    public VersioningFilter() {
    }

    public void startElement(QName qname, AttrList attribs) throws SAXException {
        if (elementStack == 0) {
            StoredNode node = getCurrentNode();
            if (node != null) {
                DocumentImpl doc = node.getDocument();
                XmldbURI uri = doc.getURI();
                if (!uri.startsWith(XmldbURI.SYSTEM_COLLECTION_URI)) {
                   
                    if (doc.getCollection().getConfiguration(getBroker()).triggerRegistered(VersioningTrigger.class)) {
                        try {
View Full Code Here


                    reindexRequired = true;
                    break;
                }
            }
            if (reindexRequired) {
                StoredNode topMost = null;
                StoredNode currentNode = node;
                while (currentNode != null) {
                    if (config.get(currentNode.getQName()) != null)
                      topMost = currentNode;
                    if (currentNode.getDocument().getCollection().isTempCollection() && currentNode.getNodeId().getTreeLevel() == 2)
                        break;
                    //currentNode = (StoredNode) currentNode.getParentNode();
                    currentNode = currentNode.getParentStoredNode();
                }
                return topMost;
            }
        }
        return null;
View Full Code Here

          final NotificationService notifier = context.getBroker().getBrokerPool().getNotificationService();
                final StoredNode[] ql = selectAndLock(transaction, inSeq);
                final IndexListener listener = new IndexListener(ql);
                NodeImpl parent;
                for (int i = 0; i < ql.length; i++) {
                    final StoredNode node = ql[i];
                    final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                    if (!doc.getPermissions().validate(context.getUser(), Permission.WRITE)) {
                        //transact.abort(transaction);   
                        throw new PermissionDeniedException("User '" + context.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                    }
                    doc.getMetadata().setIndexListener(listener);
                   
                    //update the document
                    parent = (NodeImpl) node.getParentNode();
                    if (parent==null) {
                        LOG.debug("Cannot remove the document element (no parent node)");
                        throw new XPathException(this,
                                "It is not possible to remove the document element.");
View Full Code Here

            //start a transaction
            final Txn transaction = getTransaction();
        try {
          final NotificationService notifier = context.getBroker().getBrokerPool().getNotificationService();

                final StoredNode ql[] = selectAndLock(transaction, inSeq);
                final IndexListener listener = new IndexListener(ql);
                TextImpl text;
                AttrImpl attribute;
                ElementImpl parent;
                for (int i = 0; i < ql.length; i++) {
                    final StoredNode node = ql[i];
                    final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                    if (!doc.getPermissions().validate(context.getUser(),
                            Permission.WRITE)){
                            throw new XPathException(this, "User '" + context.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                    }
                    doc.getMetadata().setIndexListener(listener);
                                       
                    //update the document
                    switch (node.getNodeType())
                    {
                        case Node.ELEMENT_NODE:
                final NodeListImpl content = new NodeListImpl();
                for (final SequenceIterator j = contentSeq.iterate(); j.hasNext(); ) {
                  final Item next = j.nextItem();
                  if (Type.subTypeOf(next.getType(), Type.NODE))
                    {content.add(((NodeValue)next).getNode());}
                  else {
                    text = new TextImpl(next.getStringValue());
                    content.add(text);
                  }
                }
                            ((ElementImpl) node).update(transaction, content);
                            break;
                        case Node.TEXT_NODE:
                            parent = (ElementImpl) node.getParentNode();
                          text = new TextImpl(contentSeq.getStringValue());
                            text.setOwnerDocument(doc);
                            parent.updateChild(transaction, node, text);
                            break;
                        case Node.ATTRIBUTE_NODE:
                            parent = (ElementImpl) node.getParentNode();
                            if (parent == null) {
                                LOG.warn("parent node not found for "
                                        + node.getNodeId());
                                break;
                            }
                            final AttrImpl attr = (AttrImpl) node;
                            attribute = new AttrImpl(attr.getQName(), contentSeq.getStringValue(), context.getBroker().getBrokerPool().getSymbols());
                            attribute.setOwnerDocument(doc);
View Full Code Here

   * @param node2 the node to which down the XML fragment is delivered as a string
   * @return fragment between the two nodes
   * @throws XPathException
   */
  private StringBuilder getFragmentBetween(Node node1, Node node2) throws XPathException {
    final StoredNode storedNode1 = (StoredNode) node1;
    final StoredNode storedNode2 = (StoredNode) node2;
    final String node1NodeId = storedNode1.getNodeId().toString();
    String node2NodeId = "-1";
    if (! (node2 == null))
      {node2NodeId = storedNode2.getNodeId().toString();}
    final DocumentImpl docImpl = (DocumentImpl) node1.getOwnerDocument();
    BrokerPool brokerPool = null;
    DBBroker dbBroker = null;
    final StringBuilder resultFragment = new StringBuilder("");
    String actualNodeId = "-2";
    boolean getFragmentMode = false;
    try {
      brokerPool = docImpl.getBrokerPool();
      dbBroker = brokerPool.get(null);
      EmbeddedXMLStreamReader reader = null;
      final NodeList children = docImpl.getChildNodes();
      for (int i = 0; i < children.getLength(); i++) {
        final StoredNode docChildStoredNode = (StoredNode) children.item(i);
        final int docChildStoredNodeType = docChildStoredNode.getNodeType();
        reader = dbBroker.getXMLStreamReader(docChildStoredNode, false);
        while (reader.hasNext() && ! node2NodeId.equals(actualNodeId) && docChildStoredNodeType != Node.PROCESSING_INSTRUCTION_NODE && docChildStoredNodeType != Node.COMMENT_NODE) {
          final int status = reader.next();
          switch (status) {
            case XMLStreamReader.START_DOCUMENT:
View Full Code Here

        // acquire a lock on all documents
          // we have to avoid that node positions change
          // during the modification
          lockedDocuments.lock(context.getBroker(), true, false);
         
        final StoredNode ql[] = new StoredNode[nodes.getItemCount()];
      for (int i = 0; i < ql.length; i++) {
                final Item item = nodes.itemAt(i);
                if (!Type.subTypeOf(item.getType(), Type.NODE))
                    {throw new XPathException(this, "XQuery update expressions can only be applied to nodes. Got: " +
                        item.getStringValue());}
View Full Code Here

      final Sequence out = new ValueSequence();
      for (final SequenceIterator i = inSeq.iterate(); i.hasNext(); ) {
        Item item = i.nextItem();
        if (item.getType() == Type.DOCUMENT) {
          if (((NodeValue)item).getImplementationType() == NodeValue.PERSISTENT_NODE) {
            final StoredNode root = (StoredNode) ((NodeProxy)item).getDocument().getDocumentElement();
            item = new NodeProxy(root.getDocument(), root.getNodeId(), root.getInternalAddress());
          } else {
            item = (Item)((NodeValue) item).getOwnerDocument().getDocumentElement();
          }
        }
        if (Type.subTypeOf(item.getType(), Type.NODE)) {
View Full Code Here

        contentSeq = deepCopy(contentSeq);
       
        //start a transaction
        final Txn transaction = getTransaction();
        try {
            final StoredNode ql[] = selectAndLock(transaction, inSeq);
            final IndexListener listener = new IndexListener(ql);
            final NotificationService notifier = context.getBroker().getBrokerPool().getNotificationService();
            Item temp;
            TextImpl text;
            AttrImpl attribute;
            ElementImpl parent;
            for (int i = 0; i < ql.length; i++) {
                final StoredNode node = ql[i];
                final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                if (!doc.getPermissions().validate(context.getUser(), Permission.WRITE)) {
                        throw new PermissionDeniedException("User '" + context.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                }
                doc.getMetadata().setIndexListener(listener);
               
                //update the document
                parent = (ElementImpl) node.getParentStoredNode();
                if (parent == null)
                    {throw new XPathException(this, "The root element of a document can not be replaced with 'update replace'. " +
                            "Please consider removing the document or use 'update value' to just replace the children of the root.");}
                switch (node.getNodeType()) {
                    case Node.ELEMENT_NODE:
                        temp = contentSeq.itemAt(0);
            if (!Type.subTypeOf(temp.getType(), Type.NODE))
              {throw new XPathException(this,
                  Messages.getMessage(Error.UPDATE_REPLACE_ELEM_TYPE,
View Full Code Here

                final StoredNode[] ql = selectAndLock(transaction, inSeq);
                final NotificationService notifier = context.getBroker().getBrokerPool().getNotificationService();
                final IndexListener listener = new IndexListener(ql);               
                final NodeList contentList = seq2nodeList(contentSeq);
                for (int i = 0; i < ql.length; i++) {
                    final StoredNode node = ql[i];
                    final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                    if (!doc.getPermissions().validate(context.getUser(), Permission.WRITE)) {
                        throw new PermissionDeniedException("User '" + context.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                    }
                    doc.getMetadata().setIndexListener(listener);
                   
                    //update the document
            if (mode == INSERT_APPEND) {
              node.appendChildren(transaction, contentList, -1);
            } else {
              final NodeImpl parent = (NodeImpl) node.getParentNode();
                      switch (mode) {
                          case INSERT_BEFORE:
                              parent.insertBefore(transaction, contentList, node);
                              break;
                          case INSERT_AFTER:
View Full Code Here

                final StoredNode[] ql = selectAndLock(transaction, inSeq);
                NodeImpl parent;
                final IndexListener listener = new IndexListener(ql);
                final NotificationService notifier = context.getBroker().getBrokerPool().getNotificationService();
                for (int i = 0; i < ql.length; i++) {
                    final StoredNode node = ql[i];
                    final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                    if (!doc.getPermissions().validate(context.getUser(), Permission.WRITE)) {
                            throw new PermissionDeniedException("User '" + context.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                    }
                    doc.getMetadata().setIndexListener(listener);
                   
                    //update the document
                    parent = (NodeImpl) node.getParentNode();
                    switch (node.getNodeType()) {
                        case Node.ELEMENT_NODE:
                            final ElementImpl newElem = new ElementImpl((ElementImpl) node);
                            newElem.setNodeName(newQName, context.getBroker().getBrokerPool().getSymbols());
                            parent.updateChild(transaction, node, newElem);
                            break;
View Full Code Here

TOP

Related Classes of org.exist.dom.StoredNode

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.