public void reindexXMLResource(final Txn transaction, final DocumentImpl oldDoc, final DocumentImpl doc, final StoredNode node) { int idxLevel = doc.getMetadata().reindexRequired(); if (idxLevel == DocumentMetadata.REINDEX_ALL) { flush(); return;
private void reindexXMLResource(Txn transaction, DocumentImpl doc, boolean repairMode) { if(CollectionConfiguration.DEFAULT_COLLECTION_CONFIG_FILE.equals(doc.getFileName())) doc.getCollection().setConfigEnabled(false); Iterator iterator; NodeList nodes = doc.getChildNodes(); StoredNode n; for (int i = 0; i < nodes.getLength(); i++) { n = (StoredNode) nodes.item(i); iterator = getNodeIterator(new NodeProxy(doc, n.getNodeId(), n.getInternalAddress())); iterator.next(); scanNodes(transaction, iterator, n, new NodePath(), true, repairMode);
    public void reindexXMLResource(final Txn transaction, final DocumentImpl oldDoc, final DocumentImpl doc,             final StoredNode node) {        int idxLevel = doc.getMetadata().reindexRequired();             if (idxLevel == DocumentMetadata.REINDEX_ALL) {            flush();            return;        }        oldDoc.getMetadata().setReindexRequired(idxLevel);        if (node == null)            LOG.debug("reindexing level " + idxLevel + " of document " + doc.getDocId());//      checkTree(doc);                final long start = System.currentTimeMillis();        // remove all old index keys from the btree         new DOMTransaction(this, domDb, Lock.WRITE_LOCK) {            public Object start() throws ReadOnlyException {                try {                    Value ref = new NodeRef(doc.getDocId());                    IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);                    final ArrayList nodes = domDb.findKeys(query);                                      for (Iterator i = nodes.iterator(); i.hasNext();) {                        ref = (Value) i.next();                        long gid = ByteConversion.byteToLong(ref.data(), ref.start() + 4);                        if (oldDoc.getTreeLevel(gid) >= doc.getMetadata().reindexRequired()) {                            if (node != null) {                                if (NodeSetHelper.isDescendant(oldDoc, node.getGID(), gid)) {                                    domDb.removeValue(transaction, ref);                                }                            } else                                domDb.removeValue(transaction, ref);                        }                    }                } catch (BTreeException e) {                    LOG.debug("Exception while reindexing document: " + e.getMessage(), e);                } catch (IOException e) {                    LOG.debug("Exception while reindexing document: " + e.getMessage(), e);                }                return null;            }        }.run();        try {            // now reindex the nodes            Iterator iterator;            if (node == null) {                NodeList nodes = doc.getChildNodes();                                for (int i = 0; i < nodes.getLength(); i++) {                    StoredNode n = (StoredNode) nodes.item(i);                    iterator =  getNodeIterator(new NodeProxy(doc, n.getGID(), n.getInternalAddress()));                    iterator.next();                    scanNodes(transaction, iterator, n, new NodePath(), false, false);                }            } else {                iterator = getNodeIterator(new NodeProxy(doc, node.getGID(), node.getInternalAddress()));                iterator.next();                scanNodes(transaction, iterator, node, node.getPath(), false, false);            }        } catch(Exception e) {            LOG.error("Error occured while reindexing document: " + e.getMessage(), e);        }        notifyReindex(oldDoc, node);        doc.getMetadata().setReindexRequired(DocumentMetadata.REINDEX_ALL);//      checkTree(doc);        LOG.debug("reindex took " + (System.currentTimeMillis() - start) + "ms.");    }