public long process() throws PermissionDeniedException, EXistException, XPathException { NodeImpl qr[] = select(docs); NodeList children = content.getChildNodes(); if (qr == null || children.getLength() == 0) return 0; DocumentImpl doc = null; Collection collection = null, prevCollection = null; NodeImpl node; NodeImpl parent; IndexListener listener = new IndexListener(qr); String newName = children.item(0).getNodeValue(); int modificationCount = 0; for (int i = 0; i < qr.length; i++) { node = qr[i]; doc = (DocumentImpl) node.getOwnerDocument(); collection = doc.getCollection(); if (prevCollection != null && collection != prevCollection) doc.getBroker().saveCollection(prevCollection); if (!collection.getPermissions().validate(broker.getUser(), Permission.UPDATE)) throw new PermissionDeniedException( "write access to collection denied; user=" + broker.getUser().getName()); if (!doc.getPermissions().validate(broker.getUser(), Permission.UPDATE)) throw new PermissionDeniedException("permission denied to update document"); doc.setIndexListener(listener); parent = (NodeImpl)node.getParentNode(); switch(node.getNodeType()) { case Node.ELEMENT_NODE : ((ElementImpl)node).setNodeName(new QName(newName, "", null)); parent.updateChild(node, node); modificationCount++; break; case Node.ATTRIBUTE_NODE : ((AttrImpl)node).setNodeName(new QName(newName, "", null)); parent.updateChild(node, node); modificationCount++; break; default : throw new EXistException("unsupported node-type"); } prevCollection = collection; doc.clearIndexListener(); doc.setLastModified(System.currentTimeMillis()); } if (doc != null) doc.getBroker().saveCollection(collection); return modificationCount; }
public long process() throws PermissionDeniedException, LockException, EXistException, XPathException { NodeList children = content.getChildNodes(); if (children.getLength() == 0) return 0; int modificationCount = 0; try { NodeImpl[] ql = selectAndLock(); DocumentImpl doc = null; Collection collection = null, prevCollection = null; NodeImpl node; NodeImpl parent; IndexListener listener = new IndexListener(ql); String newName = children.item(0).getNodeValue(); for (int i = 0; i < ql.length; i++) { node = ql[i]; doc = (DocumentImpl) node.getOwnerDocument(); collection = doc.getCollection(); if (prevCollection != null && collection != prevCollection) doc.getBroker().saveCollection(prevCollection); if (!collection.getPermissions().validate(broker.getUser(), Permission.UPDATE)) throw new PermissionDeniedException( "write access to collection denied; user=" + broker.getUser().getName()); if (!doc.getPermissions().validate(broker.getUser(), Permission.UPDATE)) throw new PermissionDeniedException( "permission denied to update document"); doc.setIndexListener(listener); parent = (NodeImpl) node.getParentNode(); switch (node.getNodeType()) { case Node.ELEMENT_NODE: ((ElementImpl) node).setNodeName(new QName(newName, "", null)); parent.updateChild(node, node); modificationCount++; break; case Node.ATTRIBUTE_NODE: ((AttrImpl) node).setNodeName(new QName(newName, "", null)); parent.updateChild(node, node); modificationCount++; break; default: throw new EXistException("unsupported node-type"); }  doc.clearIndexListener(); doc.setLastModified(System.currentTimeMillis()); prevCollection = collection; } if (doc != null) doc.getBroker().saveCollection(collection); } finally { unlockDocuments(); } return modificationCount; }
	public long process() throws PermissionDeniedException, EXistException, XPathException {		NodeImpl qr[] = select(docs);		NodeList children = content.getChildNodes();		if (qr == null || children.getLength() == 0)			return 0;		DocumentImpl doc = null;		Collection collection = null, prevCollection = null;		NodeImpl node;		NodeImpl parent;		IndexListener listener = new IndexListener(qr);		String newName = children.item(0).getNodeValue();		int modificationCount = 0;		for (int i = 0; i < qr.length; i++) {			node = qr[i];			doc = (DocumentImpl) node.getOwnerDocument();			collection = doc.getCollection();			if (prevCollection != null && collection != prevCollection)				doc.getBroker().saveCollection(prevCollection);			if (!collection.getPermissions().validate(broker.getUser(), Permission.UPDATE))				throw new PermissionDeniedException(					"write access to collection denied; user=" + broker.getUser().getName());			if (!doc.getPermissions().validate(broker.getUser(), Permission.UPDATE))				throw new PermissionDeniedException("permission denied to update document");			doc.setIndexListener(listener);			parent = (NodeImpl)node.getParentNode();			switch(node.getNodeType()) {				case Node.ELEMENT_NODE :					((ElementImpl)node).setNodeName(new QName(newName, "", null));					parent.updateChild(node, node);					modificationCount++;					break;				case Node.ATTRIBUTE_NODE :					((AttrImpl)node).setNodeName(new QName(newName, "", null));					parent.updateChild(node, node);					modificationCount++;					break;				default :					throw new EXistException("unsupported node-type");			}			prevCollection = collection;			doc.clearIndexListener();			doc.setLastModified(System.currentTimeMillis());		}		if (doc != null)			doc.getBroker().saveCollection(collection);		return modificationCount;	}