Package org.exist.storage.dom

Examples of org.exist.storage.dom.DOMTransaction


     * @param doc the document object to check
     * @return
     */
    public ErrorReport checkDocument(final DocumentImpl doc) {
        final DOMFile domDb = ( (NativeBroker)broker ).getDOMFile();
        return (ErrorReport)new DOMTransaction( this, domDb, Lock.WRITE_LOCK, doc ) {
            public Object start() {
                EmbeddedXMLStreamReader reader = null;
                try {
                    final ElementImpl root = (ElementImpl)doc.getDocumentElement();
                    if (root == null) {
View Full Code Here


     * @return  null if the document is consistent, an error report otherwise.
     */
    public ErrorReport checkXMLTree( final DocumentImpl doc )
    {
        final DOMFile domDb = ( (NativeBroker)broker ).getDOMFile();
        return( (ErrorReport)new DOMTransaction( this, domDb, Lock.WRITE_LOCK, doc ) {
                    public Object start() {
                        EmbeddedXMLStreamReader reader = null;
                        try {
                            final ElementImpl             root            = (ElementImpl)doc.getDocumentElement();
                            reader = broker.getXMLStreamReader( root, true );
View Full Code Here

         */
        public void store() {
            final DocumentImpl doc = (DocumentImpl) node.getOwnerDocument();
            if(mode == MODE_STORE && node.getNodeType() == Node.ELEMENT_NODE && level <= defaultIndexDepth) {
                //TODO : used to be this, but NativeBroker.this avoids an owner change
                new DOMTransaction(NativeBroker.this, domDb, Lock.WRITE_LOCK) {
                    @Override
                    public Object start() throws ReadOnlyException {
                        try {
                            domDb.addValue(transaction, new NodeRef(doc.getDocId(), node.getNodeId()), address);
                        } catch(final BTreeException | IOException e) {
View Full Code Here

                    //Remove doc's metadata
                    // WM: now removed in one step. see above.
                    //removeResourceMetadata(transaction, doc);
                    //Remove document nodes' index entries
                    new DOMTransaction(this, domDb, Lock.WRITE_LOCK) {
                        @Override
                        public Object start() {
                            try {
                                final Value ref = new NodeRef(doc.getDocId());
                                final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);
                                domDb.remove(transaction, query, null);
                            } catch(final BTreeException e) {
                                LOG.warn("btree error while removing document", e);
                            } catch(final IOException e) {
                                LOG.warn("io error while removing document", e);
                            } catch(final TerminatedException e) {
                                LOG.warn("method terminated", e);
                            }
                            return null;
                        }
                    }.run();
                    //Remove nodes themselves
                    new DOMTransaction(this, domDb, Lock.WRITE_LOCK) {
                        @Override
                        public Object start() {
                            if(doc.getResourceType() == DocumentImpl.BINARY_FILE) {
                                final long page = ((BinaryDocument) doc).getPage();
                                if(page > Page.NO_PAGE) {
View Full Code Here

        notifyDropIndex(collection);
        indexController.removeCollection(collection, this, reindex);
        for(final Iterator<DocumentImpl> i = collection.iterator(this); i.hasNext(); ) {
            final DocumentImpl doc = i.next();
            LOG.debug("Dropping index for document " + doc.getFileURI());
            new DOMTransaction(this, domDb, Lock.WRITE_LOCK) {
                @Override
                public Object start() {
                    try {
                        final Value ref = new NodeRef(doc.getDocId());
                        final IndexQuery query =
View Full Code Here

            if(LOG.isDebugEnabled()) {
                LOG.debug("removeDocument() - removing dom");
            }
            try {
                if(!document.getMetadata().isReferenced()) {
                    new DOMTransaction(this, domDb, Lock.WRITE_LOCK) {
                        @Override
                        public Object start() {
                            final StoredNode node = (StoredNode) document.getFirstChild();
                            domDb.removeAll(transaction, node.getInternalAddress());
                            return null;
                        }
                    }.run();
                }
            } catch(NullPointerException npe0) {
                LOG.error("Caught NPE in DOMTransaction to actually be able to remove the document.");
            }

            final NodeRef ref = new NodeRef(document.getDocId());
            final IndexQuery idx = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);
            new DOMTransaction(this, domDb, Lock.WRITE_LOCK) {
                @Override
                public Object start() {
                    try {
                        domDb.remove(transaction, idx, null);
                    } catch(final BTreeException | IOException e) {
View Full Code Here

            // dropping old structure index
            dropIndex(transaction, doc);
            // dropping dom index
            final NodeRef ref = new NodeRef(doc.getDocId());
            final IndexQuery idx = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);
            new DOMTransaction(this, domDb, Lock.WRITE_LOCK) {
                @Override
                public Object start() {
                    try {
                        domDb.remove(transaction, idx, null);
                        domDb.flush();
                    } catch(final IOException | DBException e) {
                        LOG.warn("start() - " + "error while removing doc", e);
                    } catch(final TerminatedException e) {
                        LOG.warn("method terminated", e);
                    }
                    return null;
                }
            }.run();
            // create a copy of the old doc to copy the nodes into it
            final DocumentImpl tempDoc = new DocumentImpl(pool, doc.getCollection(), doc.getFileURI());
            tempDoc.copyOf(doc, true);
            tempDoc.setDocId(doc.getDocId());
            indexController.setDocument(doc, StreamListener.STORE);
            final StreamListener listener = indexController.getStreamListener();
            // copy the nodes
            final NodeList nodes = doc.getChildNodes();
            for(int i = 0; i < nodes.getLength(); i++) {
                final StoredNode node = (StoredNode) nodes.item(i);
                final Iterator<StoredNode> iterator = getNodeIterator(node);
                iterator.next();
                copyNodes(transaction, iterator, node, new NodePath(), tempDoc, true, true, listener);
            }
            flush();
            // remove the old nodes
            new DOMTransaction(this, domDb, Lock.WRITE_LOCK) {
                @Override
                public Object start() {
                    domDb.removeAll(transaction, firstChild);
                    try {
                        domDb.flush();
View Full Code Here

        final Object property = pool.getConfiguration().getProperty(PROPERTY_XUPDATE_CONSISTENCY_CHECKS);
        if(property != null) {
            xupdateConsistencyChecks = ((Boolean) property).booleanValue();
        }
        if(xupdateConsistencyChecks) {
            new DOMTransaction(this, domDb, Lock.READ_LOCK) {
                @Override
                public Object start() throws ReadOnlyException {
                    LOG.debug("Pages used: " + domDb.debugPages(doc, false));
                    return null;
                }
            }.run();
            final NodeList nodes = doc.getChildNodes();
            for(int i = 0; i < nodes.getLength(); i++) {
                final StoredNode node = (StoredNode) nodes.item(i);
                final Iterator<StoredNode> iterator = getNodeIterator(node);
                iterator.next();
                final StringBuilder buf = new StringBuilder();
                //Pass buf to the following method to get a dump of all node ids in the document
                if(!checkNodeTree(iterator, node, buf)) {
                    LOG.debug("node tree: " + buf.toString());
                    throw new RuntimeException("Error in document tree structure");
                }
            }
            final NodeRef ref = new NodeRef(doc.getDocId());
            final IndexQuery idx = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);
            new DOMTransaction(this, domDb, Lock.READ_LOCK) {
                @Override
                public Object start() {
                    try {
                        domDb.findKeys(idx);
                    } catch(final BTreeException | IOException e) {
View Full Code Here

    public void storeNode(final Txn transaction, final StoredNode node, final NodePath currentPath, final IndexSpec indexSpec, final boolean fullTextIndex) {
        checkAvailableMemory();
        final DocumentImpl doc = (DocumentImpl) node.getOwnerDocument();
        final short nodeType = node.getNodeType();
        final byte data[] = node.serialize();
        new DOMTransaction(this, domDb, Lock.WRITE_LOCK, doc) {
            @Override
            public Object start() throws ReadOnlyException {
                long address;
                if(nodeType == Node.TEXT_NODE
                    || nodeType == Node.ATTRIBUTE_NODE
View Full Code Here

    public void updateNode(final Txn transaction, final StoredNode node, final boolean reindex) {
        try {
            final DocumentImpl doc = (DocumentImpl) node.getOwnerDocument();
            final long internalAddress = node.getInternalAddress();
            final byte[] data = node.serialize();
            new DOMTransaction(this, domDb, Lock.WRITE_LOCK) {
                @Override
                public Object start() throws ReadOnlyException {
                    if(StorageAddress.hasAddress(internalAddress)) {
                        domDb.update(transaction, internalAddress, data);
                    } else {
View Full Code Here

TOP

Related Classes of org.exist.storage.dom.DOMTransaction

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.