1

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 !

deltascience
  • 3,321
  • 5
  • 42
  • 71
  • What do you mean by "node details"? All properties? Parents? Paths? Permissions? The answer will depend on what you want... – Gagravarr Jun 10 '14 at 11:31

2 Answers2

5

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.

Mardoz
  • 1,617
  • 1
  • 13
  • 26
  • I personalty prefer to work with JSON response, but your webscript seems a to meet my needs. I'll use it until I found another alternative. Many thanks. – deltascience Jun 10 '14 at 14:53
  • If you prefer JSON then you can use the Alfresco Browser Binding: http://docs.alfresco.com/4.2/pra/1/concepts/cmis-1.1-browser-binding.html – francesco Jun 17 '14 at 14:16
2

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)

Gagravarr
  • 47,320
  • 10
  • 111
  • 156
  • Dear Gagravarr, I already used that webScript. It works only if the node is inside the documentLibrary or inside the RootNode. But what I want is getting properties of a node whatever its placement is. The error that I wrote in my question occurs when I call the webScript for a content directly inside a site folder `e.g: Sites/mysite/content.txt` The webscript says that content.txt does not refer to a folder. Would you please check if you have the same issue ? – deltascience Jun 10 '14 at 14:37
  • Look at my example, it's for a node that's in a random non-site folder. You shouldn't normally be placing content directly in a site's root, content ought to live in a container folder within the site – Gagravarr Jun 10 '14 at 15:04