
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2018 08:06 PM
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.
- Labels:
-
Alfresco Content Services
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2018 06:23 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2018 06:23 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 08:36 PM
It's creazy to traverse up the chain of parents
Now in 2022 is there another way to get the parent site without traversing the parent chain ?
Thanks you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2022 05:51 AM
You may use the regular node API with the include=path parameter
The response will include the Site and all the other parent folders
"path": { "name": "/Company Home/Sites/swsdp/documentLibrary/Agency Files/Contracts", "isComplete": true, "elements": [ { "id": "1810057d-ad92-4adf-b770-2916c56251f3", "name": "Company Home", "nodeType": "cm:folder", "aspectNames": [ "cm:titled", "cm:auditable", "app:uifacets" ] }, { "id": "9d550dea-d02f-450a-8e30-c05c091e7272", "name": "Sites", "nodeType": "st:sites", "aspectNames": [ "cm:titled", "cm:auditable", "app:uifacets" ] }, { "id": "b4cff62a-664d-4d45-9302-98723eac1319", "name": "swsdp", "nodeType": "st:site", "aspectNames": [ "cm:tagscope", "cm:ownable", "cm:titled", "cm:auditable" ] }, { "id": "8f2105b4-daaf-4874-9e8a-2152569d109b", "name": "documentLibrary", "nodeType": "cm:folder", "aspectNames": [ "cm:tagscope", "st:siteContainer", "cm:titled", "cm:ownable", "cm:auditable" ] }, { "id": "8bb36efb-c26d-4d2b-9199-ab6922f53c28", "name": "Agency Files", "nodeType": "cm:folder", "aspectNames": [ "cm:titled", "cm:ownable", "cm:auditable", "cm:taggable" ] }, { "id": "e0856836-ed5e-4eee-b8e5-bd7e8fb9384c", "name": "Contracts", "nodeType": "cm:folder", "aspectNames": [ "cm:titled", "cm:ownable", "cm:auditable" ] } ] }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2018 12:08 PM
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);
