コード例 #1
0
ファイル: CommentIndexManager.java プロジェクト: tiennv90/SVN
 public static String getCommentRelativePath(final String path) {
   int relPathStart =
       path.indexOf(JcrConstants.JCR_CONTENT) + JcrConstants.JCR_CONTENT.length() + 2;
   relPathStart = path.indexOf('/', relPathStart) + 1;
   final String relPath = path.substring(relPathStart);
   return relPath;
 }
コード例 #2
0
ファイル: CommentIndexManager.java プロジェクト: tiennv90/SVN
  /** {@inheritDoc} */
  public static String getParentRelPath(final Resource resource) {

    Resource parent = resource.getParent();

    while (parent != null) {

      try {
        final Property primaryType =
            parent.adaptTo(Node.class).getProperty(JcrConstants.JCR_PRIMARYTYPE);

        if (primaryType.getString().equals(JcrConstants.NT_UNSTRUCTURED)) {
          // We reached the beginning of the comment tree so this must be
          // a comment.
          return null;
        } else if (primaryType.getString().equals(Comment.NODE_TYPE)) {
          // Found parent. Now return its relative path.
          final String nodePath = parent.getPath();
          int relPathStart =
              nodePath.indexOf(JcrConstants.JCR_CONTENT) + JcrConstants.JCR_CONTENT.length() + 2;
          relPathStart = nodePath.indexOf('/', relPathStart) + 1;
          final String relPath = nodePath.substring(relPathStart);
          return relPath;
        }
      } catch (final RepositoryException e) {
        log.error("Error computing parentRelPath for " + resource.getPath(), e);
        return null;
      }
      parent = parent.getParent();
    }

    return null;
  }