1
votes

I want to get node details via Backend webscript but I have some issues. I've tried two webscripts:

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

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

The first one gave me this response :

{
"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"
}

and the second :

{
        "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."
          ,"

Updated :

You can notice that in the second webSript the error says that my file UploadComponent.java does not refer to a folder. Does this script take a cm:folder as an argument. If there is another web-script that returns the node details (properties: nodeRef, mimetype, size... ) from nodeRef please show it to me. thanks !

2
What do you mean by "node details"? All properties? Parents? Paths? Permissions? The answer will depend on what you want... - Gagravarr
@Gagravarr I updated the post. - deltascience

2 Answers

5
votes

Pro tip - You can see all of the available web scripts at http://localhost:8080/alfresco/service/index/uri/

You're supposed to use the CMIS web scripts where possible, and this also makes for the simplest request.

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

This returns the full set of properties for the nodeRef workspace://SpacesStore/8826b8f4-9f61-41a4-9f21-14ad5b6395ab.

Some of the XML you will receive is:

<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>

I also checked and this should give you the properties for any node regardless of where it is situated in your Alfresco instance.

2
votes

There are a few webscripts you can use, such as the CMIS ones, but I think the simplest is probably the Slingshot Document Library Node webscript, with ID org/alfresco/slingshot/documentlibrary/node.get. You can read about it at http://localhost:8080/alfresco/service/script/org/alfresco/slingshot/documentlibrary/node.get

For a node with noderef workspace://SpacesStore/357b6dad-d434-4a46-a7e0-731df50e5e90 the URL is http://localhost:8080/alfresco/service/slingshot/doclib/node/workspace/SpacesStore/357b6dad-d434-4a46-a7e0-731df50e5e90, and the JSON returned looks something like:

{
"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":
{
}
}
}

I believe that's all the metadata and properties you're after. It's a webscript used by Share, so ought to be well tested and used. As you can see from the location section, it's a webscript which works for both site-based and non-site nodes equally

(If you do hit problems with it, probably best to ensure you're running the latest service pack if on enterprise, or newest release for community)