Search in sources :

Example 11 with MountedNodeStore

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

the class NodeTypeMountedNodeStoreCheckerTest method referenceableNodeIsDetected.

@Test(expected = IllegalRepositoryStateException.class)
public void referenceableNodeIsDetected() throws CommitFailedException {
    MemoryNodeStore root = new MemoryNodeStore();
    MemoryNodeStore mount = new MemoryNodeStore();
    NodeBuilder builder = mount.getRoot().builder();
    builder.child("first").setProperty(PropertyStates.createProperty(JcrConstants.JCR_MIXINTYPES, Collections.singletonList(JcrConstants.MIX_REFERENCEABLE), Type.NAMES)).setProperty(JcrConstants.JCR_UUID, UUID.randomUUID().toString());
    mount.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    MountInfoProvider mip = Mounts.newBuilder().readOnlyMount("first", "/first").build();
    NodeTypeMountedNodeStoreChecker checker = new NodeTypeMountedNodeStoreChecker(JcrConstants.MIX_REFERENCEABLE, "test error");
    Context context = checker.createContext(root, mip);
    ErrorHolder errorHolder = new ErrorHolder();
    checker.check(new MountedNodeStore(mip.getMountByName("first"), mount), TreeFactory.createReadOnlyTree(mount.getRoot()).getChild("first"), errorHolder, context);
    errorHolder.end();
}
Also used : Context(org.apache.jackrabbit.oak.composite.checks.NodeTypeMountedNodeStoreChecker.Context) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MountedNodeStore(org.apache.jackrabbit.oak.composite.MountedNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) Test(org.junit.Test)

Example 12 with MountedNodeStore

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

the class UniqueIndexNodeStoreChecker method createContext.

@Override
public Context createContext(NodeStore globalStore, MountInfoProvider mip) {
    Context ctx = new Context(mip);
    // read definitions from oak:index, and pick all unique indexes
    NodeState indexDefs = globalStore.getRoot().getChildNode(INDEX_DEFINITIONS_NAME);
    for (ChildNodeEntry indexDef : indexDefs.getChildNodeEntries()) {
        if (indexDef.getNodeState().hasProperty(UNIQUE_PROPERTY_NAME) && indexDef.getNodeState().getBoolean(UNIQUE_PROPERTY_NAME)) {
            ctx.add(indexDef, mip.getDefaultMount(), indexDefs);
            ctx.track(new MountedNodeStore(mip.getDefaultMount(), globalStore));
        }
    }
    return ctx;
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) MountedNodeStore(org.apache.jackrabbit.oak.composite.MountedNodeStore) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)

Aggregations

MountedNodeStore (org.apache.jackrabbit.oak.composite.MountedNodeStore)12 Test (org.junit.Test)10 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)7 Context (org.apache.jackrabbit.oak.composite.checks.UniqueIndexNodeStoreChecker.Context)5 Context (org.apache.jackrabbit.oak.composite.checks.NodeTypeMountedNodeStoreChecker.Context)2 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 Tree (org.apache.jackrabbit.oak.api.Tree)1 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1