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(); } } }
@Test public void mountsPlacedUnder() { MountInfoProvider mip = Mounts.newBuilder() .mount("first", "/b") .mount("second", "/d", "/b/a") .mount("third", "/h", "/b/c") .build(); Collection<Mount> mountsContainedBetweenPaths = mip.getMountsPlacedUnder("/b"); assertEquals(2, mountsContainedBetweenPaths.size()); } }