Search in sources :

Example 1 with CompositeNodeStore

use of org.apache.jackrabbit.oak.composite.CompositeNodeStore in project jackrabbit-oak by apache.

the class SessionImplCapabilityWithMountInfoProviderTest method prepare.

@Before
public void prepare() throws Exception {
    MountInfoProvider mip = Mounts.newBuilder().readOnlyMount("ro", "/private").build();
    MemoryNodeStore roStore = new MemoryNodeStore();
    {
        NodeBuilder builder = roStore.getRoot().builder();
        builder.child("private").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED).setProperty("prop", "value").child("foo").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED);
        roStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    }
    MemoryNodeStore globalStore = new MemoryNodeStore();
    {
        NodeBuilder builder = globalStore.getRoot().builder();
        builder.child("foo").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED).setProperty("prop", "value").child("bar").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED);
        globalStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    }
    CompositeNodeStore store = new CompositeNodeStore.Builder(mip, globalStore).addMount("ro", roStore).build();
    Whiteboard whiteboard = new DefaultWhiteboard();
    whiteboard.register(MountInfoProvider.class, mip, Collections.emptyMap());
    Jcr jcr = new Jcr(store).with(whiteboard);
    jcr.createContentRepository();
    Repository repository = jcr.createRepository();
    adminSession = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) CompositeNodeStore(org.apache.jackrabbit.oak.composite.CompositeNodeStore) Repository(javax.jcr.Repository) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Before(org.junit.Before)

Aggregations

Repository (javax.jcr.Repository)1 SimpleCredentials (javax.jcr.SimpleCredentials)1 CompositeNodeStore (org.apache.jackrabbit.oak.composite.CompositeNodeStore)1 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)1 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)1 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 DefaultWhiteboard (org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard)1 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)1 Before (org.junit.Before)1