-
-
Save helms-charity/fd1e41c4033a93d71b22aecb15b28b69 to your computer and use it in GitHub Desktop.
Groovy script to remove a node at a given path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.jackrabbit.oak.spi.commit.CommitInfo | |
import org.apache.jackrabbit.oak.spi.commit.EmptyHook | |
import org.apache.jackrabbit.oak.spi.state.NodeStore | |
import org.apache.jackrabbit.oak.commons.PathUtils | |
def rmNode(def session, String path) { | |
println "Removing node ${path}" | |
NodeStore ns = session.store | |
def nb = ns.root.builder() | |
def aBuilder = nb | |
for(p in PathUtils.elements(path)) { aBuilder = aBuilder.getChildNode(p) } | |
if(aBuilder.exists()) { | |
rm = aBuilder.remove() | |
ns.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY) | |
return rm | |
} else { | |
println "Node ${path} doesn't exist" | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment