2
1
0

Confluenceでは、同名のファイル名を添付すると履歴として残ります。

履歴として残したくないのですが、画面から一々削除するのも大変です。

何かいい方法はありませんか?

    Commentコメントを追加...

    1 回答

    1.  
      2
      1
      0

      やる方法として…

      アドオンを検証する。

       

      あとは、添付ファイルの履歴を消せるSOAP API、REST APIがないので…

       

      添付ファイルの履歴を消せるREST APIを追加してほしいという製品要望は以下にあります…

      • CONF-36015 REST API Needs ability to remove specific versions of an attachment

       

      消したいページの添付ファイル一覧を表示してる画面でChromeとかの開発ツールのコンソールにて、以下JavaScriptを実行する。

      添付ファイルが多くてページングされている場合は1ページごとの削除になりますけどね...

      AJS.$('div#view-attachments tr[id^=attachment]').each(function() {
      	var attachmentId = AJS.$(this).attr('id').replace(/^attachment-/, '');
      	if (AJS.$('div#view-attachments tr[class^=history-' + attachmentId + ']').size() > 1) {
      		var current = true;
      		AJS.$('div#view-attachments tr[class^=history-' + attachmentId + ']').each(function() {
      			if (current) {
      				current = false;
      				return;
      			}
      			var filename  = AJS.$(this).attr('data-attachment-filename');
      			var version   = parseInt(AJS.$(this).attr('data-attachment-version'), 10);
      			var pageid    = parseInt(AJS.$('meta[name=ajs-page-id]').attr('content'), 10);
      			var atl_token = AJS.$('meta[name=atlassian-token]').attr('content');
      		    AJS.$.ajax({
      		        url: contextPath + "/json/removeattachmentversion.action?pageId=" + encodeURIComponent(pageid) + '&fileName=' + encodeURIComponent(filename) + '&version=' + encodeURIComponent(version),
      		        type: "POST",
      		        data: {atl_token : atl_token},
      		        dataType: "json",
      		        success: function(msg){
      		        }
      		    });
      		});
      	}
      });

       

      あとは以下のようなユーザーマクロですかね…

      ## @param page:title=ページ名|type=confluence-content|required=true|desc=ページ名を指定してください。
       
      #set($containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager'))
      #set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
      #set($containerManager = $getInstanceMethod.invoke(null,null))
      #set($containerContext = $containerManager.containerContext)
      #set($pageManager=$containerContext.getComponent('pageManager'))
      #set($attachmentManager=$containerContext.getComponent('attachmentManager'))
      #set ($ss='')
      #set ($sp='')
      #foreach ($p in $parampage.split(":"))
         #if ($ss=='')
          #set ($ss=$p)
         #else
          #set ($sp=$p)
         #end
      #end
      #if ($sp=='')
        #set ($sp=$ss)
        #set ($ss=$space.key)
      #end
      #set($page=$pageManager.getPage($ss ,$sp))
      #foreach($attachment in $page.getAttachments())
      #foreach($attachmentVersion in $attachmentManager.getAllVersions($attachment))
      #if($attachmentVersion.isLatestVersion()) 
      #else
      #$attachmentManager.removeAttachmentVersionFromServer($attachmentVersion)
      #end
      #end

      ユーザーマクロ応用すればスペースにある添付ファイル履歴消せますけど…かなり重い気もします。

      参考になりましたら幸いです。

      参考QA

      Confluenceのページに添付されているファイルを一括で削除したい 

       

        Commentコメントを追加...