stefan-egli commented on PR #1622:
URL: https://github.com/apache/jackrabbit-oak/pull/1622#issuecomment-2269152138

   Just to mention one further, somewhat brutal, option : Equivalent to 
temporarily removing the `mix:referenceable` (with the goal to allow changing 
the `jcr:uuid`) would be to temporarily change the primaryType to an 
unprotected one that would allow changing the `jcr:uuid`. That could be 
achieved either by using a hard-coded raw type (eg `nt:unstructured`, 
`oak:Unstructured` depending on orderable or not) - or by temporarily adding an 
node type that extends the existing one, and in the temporary one make 
`jcr:uuid` not protected, eg:
   ```
               NodeTypeTemplate unprotectedNTT = ntMgr.createNodeTypeTemplate();
               unprotectedNTT.setName(tmpNodeTypeName);
               unprotectedNTT.setDeclaredSuperTypeNames(new String[] 
{primaryType.getName()});
               PropertyDefinitionTemplate pdt = 
ntMgr.createPropertyDefinitionTemplate();
               pdt.setName("jcr:uuid");
               pdt.setProtected(false);
               unprotectedNTT.getPropertyDefinitionTemplates().add(pdt);
               
session.getWorkspace().getNodeTypeManager().registerNodeType(unprotectedNTT, 
true);
               target.setPrimaryType(unprotectedNTT.getName());
               target.setProperty("jcr:uuid", newUUID);
               target.setPrimaryType(primaryType.getName());
               
session.getWorkspace().getNodeTypeManager().unregisterNodeType(unprotectedNTT.getName());
               session.save();
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to