通过后端webscript获取Alfresco中的节点详细信息

时间:2014-06-10 08:39:58

标签: java alfresco backend web-scripting

我想通过Backend webscript获取节点详细信息,但我有一些问题。我尝试了两个网页:

  • alfresco/service/slingshot/doclib2/node/workspace/SpacesStore/a10a0777-40f4-42da-b236-8845eb26294e

  • alfresco/service/slingshot/doclib/node/workspace/SpacesStore/a10a0777-40f4-42da-b236-8845eb26294e

第一个给了我这个回复:

{
"status" : 
{
"code" : 410,
"name" : "Gone",
"description" : "Resource is no longer available at the server and no forwarding address is known."
},  

"message" : "Location is 'null'. (No permission?)",  
"exception" : "",

"callstack" : 
[ 

],

"server" : "Enterprise v4.2.0 (r57217-b28) schema 6,034",
"time" : "Jun 10, 2014 10:28:15 AM"
}

和第二个:

{
        "status" : 
      {
        "code" : 500,
        "name" : "Internal Error",
        "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
      },  

      "message" : "05100028 Wrapped Exception (with status template): 05100077 Failed to execute script 'classpath*:alfresco\/templates\/webscripts\/org\/alfresco\/slingshot\/documentlibrary\/node.get.js': 05100076 Site container UploadComponent.java does not refer to a folder.",  
      "exception" : "org.springframework.extensions.webscripts.WebScriptException - 05100028 Wrapped Exception (with status template): 05100077 Failed to execute script 'classpath*:alfresco\/templates\/webscripts\/org\/alfresco\/slingshot\/documentlibrary\/node.get.js': 05100076 Site container UploadComponent.java does not refer to a folder.",

      "callstack" : 
      [ 
          ""      ,"org.alfresco.repo.site.SiteServiceException: 05100076 Site container UploadComponent.java does not refer to a folder."
          ,"

已更新:

您可以注意到,在第二个webSript中,错误表明我的文件UploadComponent.java未引用文件夹。此脚本是否将cm:文件夹作为参数。如果有另一个web-script从nodeRef返回节点详细信息(属性:nodeRef,mimetype,size ...),请向我显示。谢谢!

2 个答案:

答案 0 :(得分:5)

专业提示 - 您可以在http://localhost:8080/alfresco/service/index/uri/

查看所有可用的网络脚本

假设在可能的情况下使用CMIS网页脚本,这也是最简单的请求。

http://<MyAlfresco>/alfresco/service/cmis/i/8826b8f4-9f61-41a4-9f21-14ad5b6395ab

这将返回nodeRef workspace://SpacesStore/8826b8f4-9f61-41a4-9f21-14ad5b6395ab的完整属性集。

您将收到的一些XML是:

<cmis:properties>
    <cmis:propertyInteger propertyDefinitionId="cmis:contentStreamLength" displayName="Content Stream Length" queryName="cmis:contentStreamLength"><cmis:value>36864</cmis:value></cmis:propertyInteger>
    <cmis:propertyId propertyDefinitionId="cmis:objectTypeId" displayName="Object Type Id" queryName="cmis:objectTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId>
    <cmis:propertyString propertyDefinitionId="cmis:versionSeriesCheckedOutBy" displayName="Version Series Checked Out By" queryName="cmis:versionSeriesCheckedOutBy"/>
    <cmis:propertyBoolean propertyDefinitionId="cmis:isPrivateWorkingCopy" displayName="Is private working copy" queryName="cmis:isPrivateWorkingCopy"/>
    <cmis:propertyId propertyDefinitionId="cmis:versionSeriesCheckedOutId" displayName="Version Series Checked Out Id" queryName="cmis:versionSeriesCheckedOutId"/>
    <cmis:propertyId propertyDefinitionId="cmis:versionSeriesId" displayName="Version series id" queryName="cmis:versionSeriesId"><cmis:value>workspace://SpacesStore/8826b8f4-9f61-41a4-9f21-14ad5b6395ab</cmis:value></cmis:propertyId>
    <cmis:propertyBoolean propertyDefinitionId="cmis:isLatestVersion" displayName="Is Latest Version" queryName="cmis:isLatestVersion"><cmis:value>true</cmis:value></cmis:propertyBoolean>
</cmis:properties>

我还检查过,这应该为您提供任何节点的属性,无论它在Alfresco实例中的位置。

答案 1 :(得分:2)

您可以使用一些网页脚本,例如CMIS ones,但我认为最简单的可能是Slingshot文档库节点webscript,标识为org/alfresco/slingshot/documentlibrary/node.get。您可以在http://localhost:8080/alfresco/service/script/org/alfresco/slingshot/documentlibrary/node.get

上阅读相关信息

对于noderef为workspace://SpacesStore/357b6dad-d434-4a46-a7e0-731df50e5e90的节点,URL为http://localhost:8080/alfresco/service/slingshot/doclib/node/workspace/SpacesStore/357b6dad-d434-4a46-a7e0-731df50e5e90,返回的JSON类似于:

{
"metadata":
{
  "parent":
  {
     "nodeRef": "workspace://SpacesStore/7f4e374c-7c7c-4356-bf8f-0ec6bfc5eac4",
     "permissions":
     {
        "userAccess":
        {
           "permissions": true,
           "edit": true,
           "delete": true,
           "cancel-checkout": false,
           "create": true
        }
     }
  },
  "onlineEditing": true
},
"item":
{
"nodeRef": "workspace://SpacesStore/357b6dad-d434-4a46-a7e0-731df50e5e90",
"nodeType": "cm:content",
"type": "document",
"mimetype": "application\/vnd.ms-project",
"isFolder": false,
"isLink": false,
"fileName": "testPROJECT.mpx",
"displayName": "testPROJECT.mpx",
"status": "",
"title": "testPROJECT.mpx",
"description": "",
"author": "",
"createdOn": "2014-06-10T15:17:33.791+01:00",
"createdBy": "Administrator",
"createdByUser": "admin",
"modifiedOn": "2014-06-10T15:17:42.258+01:00",
"modifiedBy": "Administrator",
"modifiedByUser": "admin",
"lockedBy": "",
"lockedByUser": "",
"size": "3555",
"version": "1.0",
"contentUrl": "api/node/content/workspace/SpacesStore/357b6dad-d434-4a46-a7e0-731df50e5e90/testPROJECT.mpx",
"webdavUrl": "\/webdav\/User%20Homes\/administrator\/testPROJECT.mpx",
"actionSet": "document",
"tags": [],
"activeWorkflows": "",
"isFavourite": false,
"likes":
{
  "isLiked": false,
  "totalLikes": 0
},
"location":
{
  "repositoryId": "8ff64edd-57d3-4198-ac3d-8386f47bf5bb",
  "site": "",
  "siteTitle": "",
  "container": "",
  "path": "\/User Homes\/administrator",
  "file": "testPROJECT.mpx",
  "parent":
  {
     "nodeRef": "workspace:\/\/SpacesStore\/7f4e374c-7c7c-4356-bf8f-0ec6bfc5eac4"
  }
},
"permissions":
{
  "inherited": true,
  "roles":
  [
     "ALLOWED;administrator;All;INHERITED",
     "ALLOWED;ROLE_OWNER;All;INHERITED"
  ],
  "userAccess":
  {
     "permissions": true,
     "edit": true,
     "delete": true,
     "cancel-checkout": false,
     "create": true
  }
},
"custom": {},
"actionLabels":
{
}
}
}

我相信您所拥有的所有元数据和属性。它是Share使用的webscript,因此应该经过充分测试和使用。从位置部分可以看出,它是一个同时适用于基于站点和非站点节点的webscript

(如果您遇到问题,最好确保您在企业或社区的最新版本中运行最新的Service Pack)