if ( document.uri() != null ) {
String stringUri = document.uri().toString();
// TODO: this is a quick patch to get the file server running with relative files
final String documentUri = URLEncoder.encode( derelativise
? new File( stringUri.startsWith( "file:" ) ? stringUri.substring( 5 ) : stringUri ).getAbsoluteFile().toURI().toASCIIString()
: document.uri().toString(), "UTF-8" );
resultItem.uri = StringEscapeUtils.escapeHtml( "./Item?doc=" + resultItem.doc + "&m=" + urlEncodedMimeType + "&uri=" + documentUri );
}
else resultItem.uri = StringEscapeUtils.escapeHtml( "./Item?doc=" + resultItem.doc + "&m=" + urlEncodedMimeType );
}