Last active
June 25, 2024 16:30
-
-
Save alexkli/fe955b1d651e68b2a01db24be31c844f to your computer and use it in GitHub Desktop.
Groovy script for displaying hidden Oak content structures
This file contains hidden or 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.sling.jcr.api.SlingRepository | |
import javax.jcr.Session | |
import javax.jcr.Node | |
import javax.jcr.Property | |
SlingRepository repo = sling.getService(SlingRepository.class) | |
Session session = null | |
InputStream is = null | |
try { | |
session = repo.loginAdministrative(null); | |
// get oak ContentSession via reflection | |
def obj1 = java.lang.reflect.Proxy.getInvocationHandler(session).delegatee; | |
def field = obj1.class.superclass.getDeclaredField("sd"); | |
field.setAccessible(true); | |
def obj2 = field.get(obj1); | |
field = obj2.class.superclass.getDeclaredField("contentSession"); | |
field.setAccessible(true); | |
def cs = field.get(obj2); | |
out.println(cs.dump()); | |
def root = cs.latestRoot; | |
def t = root.getTree("/oak:index/nodetype/:index"); | |
out.println(t.exists()); | |
t.properties.each { kid -> | |
out.println(kid); | |
} | |
out.println(t.getChildrenCount(1000)); | |
t.children.each { kid -> | |
out.println(kid); | |
} | |
} finally { | |
is?.close() | |
session?.logout() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment