내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
해결됨

Can we change jcr:primaryType of the node after it is created

Avatar

Level 4

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.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 4

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

원본 게시물의 솔루션 보기

7 답변 개

Avatar

Community Advisor and Adobe Champion

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

HeenaMadan_0-1659019513203.png

Thanks

Avatar

Community Advisor

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 :

 

https://developer.adobe.com/experience-manager/reference-materials/spec/jcr/1.0/6.7.5_Special_Proper...

 

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.

Avatar

Level 2

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

Screenshot 2023-06-23 at 12.51.45.png

Avatar

Level 3

Thanks @muhammeds946397 that works and is simple solution 

Avatar

Level 3

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();

Avatar

Administrator

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



Kautuk Sahni

Avatar

정확한 답변 작성자:
Level 4

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