Skip to content

Instantly share code, notes, and snippets.

@chetanmeh
Last active March 12, 2022 15:40
Show Gist options
  • Save chetanmeh/a1f4bbfaad7f5d9495ce84b43967db9f to your computer and use it in GitHub Desktop.
Save chetanmeh/a1f4bbfaad7f5d9495ce84b43967db9f to your computer and use it in GitHub Desktop.
import org.apache.jackrabbit.oak.spi.commit.CommitInfo
import org.apache.jackrabbit.oak.spi.commit.EmptyHook
import org.apache.jackrabbit.oak.spi.state.NodeBuilder as JNodeBuilder
import org.apache.jackrabbit.oak.spi.state.NodeStore
import org.apache.jackrabbit.util.ISO8601
import java.util.concurrent.TimeUnit
NodeStore store = getStore()
String checkpoint = store.checkpoint(TimeUnit.DAYS.toMillis(100),
[
creator: 'AsyncIndexUpdate',
name : 'fulltext-async',
created: ISO8601.format(Calendar.getInstance()),
thread : 'groovy-script'
]
)
println "Before :async ${store.root.getChildNode(":async")}"
JNodeBuilder nb = store.root.builder()
nb.getChildNode(":async").setProperty("fulltext-async", checkpoint)
store.merge(nb, EmptyHook.INSTANCE, CommitInfo.EMPTY)
println "Created checkpoint $checkpoint"
println "Current :async ${store.root.getChildNode(":async")}"
def getStore() {
osgi.getService(org.apache.sling.jcr.api.SlingRepository.class).manager.store
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment