1
0
-1

Confluence の添付ファイルにはピンコメントを付けられるかと思いますが、
たくさん付けていくとわかりにくくなり
一覧で取得できる方法が知りたいと思っています。

何かいい方法はないでしょうか?

    Commentコメントを追加...

    1 回答

    1.  
      1
      0
      -1

      標準の機能ではなさそうなので...

      REST API を使用して
      以下のような URL にアクセスすれば添付ファイルのピンコメントを取得できるようでした。

      <confluence base url>/rest/api/content/<attachment file id>/child/comment?expand=body.view

      あとは以下のようなユーザーマクロでも取得できたように見受けられます。

      ## @param attachmentId:title=添付ファイルID|type=int|required=true
      ## @param HideResolvedComment:title=解決済みコメントを非表示にする|type=boolean
      
      #set ($intConv = 1)
      #set ($attachment = $attachmentManager.getAttachment($intConv.parseInt(${paramattachmentId})))
      
      ## 添付ファイルを取得できた場合
      #if ($!{attachment})
          #set ($contentEntityObject = $attachment.getEntity())
          #set ($comments = $contentEntityObject.getComments())
      
          ## コメントを取得できた場合
          #if ($!{comments})
          <table class="confluenceTable">
              <thead>
                  <tr>
                      <th class="confluenceTh">comment</th>
                      <th class="confluenceTh">status</th>
                  </tr>
              </thead>
              <tbody>
                  #foreach ($comment in $comments)
                      #set ($status = $comment.getStatus())
                      #set ($statusString = $status.getValue().getStringValue())
      
                      ## ステータスのカラーを取得
                      #set ($color = "Grey")
                      #if ($status.isOpen() || $status.isReopened())
                          #set ($color = "Blue")
                      #elseif ($status.isDangling())
                          #set ($color = "Grey")
                      #elseif ($status.isResolved())
                          #set ($color = "Green")
                      #end
      
                      ## $paramHideResolvedComment が true なら、解決済みコメントはスキップ
                      #if (!($paramHideResolvedComment.equals("true") && $color.equals("Green")))
                          <tr>
                              <td class="confluenceTd"><a href="$settingsManager.getGlobalSettings().getBaseUrl()$comment.getUrlPath()">$comment.getBodyContent().getBody()</a></td>
                              <td class="confluenceTd">
                                  <ac:structured-macro ac:name="status" ac:schema-version="1">
                                      <ac:parameter ac:name="colour">$color</ac:parameter>
                                      <ac:parameter ac:name="title">$statusString</ac:parameter>
                                  </ac:structured-macro>
                              </td>
                          </tr>
                      #end
      
                  #end
              </tbody>
          </table>
          #end
      ## 添付ファイルを取得できなかったらエラー表示
      #else
      <ac:structured-macro ac:name="warning" ac:schema-version="1">
          <ac:rich-text-body>
              <p>Cannot get attachment.</p>
          </ac:rich-text-body>
      </ac:structured-macro>
      #end
      
      
        Commentコメントを追加...