String uri; try { uri = new URI(file.toURL().toString()).toASCIIString(); } catch (Exception e) { uri = file.getAbsolutePath(); } collection.addDocument(broker, docName, new InputSource(uri));
collection.store(broker, indexer, source, false);
	public boolean parseLocal(User user, String localFile, String docName,			boolean replace) throws EXistException, PermissionDeniedException, LockException,			SAXException, TriggerException {		File file = new File(localFile);		if (!file.canRead())			throw new EXistException("unable to read file " + localFile);		DBBroker broker = null;		DocumentImpl doc = null;		try {			broker = brokerPool.get(user);			int p = docName.lastIndexOf('/');			if (p < 0 || p == docName.length() - 1)				throw new EXistException("Illegal document path");			String collectionName = docName.substring(0, p);			docName = docName.substring(p + 1);			Collection collection = broker.getCollection(collectionName);			if (collection == null)				throw new EXistException("Collection " + collectionName						+ " not found");			if (!replace) {				DocumentImpl old = collection.getDocument(broker, docName);				if (old != null)					throw new PermissionDeniedException(							"Old document exists and overwrite is not allowed");			}			String uri;			try {				uri = new URI(file.toURL().toString()).toASCIIString();			} catch (Exception e) {				uri = file.getAbsolutePath();			}			collection.addDocument(broker, docName, new InputSource(uri));		} finally {			brokerPool.release(broker);		}		file.delete();		documentCache.clear();		return doc != null;	}