예제 #1
0
  @Override
  public String getHtml(IMacroContext macroContext) {
    htmlSerializerContext = macroContext.getHtmlSerializerContext();
    pageStore = macroContext.getPageStore();
    permissionEvaluator = macroContext.getPermissionEvaluator();

    path = htmlSerializerContext.getPagePath();
    if (path != null) {
      projectName = htmlSerializerContext.getProjectName();
      branchName = htmlSerializerContext.getBranchName();

      if (log.isInfoEnabled()) {
        log.info(
            "rendering neighbors for page: {}/{}/{}, user: {}", //$NON-NLS-1$
            projectName,
            branchName,
            Util.toUrlPagePath(path),
            htmlSerializerContext.getAuthentication().getName());
      }

      try {
        StringBuilder buf = new StringBuilder();
        buf.append(
                "<ul class=\"well well-small nav nav-list neighbors pull-right\">") //$NON-NLS-1$
            .append(printParent(printLinkListItem(path), path))
            .append("</ul>"); // $NON-NLS-1$
        return buf.toString();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    } else {
      return null;
    }
  }
예제 #2
0
 private boolean hasViewPermission(String path) {
   Authentication authentication = htmlSerializerContext.getAuthentication();
   return permissionEvaluator.hasPagePermission(
       authentication, projectName, branchName, path, Permission.VIEW);
 }