-
-
Save yesil/191b04f968c728962aefa00b927bec5f to your computer and use it in GitHub Desktop.
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.NodeState | |
import org.apache.jackrabbit.oak.spi.state.NodeBuilder | |
class LibsCleaner { | |
def session | |
def scanBundles(remove = false) { | |
def root = session.store.root | |
def builder = root.builder() | |
scanBundlesInt(session, remove, root.getChildNode("libs"), builder.getChildNode("libs"), "/libs") | |
if(remove) { | |
session.store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY) | |
} | |
println "finished" | |
} | |
def scanBundlesInt(def session, Boolean remove, NodeState nodeState, NodeBuilder nodeBuilder, String path) { | |
for(entry in nodeState.getChildNodeEntries()) { | |
def ns = entry.nodeState | |
def name = entry.name | |
def builder = nodeBuilder.getChildNode(name) | |
def current = path + "/" + name | |
if(name == "install") { | |
for(cnes in ns.getChildNodeNames()) { | |
if(cnes.endsWith(".jar")) { | |
if(remove) { | |
println "Removing ${current}/${cnes}" | |
builder.getChildNode(cnes).remove() | |
} else { | |
println "Found ${current}/${cnes}" | |
} | |
} | |
} | |
} else if(ns.getName("jcr:primaryType") == "nt:folder") { | |
scanBundlesInt(session, remove, ns, builder, current) | |
} | |
} | |
} | |
} | |
libsCleaner = new LibsCleaner(session: session) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to hack.fb with your code thanks
h