Exemplo n.º 1
0
  @Override
  public PageData getRevisionData(FileSystemPage page, String label) {
    // Workaround for CachingPage
    if (label == null) {
      return persistence.getRevisionData(page, null);
    }
    String content, propertiesXml;
    RevCommit revCommit;
    Repository repository = getRepository(page);

    try {
      String fileSystemPath = getPath(page, repository);
      ObjectId rev = repository.resolve(label);
      RevWalk walk = new RevWalk(repository);
      revCommit = walk.parseCommit(rev);

      content = getRepositoryContent(repository, revCommit, fileSystemPath + "/" + contentFilename);
      propertiesXml =
          getRepositoryContent(repository, revCommit, fileSystemPath + "/" + propertiesFilename);
    } catch (IOException e) {
      throw new RuntimeException("Unable to get data for revision " + label, e);
    }

    final PageData pageData = new PageData(page);
    pageData.setContent(content);
    pageData.setProperties(
        parsePropertiesXml(propertiesXml, revCommit.getAuthorIdent().getWhen().getTime()));
    return pageData;
  }
Exemplo n.º 2
0
 @Override
 public WikiPage toWikiPage(WikiPage root) {
   FileSystemPage fsPage = (FileSystemPage) root;
   WikiPage recentChangesPage = InMemoryPage.createChildPage(RECENT_CHANGES, fsPage);
   PageData pageData = recentChangesPage.getData();
   try {
     pageData.setContent(
         convertToWikiText(
             history(
                 fsPage,
                 new LogCommandSpec() {
                   @Override
                   public LogCommand specify(LogCommand log, String fileSystemPath) {
                     return log.setMaxCount(RECENT_CHANGES_DEPTH);
                   }
                 })));
   } catch (GitAPIException e) {
     pageData.setContent("Unable to read history: " + e.getMessage());
   }
   // No properties, no features.
   pageData.setProperties(new WikiPageProperties());
   recentChangesPage.commit(pageData);
   return recentChangesPage;
 }