Hi All,
I would like to get site name / id of a given node id. How can I do that?
I used the below query (/nodes/{nodeId}/parents) but apparently it gives only the immediate parent of the node?
Request
Response
{
"list":{
"pagination":{
"count":1,
"hasMoreItems":false,
"totalItems":1,
"skipCount":0,
"maxItems":100
},
"entries":[
{
"entry":{
"createdAt":"2018-05-28T17:40:02.421+0000",
"isFolder":true,
"isFile":false,
"createdByUser":{
"id":"admin",
"displayName":"Administrator"
},
"modifiedAt":"2018-05-28T23:55:58.705+0000",
"modifiedByUser":{
"id":"admin",
"displayName":"Administrator"
},
"name":"MyFolder1",
"association":{
"isPrimary":true,
"assocType":"cm:contains"
},
"id":"7bd86fea-5477-470f-9d91-2c7937a8936e",
"nodeType":"cm:folder",
"parentId":"18f734ac-8e2c-424b-a75c-c19db3ea6d36"
}
}
]
}
}
Please let me know
Thank you,
Edit by Axel Faust: Use syntax highlighter and formatting to make post easier to read.
Solved! Go to Solution.
You need to traverse up the chain of parents until you find a node of type st:site. Then use that node's name as the site ID.
You need to traverse up the chain of parents until you find a node of type st:site. Then use that node's name as the site ID.
An alternative would be to write a simple web script with a Java controller. The SiteService has a getSite() method that accepts a node reference and returns a SiteInfo object for the site that contains that node.
/**
* This method gets the {@link SiteInfo} for the Share Site which contains the given NodeRef.
* If the given NodeRef is not contained within a Share Site, then <code>null</code> is returned.
*
* @param nodeRef the node whose containing site's info is to be found.
* @return SiteInfo site information for the containing site or <code>null</code> if node is not in a site.
*/
@NotAuditable
SiteInfo getSite(NodeRef nodeRef);
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.