private PageData getDataVersion() throws IOException { FileVersion[] versions = versionsController.getRevisionData(versionName, path); FileVersion fileVersion = versions[0]; String content = ""; WikiPageProperty properties = defaultPageProperties(); if (fileVersion != null) { try { String fileContent = loadContent(fileVersion); final ParsingPage parsingPage = makeParsingPage(this); final Symbol syntaxTree = Parser.make(parsingPage, fileContent, WIKI_FILE_PARSING_PROVIDER).parse(); if (!syntaxTree.getChildren().isEmpty()) { final Symbol maybeFrontMatter = syntaxTree.getChildren().get(0); if (maybeFrontMatter.isType(FrontMatter.symbolType)) { properties = mergeWikiPageProperties(properties, maybeFrontMatter); if (syntaxTree.getChildren().size() > 1) { content = fileContent.substring(maybeFrontMatter.getEndOffset()); } } else { content = fileContent; } } properties.setLastModificationTime(fileVersion.getLastModificationTime()); } catch (IOException e) { throw new WikiPageLoadException(e); } } pageData = new PageData(content, properties); return pageData; }
private PageData getDataVersion() throws IOException { FileVersion[] versions = versionsController.getRevisionData(versionName, path); FileVersion fileVersion = versions[0]; String content = ""; WikiPageProperty properties = defaultPageProperties(); if (fileVersion != null) { try { String fileContent = loadContent(fileVersion); final ParsingPage parsingPage = makeParsingPage(this); final Symbol syntaxTree = Parser.make(parsingPage, fileContent, WIKI_FILE_PARSING_PROVIDER).parse(); if (!syntaxTree.getChildren().isEmpty()) { final Symbol maybeFrontMatter = syntaxTree.getChildren().get(0); if (maybeFrontMatter.isType(FrontMatter.symbolType)) { properties = mergeWikiPageProperties(properties, maybeFrontMatter); if (syntaxTree.getChildren().size() > 1) { content = fileContent.substring(maybeFrontMatter.getEndOffset()); } } else { content = fileContent; } } properties.setLastModificationTime(fileVersion.getLastModificationTime()); } catch (IOException e) { throw new WikiPageLoadException(e); } } pageData = new PageData(content, properties); return pageData; }