Search in sources :

Example 11 with Mount

use of org.apache.jackrabbit.oak.spi.mount.Mount in project jackrabbit-oak by apache.

the class CrossMountReferenceValidator method leave.

@Override
public void leave(NodeState before, NodeState after) throws CommitFailedException {
    if (parent != null) {
        return;
    }
    for (Map.Entry<String, Collection<String>> e : newReferences.asMap().entrySet()) {
        String uuid = e.getKey();
        String passivePath = getPathByUuid(uuid);
        if (passivePath == null) {
            LOG.warn("Can't find path for the UUID {}", uuid);
        }
        Mount m1 = mip.getMountByPath(passivePath);
        for (String activePath : e.getValue()) {
            Mount m2 = mip.getMountByPath(activePath);
            if (!m1.equals(m2)) {
                if (failOnDetection) {
                    throw new CommitFailedException(INTEGRITY, 1, "Unable to reference the node [" + passivePath + "] from node [" + activePath + "]. Referencing across the mounts is not allowed.");
                } else {
                    LOG.warn("Detected a cross-mount reference: {} -> {}", activePath, passivePath);
                }
            }
        }
    }
}
Also used : Mount(org.apache.jackrabbit.oak.spi.mount.Mount) Collection(java.util.Collection) Map(java.util.Map) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException)

Example 12 with Mount

use of org.apache.jackrabbit.oak.spi.mount.Mount in project jackrabbit-oak by apache.

the class MountInfoProviderServiceTest method mountWithConfig_Name.

@Test
public void mountWithConfig_Name() throws Exception {
    MockOsgi.activate(service, context.bundleContext(), ImmutableMap.<String, Object>of("mountedPaths", new String[] { "/a", "/b" }, "mountName", "foo", "readOnlyMount", true));
    MountInfoProvider provider = context.getService(MountInfoProvider.class);
    assertEquals(1, provider.getNonDefaultMounts().size());
    Mount m = provider.getMountByName(MountInfoProviderService.PROP_MOUNT_NAME_DEFAULT);
    assertNull(m);
    Mount defMount = provider.getDefaultMount();
    assertNotNull(defMount);
    m = provider.getMountByName("foo");
    assertEquals(m, provider.getMountByPath("/a"));
    assertEquals(defMount, provider.getMountByPath("/x"));
    assertTrue(m.isReadOnly());
}
Also used : Mount(org.apache.jackrabbit.oak.spi.mount.Mount) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) Mounts.defaultMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider) Test(org.junit.Test)

Aggregations

Mount (org.apache.jackrabbit.oak.spi.mount.Mount)12 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)6 Test (org.junit.Test)6 HashSet (java.util.HashSet)2 Mounts.defaultMountInfoProvider (org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider)2 SimpleMountInfoProvider (org.apache.jackrabbit.oak.spi.mount.SimpleMountInfoProvider)2 ImmutableList (com.google.common.collect.ImmutableList)1 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 Collection (java.util.Collection)1 Hashtable (java.util.Hashtable)1 Map (java.util.Map)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)1 Multiplexers.getNodeForMount (org.apache.jackrabbit.oak.plugins.index.property.Multiplexers.getNodeForMount)1 FilteringIndexStoreStrategy (org.apache.jackrabbit.oak.plugins.index.property.strategy.FilteringIndexStoreStrategy)1 IndexStoreStrategy (org.apache.jackrabbit.oak.plugins.index.property.strategy.IndexStoreStrategy)1 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)1 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)1 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)1