int idxLevel = doc.reindexRequired(); if (idxLevel == DocumentImpl.REINDEX_ALL) {
int idxLevel = doc.getMetadata().reindexRequired(); if (idxLevel == DocumentMetadata.REINDEX_ALL) {
	public void reindex(final Txn transaction, final DocumentImpl oldDoc, final DocumentImpl doc, 			final StoredNode node) {		int idxLevel = doc.reindexRequired();     		if (idxLevel == DocumentImpl.REINDEX_ALL) {			flush();			return;		}		oldDoc.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);					long gid;					for (Iterator i = nodes.iterator(); i.hasNext();) {						ref = (Value) i.next();						gid = ByteConversion.byteToLong(ref.data(), ref.start() + 4);						if (oldDoc.getTreeLevel(gid) >= doc.reindexRequired()) {							if (node != null) {								if (XMLUtil.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();				StoredNode n;				for (int i = 0; i < nodes.getLength(); i++) {					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.setReindexRequired(DocumentImpl.REINDEX_ALL);//		checkTree(doc);		LOG.debug("reindex took " + (System.currentTimeMillis() - start) + "ms.");	}