Skip to content

Instantly share code, notes, and snippets.

@yesil
Created May 11, 2016 16:53
Show Gist options
  • Save yesil/d0e939ec34a8b2c867f7f9d63fcf21db to your computer and use it in GitHub Desktop.
Save yesil/d0e939ec34a8b2c867f7f9d63fcf21db to your computer and use it in GitHub Desktop.
groovy script to load in oak-run in order to rename protected node names.
import org.apache.jackrabbit.oak.spi.commit.CommitInfo
import org.apache.jackrabbit.oak.spi.commit.EmptyHook
def fixNodeType(session, nodeType) {
def rootB = session.store.root.builder()
def nodeTypeB = rootB.getChildNode("jcr:system").getChildNode("jcr:nodeTypes").getChildNode(nodeType)
def propertyDefinitionB = nodeTypeB.getChildNode("jcr:propertyDefinition")
def move = propertyDefinitionB.moveTo(nodeTypeB,"jcr:propertyDefinition[1]")
session.store.merge(rootB, EmptyHook.INSTANCE, CommitInfo.EMPTY)
println move ? "success" : "error"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment