if (!collection.getPermissions().validate(user, Permission.UPDATE)) throw new PermissionDeniedException( "write access to collection denied; user=" + user.getName());
	public long process() throws PermissionDeniedException, EXistException {		ArrayList qr = select(docs);		NodeList children = content.getChildNodes();		if (qr == null || children.getLength() == 0)			return 0;		IndexListener listener = new IndexListener(qr);		NodeImpl node;		Node temp;		TextImpl text;		AttrImpl attribute;		ElementImpl parent;		DocumentImpl doc = null;		Collection collection = null;		for (Iterator i = qr.iterator(); i.hasNext();) {			node = (NodeImpl) i.next();			doc = (DocumentImpl) node.getOwnerDocument();			doc.setIndexListener(listener);			collection = doc.getCollection();			if (!collection.getPermissions().validate(user, Permission.UPDATE))				throw new PermissionDeniedException(					"write access to collection denied; user=" + user.getName());			if (!doc.getPermissions().validate(user, Permission.UPDATE))				throw new PermissionDeniedException("permission denied to update document");			switch (node.getNodeType()) {				case Node.ELEMENT_NODE :					((ElementImpl) node).update(children);					break;				case Node.TEXT_NODE :					parent = (ElementImpl)node.getParentNode();					temp = children.item(0);					text = new TextImpl(temp.getNodeValue());					text.setOwnerDocument(doc);					parent.updateChild(node, text);					break;				case Node.ATTRIBUTE_NODE :					parent = (ElementImpl)node.getParentNode();					temp = children.item(0);					attribute = 						new AttrImpl(((AttrImpl)node).getName(), temp.getNodeValue());					attribute.setOwnerDocument(doc);					parent.updateChild(node, attribute);					break;				default :					throw new EXistException("unsupported node-type");			}		}		return children.getLength();	}