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; NodeImpl parent; DocumentImpl doc = null; Collection collection = null, prevCollection = null; int len = children.getLength(); LOG.debug("found " + len + " nodes to insert"); 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 remove document denied"); parent = (NodeImpl) node.getParentNode(); switch (mode) { case INSERT_BEFORE : parent.insertBefore(children, node); break; case INSERT_AFTER : ((NodeImpl) parent).insertAfter(children, node); break; } 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); NodeImpl node; NodeImpl parent; DocumentImpl doc = null; Collection collection = null, prevCollection = null; int len = children.getLength(); LOG.debug("found " + len + " nodes to insert"); 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 remove document denied"); parent = (NodeImpl) node.getParentNode(); switch (mode) { case INSERT_BEFORE: parent.insertBefore(children, node); break; case INSERT_AFTER: ((NodeImpl) parent).insertAfter(children, node); break; } 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;		NodeImpl parent;		DocumentImpl doc = null;		Collection collection = null, prevCollection = null;		int len = children.getLength();		LOG.debug("found " + len + " nodes to insert");		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 remove document denied");			parent = (NodeImpl) node.getParentNode();			switch (mode) {				case INSERT_BEFORE :					parent.insertBefore(children, node);					break;				case INSERT_AFTER :					 ((NodeImpl) parent).insertAfter(children, node);					break;			}			doc.clearIndexListener();			doc.setLastModified(System.currentTimeMillis());			prevCollection = collection;		}		if(doc != null)			doc.getBroker().saveCollection(collection);		return qr.length;	}