1

ウェブスクリプトを使用して、Alfresco で出力形式を HTML ではなく CSV に変更するにはどうすればよいですか?

以下は、対応するFTLおよびWebscriptファイルです


recursive.get.html.ftl

<#macro recurse_macro node depth>
  <#if node.isContainer>
    <tr>
    <td> 
        ${node.properties.name}
    </td>
<td></td>
  </tr>

   <#list node.children as child>
    <#if child.isContainer>

         <@recurse_macro node=child depth=depth+1/>

 <#list child.children as child2>
    <#if child2.isDocument>
     <tr><td></td><td>${child2.properties.name}</td></tr>
       </#if>
 </#list>

    </#if>
   </#list>
  </#if>
</#macro>

スペースとドキュメントの再帰的リスト:

スペースドキュメント

recursive.get.desc.xml

<webscript>
  <shortname>recurcive</shortname>
  <description>Recursive</description>
  <url>/sample/recursive/{recursive}</url>
  <format default="html">extension</format>
  <authentication>guest</authentication>
  </webscript>

そしてhtml出力は

Recursive Listing of Spaces & Documents:
Space   Document
Company Home    
Data Dictionary     
Space Templates     
Software Engineering Project    
Documentation   
Drafts  
Pending Approval    
Published   
Samples     
    system-overview.html
Discussions     
UI Design   
Presentations   
Quality Assurance   
Presentation Templates  
    doc_info.ftl
    localizable.ftl
    my_docs.ftl
    my_spaces.ftl
    my_summary.ftl
    translatable.ftl
    recent_docs.ftl
    general_example.ftl
    my_docs_inline.ftl
    show_audit.ftl
    readme.ftl
Email Templates     
    notify_user_email.ftl
    invite_user_email.ftl
RSS Templates   
    RSS_2.0_recent_docs.ftl
Saved Searches  
admin   
Scripts     
    backup.js
    example test script.js
    backup and log.js
    append copyright.js
    alfresco docs.js
    test return value.js
Web Scripts     
org     
alfresco    
sample  
    blogsearch.get.js
    blogsearch.get.atom.ftl
    blogsearch.get.desc.xml
    blogsearch.get.html.ftl
    blogsearch.get.html.400.ftl
    blogsearch.get.atom.400.ftl
    categorysearch.get.js
    categorysearch.get.atom.ftl
    categorysearch.get.desc.xml
    categorysearch.get.html.ftl
    categorysearch.get.html.404.ftl
    categorysearch.get.atom.404.ftl
    folder.get.js
    folder.get.atom.ftl
    folder.get.desc.xml
    folder.get.html.ftl
    avmstores.get.desc.xml
    avmstores.get.html.ftl
    avmbrowse.get.js
    avmbrowse.get.desc.xml
    avmbrowse.get.html.ftl
    recursive.get.desc.xml
    recursive.get.html.ftl
    sgs.get.desc.xml
    sgs.get.csv.ftl
    sample1.get.desc.xml
    sample1.get.csv.ftl
    first.get.desc.xml
    first.get.text.ftl
    rag.get.html.ftl
    rag.get.desc.xml
    new1.get.desc.xml
    new1.get.html.ftl
    excel.get.html.ftl
    excel.get.desc.xml
    sgs1.get.desc.xml
    one.get.html.ftl
    one.get.desc.xml
    one.get.js
    readme.html
Web Scripts Extensions  
    readme.html
Guest Home  
    Alfresco-Tutorial.pdf
User Homes  
isabel  
Users Home  
4

2 に答える 2

1

はい、csv出力可能です。http://wiki.alfresco.com/wiki/Web_Scripts#Implementationを参照してください。

dess ファイルを次のように変更する必要があります。

 <webscript>
  <shortname>recurcive</shortname>
  <description>Recursive</description>
  <url>/sample/recursive/{recursive}</url>
  <format default="csv">extension</format>
  <authentication>guest</authentication>
 </webscript>

または、html をデフォルトのフォーマットとして維持したい場合は、csv 拡張子 (alfresco/service/recursive/blabla.csv) またはフォーマット パラメータ ?format=csv を使用してスクリプトを呼び出すだけです。

次に、recursive.get を作成しました。csv .ftl ファイルは次のようになります。

    <#macro recurse_macro node depth>
      <#if node.isContainer>       
            ${node.properties.name}
       <#list node.children as child>         
         <#if child.isContainer>
         ,         
         <@recurse_macro node=child depth=depth+1/>        
          <#list child.children as child2> 
            <#if child2.isDocument>
                ${child2.properties.name}
               <#if child2_has_next>,</#if>
            </#if>
          </#list>            
         </#if>
            \n        
       </#list>
      </#if>
    </#macro>

私はコードをテストしていませんが、各メイン ノードの最後で行を分割する必要があり、各子ノードの後に​​ (最後のノードを除く) コマが必要であるという考えを理解していることを前提としています。

于 2010-08-18T18:21:40.110 に答える
0

デフォルトの出力がcsvになるように指定できます。これをwebscript記述ファイル(.desc.xml)拡張子に入れます

次に、csv出力を作成するrecursive.get.xml.ftlを追加します。

于 2010-06-17T11:41:59.157 に答える