* @throws RepositoryException if an error occurs.
* @throws DocumentBuildException if an error occurs.
*/
public static Document getCurrentDocument(ServiceManager manager, Request request)
throws RepositoryException, DocumentBuildException {
Session session = RepositoryUtil.getSession(manager, request);
DocumentFactory factory = DocumentUtil.createDocumentFactory(manager, session);
String url = ServletHelper.getWebappURI(request);
Document doc = null;
if (factory.isDocument(url)) {
doc = factory.getFromURL(url);