String uri; try { uri = new URI(file.toURL().toString()).toASCIIString(); } catch (Exception e) { uri = file.getAbsolutePath(); } source = new InputSource(uri);
source = new InputSource(file.toURI().toASCIIString());
	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 = null;			IndexInfo info;			InputSource source;			try {				collection = broker.openCollection(collectionName, Lock.WRITE_LOCK);				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();				}				source = new InputSource(uri);				info = collection.validate(broker, docName, source);			} finally {				if(collection != null)					collection.release();			}			collection.store(broker, info, source, false);		} finally {			brokerPool.release(broker);		}		file.delete();		documentCache.clear();		return doc != null;	}