for (Iterator i = collection.iterator(); i.hasNext(); j++) {
for (Iterator i = collection.iterator(broker); i.hasNext(); j++) {
	public Collection listCollection(String sessionId, String path) throws RemoteException {		Session session = getSession(sessionId);		DBBroker broker = null;		try {			broker = pool.get(session.getUser());			if (path == null)				path = "/db";			org.exist.collections.Collection collection = broker.getCollection(path);			if (collection == null)				throw new RemoteException("collection " + path + " not found");			if (!collection.getPermissions().validate(session.getUser(), Permission.READ))				throw new RemoteException("permission denied");			Collection c = new Collection();			// Sub-collections			String childCollections[] = new String[collection.getChildCollectionCount()];			int j = 0;			for (Iterator i = collection.collectionIterator(); i.hasNext(); j++)				childCollections[j] = (String) i.next();			// Resources			String[] resources = new String[collection.getDocumentCount()];			j = 0;			int p;			String resource;			for (Iterator i = collection.iterator(); i.hasNext(); j++) {				resource = ((DocumentImpl) i.next()).getFileName();				p = resource.lastIndexOf('/');				resources[j] = p < 0 ? resource : resource.substring(p + 1);			}			c.setResources(resources);			c.setCollections(childCollections);			return c;		} catch (EXistException e) {			throw new RemoteException(e.getMessage());		} finally {			pool.release(broker);		}	}