Search code examples
javaalfrescobackendweb-scripting

Get node details in Alfresco via back-end webscript


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 !


Solution

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