}
resolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
String webappUrl = ServletHelper.getWebappURI(request);
LinkTarget target;
if (factory.isDocument(webappUrl)) {
Document currentDoc = factory.getFromURL(webappUrl);
target = resolver.resolve(currentDoc, linkUri);
}
else {
Link link = new Link(linkUri);
contextualize(link, webappUrl);
target = resolver.resolve(factory, link.getUri());
}
if (!target.exists()) {
throw new SourceNotFoundException("Source not found: [" + location + "]");
}
Document doc = target.getDocument();
if (target.isRevisionSpecified()) {
if (queryString == null) {
queryString = "";
}
queryString += "rev=" + target.getRevisionNumber();
}
String format = null;
if (queryString != null) {
Query query = new Query(queryString);