public long process() throws PermissionDeniedException, EXistException, XPathException { NodeImpl[] qr = select(docs); NodeList children = content.getChildNodes(); if (qr == null || children.getLength() == 0) return 0;  IndexListener listener = new IndexListener(qr); NodeImpl node; DocumentImpl doc = null; Collection collection = null, prevCollection = null; for(int i = 0; i < qr.length; i++) { node = qr[i]; doc = (DocumentImpl) node.getOwnerDocument(); doc.setIndexListener(listener); collection = doc.getCollection(); if (prevCollection != null && collection != prevCollection) doc.getBroker().saveCollection(prevCollection); if (!doc.getPermissions().validate(broker.getUser(), Permission.UPDATE)) throw new PermissionDeniedException("permission to update document denied"); node.appendChildren(children, child); doc.clearIndexListener(); doc.setLastModified(System.currentTimeMillis()); prevCollection = collection; } if (doc != null) doc.getBroker().saveCollection(collection); return qr.length;
public long process() throws PermissionDeniedException, LockException, EXistException, XPathException { NodeList children = content.getChildNodes(); if(children.getLength() == 0) return 0;  try { NodeImpl ql[] = selectAndLock(); IndexListener listener = new IndexListener(ql); Collection collection = null, prevCollection = null; DocumentImpl doc = null, prevDoc = null; NodeImpl node; for(int i = 0; i < ql.length; i++) { node = ql[i]; doc = (DocumentImpl) node.getOwnerDocument(); doc.setIndexListener(listener); collection = doc.getCollection(); if (prevCollection != null && collection != prevCollection) doc.getBroker().saveCollection(prevCollection); if (!doc.getPermissions().validate(broker.getUser(), Permission.UPDATE)) throw new PermissionDeniedException("permission to update document denied"); node.appendChildren(children, child); doc.clearIndexListener(); doc.setLastModified(System.currentTimeMillis()); prevCollection = collection; } if (doc != null) doc.getBroker().saveCollection(collection); return ql.length; } finally {  unlockDocuments(); }
	public long process() throws PermissionDeniedException, EXistException, XPathException {		NodeImpl[] qr = select(docs);		NodeList children = content.getChildNodes();		if (qr == null || children.getLength() == 0)			return 0;		IndexListener listener = new IndexListener(qr);		NodeImpl node;		DocumentImpl doc = null;		Collection collection = null, prevCollection = null;		for(int i = 0; i < qr.length; i++) {			node = qr[i];			doc = (DocumentImpl) node.getOwnerDocument();			doc.setIndexListener(listener);			collection = doc.getCollection();			if (prevCollection != null && collection != prevCollection)				doc.getBroker().saveCollection(prevCollection);			if (!doc.getPermissions().validate(broker.getUser(), Permission.UPDATE))				throw new PermissionDeniedException("permission to update document denied");			node.appendChildren(children, child);			doc.clearIndexListener();			doc.setLastModified(System.currentTimeMillis());			prevCollection = collection;		}		if (doc != null)			doc.getBroker().saveCollection(collection);		return qr.length;	}