Hi,
I am having requirement to add a custom folder properties , but my folder are created dynamically as nt:folder from backend.
Since folder schema only applies to sling:folder, wanted to check if we can change the folder primary type in JCR.
Solved! Go to Solution.
Views
Replies
Total Likes
Thanks @kautuk_sahni ,
I have found these suggestions useful, for my case, I used CURL commands to change it on author ,
However on publisher i was not able to do the same , so i have unpublished the node and change the folder type in author using CURL and publish it again fixes the issue.
Thank you.
Poovitha S
Yes, you can change folder from code by giving same name to the folder, just change jcr:primaryType="sling:Folder"
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="sling:Folder" jcr:title="test folder project" sling:resourceType="sling:Folder"/>
in filter.xml, you can update
<filter root="/<foolder-destination>/testfolder" mode="update"/>
earlier testfolder was "nt:folder" now updated to sling:Folder
Thanks
jcr:primaryType is a protected property and can not be changed or removed by the application using the API. Please refer this document for more details :
You can restructure the old folders with Sling:Folder as jcr:primaryType using some script and update existing BE logic to create the folder as sling:Folder.
Goto folder properties and change it to "orderable". this will change the the primaryType from nt:folder to sling:orderedFolder. you can uncheck this again to the make primaryType to sling:folder
Thanks @muhammeds946397 that works and is simple solution
Views
Replies
Total Likes
YES! it is posible and i have it working correctly.
It is the same code that is used by the POST servlet when you want to change the folder properties using the UI
Node folderNode = folderResource.adaptTo(Node.class);
folderNode.setPrimaryType("sling:OrderedFolder");
folderNode.getSession().save();
@PoovithaSelvaraj Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
Thanks @kautuk_sahni ,
I have found these suggestions useful, for my case, I used CURL commands to change it on author ,
However on publisher i was not able to do the same , so i have unpublished the node and change the folder type in author using CURL and publish it again fixes the issue.
Thank you.
Poovitha S