使用Alfresco获取工作流的文件名

Get filename of workflow with Alfresco

本文关键字:文件名 工作流 获取 Alfresco 使用      更新时间:2023-09-26

我正在尝试获取工作流项目的文件名。

我尝试这样做:

var title;
     Alfresco.util.Ajax.jsonGet(
         {
            url: Alfresco.constants.PROXY_URI_RELATIVE + "api/metadata?nodeRef=" + nodeRefContext + "&shortQNames=true" ,
            successCallback:
            {
               fn: function(response)
               {
                  if (response.json)
                  {
                     title=response.json.properties["cm:title"];
                     alert(title);
                  }
               },
               scope: this
           },
       failureCallback:
           {
               fn: function(response)
               {
                  Alfresco.util.PopupManager.displayPrompt(
                  {
                     failureMessage: this.msg("message.failure")
                  });
               },
               scope: this
            }
         });

但是在警报中给了我未定义...

我也尝试:

var nodeR = search.findNode(fileNodeRef);
alert(nodeR);

未定义搜索

知道如何获取工作流的文件名吗?在URL中,我只有noderef。

你有cm:title,但是对于文件的名称,你必须访问cm:name。

输出:

{
   "nodeRef":"workspace://SpacesStore/3444dc43-4526-4790-a63d-3827f55f53de",
   "aspects":[
      "{http://www.alfresco.org/model/rendition/1.0}renditioned",
      "{http://www.alfresco.org/model/content/1.0}versionable",
      "{http://www.alfresco.org/model/content/1.0}titled",
      "{http://www.alfresco.org/model/content/1.0}auditable",
      "{http://www.alfresco.org/model/system/1.0}referenceable",
      "{http://www.alfresco.org/model/system/1.0}localized",
      "{http://www.alfresco.org/model/content/1.0}author",
      "{http://www.alfresco.org/model/content/1.0}thumbnailModification"
   ],
   "mimetype":"application/pdf",
   "type":"{http://www.alfresco.org/model/content/1.0}content",
   "properties":{
      "{http://www.alfresco.org/model/content/1.0}autoVersionOnUpdateProps":false,
      "{http://www.alfresco.org/model/content/1.0}created":"2016-02-01T11:25:43.926Z",
      "{http://www.alfresco.org/model/content/1.0}lastThumbnailModification":[
         "doclib:1454326175307"
      ],
      "{http://www.alfresco.org/model/content/1.0}creator":"admin",
      "{http://www.alfresco.org/model/system/1.0}node-uuid":"0a790a38-2ccd-4a69-ae2f-282ebd743c26",
      "{http://www.alfresco.org/model/content/1.0}name":"examplepdf1.pdf",
      "{http://www.alfresco.org/model/system/1.0}store-protocol":"workspace",
      "{http://www.alfresco.org/model/content/1.0}content":"contentUrl=store://2016/2/1/11/29/c58f779f-f071-4d23-92d2-f38cd9f51578.bin|mimetype=application/pdf|size=94301|encoding=UTF-8|locale=en_US_|id=510",
      "{http://www.alfresco.org/model/system/1.0}store-identifier":"SpacesStore",
      "{http://www.alfresco.org/model/system/1.0}node-dbid":1231,
      "{http://www.alfresco.org/model/system/1.0}locale":"en_US",
      "{http://www.alfresco.org/model/content/1.0}versionLabel":"1.1",
      "{http://www.alfresco.org/model/content/1.0}modifier":"admin",
      "{http://www.alfresco.org/model/content/1.0}modified":"2016-02-01T11:29:34.763Z",
      "{http://www.alfresco.org/model/content/1.0}autoVersion":true,
      "{http://www.alfresco.org/model/content/1.0}initialVersion":true
   }
}

您可以看到"examplepdf1.pdf"是文件的名称,属性是名称而不是标题。

所以,取而代之的是:

title=response.json.properties["cm:title"];

把这个:

title=response.json.properties["cm:name"];

通过检查该特定网络脚本的输出

GET http://127.0.0.1:8080/alfresco/s/api/metadata?nodeRef=workspace://SpacesStore/5ad08b31-482f-41b1-8949-8021dd455507

,我发现它的格式是这样的:

{
   "mimetype":"application/octet-stream",
   "aspects":[
      "{http://www.alfresco.org/model/content/1.0}auditable",
      "{http://www.alfresco.org/model/system/1.0}referenceable",
      "{http://www.alfresco.org/model/content/1.0}titled",
      "{http://www.alfresco.org/model/content/1.0}taggable",
      "{http://www.alfresco.org/model/system/1.0}localized",
      "{http://www.alfresco.org/model/content/1.0}generalclassifiable"
   ],
   "nodeRef":"workspace://SpacesStore/5ad08b31-482f-41b1-8949-8021dd455507",
   "properties":{
      "{http://www.alfresco.org/model/content/1.0}name":"aa",
      "{http://www.alfresco.org/model/system/1.0}node-dbid":769,
      "{http://www.alfresco.org/model/system/1.0}store-identifier":"SpacesStore",
      "{http://www.alfresco.org/model/system/1.0}locale":"fr",
      "{http://www.alfresco.org/model/content/1.0}title":"",
      "{http://www.alfresco.org/model/system/1.0}node-uuid":"5ad08b31-482f-41b1-8949-8021dd455507",
      "{http://www.alfresco.org/model/content/1.0}taggable":null,
      "{http://www.alfresco.org/model/content/1.0}modified":"2016-01-12T10:22:17.437+01:00",
      "{http://www.alfresco.org/model/content/1.0}created":"2016-01-12T10:22:17.437+01:00",
      "{http://www.alfresco.org/model/system/1.0}store-protocol":"workspace",
      "{http://www.alfresco.org/model/content/1.0}creator":"admin",
      "{http://www.alfresco.org/model/content/1.0}description":"",
      "{http://www.alfresco.org/model/content/1.0}categories":null,
      "{http://www.alfresco.org/model/content/1.0}modifier":"admin"
   },
   "type":"{http://www.alfresco.org/model/content/1.0}folder"
}

所以我建议你试试 title=response.json.properties["http://www.alfresco.org/model/content/1.0}title"];

而不是title=response.json.properties["cm:title"];