MountedNodeStore getOwningStore(String path) { Mount mount = mip.getMountByPath(path); if (nodeStoresByMount.containsKey(mount)) { return nodeStoresByMount.get(mount); } else { throw new IllegalArgumentException("Unable to find an owning store for path " + path); } }
public static String getIndexNodeName(MountInfoProvider mountInfoProvider, String path, String defaultName) { Mount mount = mountInfoProvider.getMountByPath(path); return getNodeForMount(mount, defaultName); }
public static String getIndexNodeName(MountInfoProvider mountInfoProvider, String path, String defaultName) { Mount mount = mountInfoProvider.getMountByPath(path); return getNodeForMount(mount, defaultName); }
public static String getIndexNodeName(MountInfoProvider mountInfoProvider, String path, String defaultName) { Mount mount = mountInfoProvider.getMountByPath(path); return getNodeForMount(mount, defaultName); }
private LuceneIndexWriter getWriter(String path) { Mount mount = mountInfoProvider.getMountByPath(path); return getWriter(mount); }
private LuceneIndexWriter getWriter(String path) { Mount mount = mountInfoProvider.getMountByPath(path); return getWriter(mount); }
@NotNull private NodeBuilder getPermissionRoot(String path) { Mount m = mountInfoProvider.getMountByPath(path); return permissionStore.getChildNode(MountPermissionProvider.getPermissionRootName(m, workspaceName)); }
@Nonnull private NodeBuilder getPermissionRoot(String path) { Mount m = mountInfoProvider.getMountByPath(path); return permissionStore.getChildNode(MountPermissionProvider.getPermissionRootName(m, workspaceName)); }
@NotNull private NodeBuilder getPermissionRoot(String path) { Mount m = mountInfoProvider.getMountByPath(path); return permissionStore.getChildNode(MountPermissionProvider.getPermissionRootName(m, workspaceName)); }
private Validator checkPrivateStoreCommit(String commitPath) throws CommitFailedException { Mount mountInfo = mountInfoProvider.getMountByPath(commitPath); if (mountInfo.isReadOnly()) { Throwable throwable = new Throwable("Commit path: " + commitPath); logger.error("Detected commit to a read-only store! ", throwable); if (failOnDetection) { throw new CommitFailedException(CommitFailedException.UNSUPPORTED, 0, "Unsupported commit to a read-only store!", throwable); } } return new PrivateStoreValidator(commitPath); }
private boolean isMountedReadOnly(String path) { MountInfoProvider mip = sessionContext.getMountInfoProvider(); return mip != null && mip.getMountByPath(path).isReadOnly(); }
private boolean isMountedReadOnly(String path) { MountInfoProvider mip = sessionContext.getMountInfoProvider(); return mip != null && mip.getMountByPath(path).isReadOnly(); }
private boolean isMountedReadOnly(String path) { MountInfoProvider mip = sessionContext.getMountInfoProvider(); return mip != null && mip.getMountByPath(path).isReadOnly(); }
boolean shouldBeComposite(final String path) { boolean supportMounts = false; if (mip.getNonDefaultMounts().stream().anyMatch(m -> m.isSupportFragmentUnder(path))) { supportMounts = true; } else if (!mip.getMountsPlacedUnder(path).isEmpty()) { supportMounts = true; } return supportMounts && mip.getMountByPath(path).isDefault(); }
@Override public void deleteDocuments(String path) throws IOException { Mount mount = mountInfoProvider.getMountByPath(path); getWriter(mount).deleteDocuments(path); //In case of default mount look for other mounts with roots under this path //Note that one mount cannot be part of another mount if (mount.isDefault()) { //If any mount falls under given path then delete all documents in that for (Mount m : mountInfoProvider.getMountsPlacedUnder(path)) { getWriter(m).deleteAll(); } } }
@Override public void deleteDocuments(String path) throws IOException { Mount mount = mountInfoProvider.getMountByPath(path); getWriter(mount).deleteDocuments(path); //In case of default mount look for other mounts with roots under this path //Note that one mount cannot be part of another mount if (mount.isDefault()) { //If any mount falls under given path then delete all documents in that for (Mount m : mountInfoProvider.getMountsPlacedUnder(path)) { getWriter(m).deleteAll(); } } }
private Validator checkPrivateStoreCommit(String commitPath) throws CommitFailedException { Mount mountInfo = mountInfoProvider.getMountByPath(commitPath); if (mountInfo.isReadOnly()) { throw new CommitFailedException(CommitFailedException.UNSUPPORTED, 0, "Unsupported commit to a read-only store "+ commitPath); } return new PrivateStoreValidator(commitPath, mountInfoProvider); }
@Test public void defaultMount() throws Exception { MountInfoProvider mip = new SimpleMountInfoProvider(Collections.<Mount>emptyList()); assertNotNull(mip.getMountByPath("/a")); assertTrue(mip.getMountByPath("/a").isDefault()); assertFalse(mip.hasNonDefaultMounts()); }
@Test public void basicMounting() throws Exception { MountInfoProvider mip = Mounts.newBuilder() .mount("foo", "/a", "/b") .mount("bar", "/x", "/y") .build(); assertEquals("foo", mip.getMountByPath("/a").getName()); assertEquals("foo", mip.getMountByPath("/a/x").getName()); assertEquals("bar", mip.getMountByPath("/x").getName()); assertTrue(mip.getMountByPath("/z").isDefault()); assertTrue(mip.hasNonDefaultMounts()); }
@Test public void mountWithConfig_Paths() throws Exception{ MockOsgi.activate(service, context.bundleContext(), ImmutableMap.<String, Object>of("mountedPaths", new String[] {"/a", "/b"})); MountInfoProvider provider = context.getService(MountInfoProvider.class); assertEquals(1, provider.getNonDefaultMounts().size()); Mount m = provider.getMountByName(MountInfoProviderService.PROP_MOUNT_NAME_DEFAULT); assertNotNull(m); Mount defMount = provider.getDefaultMount(); assertNotNull(defMount); assertFalse(m.isReadOnly()); assertEquals(m, provider.getMountByPath("/a")); assertEquals(defMount, provider.getMountByPath("/x")); }