@Activate private void activate(BundleContext bundleContext, Map<String, ?> config) { failOnDetection = PropertiesUtil.toBoolean(config.get(PROP_FAIL_ON_DETECTION), true); if (mountInfoProvider.hasNonDefaultMounts()) { serviceRegistration = bundleContext.registerService(EditorProvider.class.getName(), this, null); logger.info("Enabling PrivateStoreValidatorProvider with failOnDetection {}", failOnDetection); } }
@Override public List<LuceneIndexReader> createReaders(LuceneIndexDefinition definition, NodeState defnState, String indexPath) throws IOException { if (!mountInfoProvider.hasNonDefaultMounts()) { LuceneIndexReader reader = createReader(definition, defnState, indexPath, FulltextIndexConstants.INDEX_DATA_CHILD_NAME, SUGGEST_DATA_CHILD_NAME); return reader != null ? ImmutableList.of(reader) : Collections.<LuceneIndexReader>emptyList(); } else { return createMountedReaders(definition, defnState, indexPath); } }
@Override public List<LuceneIndexReader> createReaders(LuceneIndexDefinition definition, NodeState defnState, String indexPath) throws IOException { if (!mountInfoProvider.hasNonDefaultMounts()) { LuceneIndexReader reader = createReader(definition, defnState, indexPath, FulltextIndexConstants.INDEX_DATA_CHILD_NAME, SUGGEST_DATA_CHILD_NAME); return reader != null ? ImmutableList.of(reader) : Collections.<LuceneIndexReader>emptyList(); } else { return createMountedReaders(definition, defnState, indexPath); } }
@Override public LuceneIndexWriter newInstance(IndexDefinition def, NodeBuilder definitionBuilder, boolean reindex) { Preconditions.checkArgument(def instanceof LuceneIndexDefinition, "Expected {} but found {} for index definition", LuceneIndexDefinition.class, def.getClass()); LuceneIndexDefinition definition = (LuceneIndexDefinition)def; if (mountInfoProvider.hasNonDefaultMounts()){ return new MultiplexingIndexWriter(directoryFactory, mountInfoProvider, definition, definitionBuilder, reindex, writerConfig); } return new DefaultIndexWriter(definition, definitionBuilder, directoryFactory, FulltextIndexConstants.INDEX_DATA_CHILD_NAME, LuceneIndexConstants.SUGGEST_DATA_CHILD_NAME, reindex, writerConfig); } }
@Override public LuceneIndexWriter newInstance(IndexDefinition def, NodeBuilder definitionBuilder, boolean reindex) { Preconditions.checkArgument(def instanceof LuceneIndexDefinition, "Expected {} but found {} for index definition", LuceneIndexDefinition.class, def.getClass()); LuceneIndexDefinition definition = (LuceneIndexDefinition)def; if (mountInfoProvider.hasNonDefaultMounts()){ return new MultiplexingIndexWriter(directoryFactory, mountInfoProvider, definition, definitionBuilder, reindex, writerConfig); } return new DefaultIndexWriter(definition, definitionBuilder, directoryFactory, FulltextIndexConstants.INDEX_DATA_CHILD_NAME, LuceneIndexConstants.SUGGEST_DATA_CHILD_NAME, reindex, writerConfig); } }
static Set<String> getSupportedPaths(@NotNull ConfigurationParameters params, @NotNull MountInfoProvider mountInfoProvider) { Set<String> supportedPaths = params.getConfigValue(CugConstants.PARAM_CUG_SUPPORTED_PATHS, ImmutableSet.of()); if (!supportedPaths.isEmpty() && mountInfoProvider.hasNonDefaultMounts()) { for (Mount mount : mountInfoProvider.getNonDefaultMounts()) { for (String path : supportedPaths) { if (mount.isUnder(path)) { log.error("Configured supported CUG path '{}' includes node store mount '{}'.", path, mount.getName()); throw new IllegalStateException(); } else if (mount.isMounted(path)) { log.error("Configured supported CUG path '{}' is part of node store mount '{}'.", path, mount.getName()); throw new IllegalStateException(); } } } } return supportedPaths; }
static Set<String> getSupportedPaths(@NotNull ConfigurationParameters params, @NotNull MountInfoProvider mountInfoProvider) { Set<String> supportedPaths = params.getConfigValue(CugConstants.PARAM_CUG_SUPPORTED_PATHS, ImmutableSet.of()); if (!supportedPaths.isEmpty() && mountInfoProvider.hasNonDefaultMounts()) { for (Mount mount : mountInfoProvider.getNonDefaultMounts()) { for (String path : supportedPaths) { if (mount.isUnder(path)) { log.error("Configured supported CUG path '{}' includes node store mount '{}'.", path, mount.getName()); throw new IllegalStateException(); } else if (mount.isMounted(path)) { log.error("Configured supported CUG path '{}' is part of node store mount '{}'.", path, mount.getName()); throw new IllegalStateException(); } } } } return supportedPaths; }
private static Set<IndexStoreStrategy> getStrategies(boolean unique, MountInfoProvider mountInfoProvider, Iterable<String> children, String defaultName) { if (mountInfoProvider.hasNonDefaultMounts()) { Set<String> names = new HashSet<String>();
@NotNull @Override public PermissionProvider getPermissionProvider(@NotNull Root root, @NotNull String workspaceName, @NotNull Set<Principal> principals) { Context ctx = getSecurityProvider().getConfiguration(AuthorizationConfiguration.class).getContext(); if (mountInfoProvider.hasNonDefaultMounts()) { return new MountPermissionProvider(root, workspaceName, principals, getRestrictionProvider(), getParameters(), ctx, this); } else { return new PermissionProviderImpl(root, workspaceName, principals, getRestrictionProvider(), getParameters(), ctx, this); } }
@NotNull @Override public PermissionProvider getPermissionProvider(@NotNull Root root, @NotNull String workspaceName, @NotNull Set<Principal> principals) { Context ctx = getSecurityProvider().getConfiguration(AuthorizationConfiguration.class).getContext(); if (mountInfoProvider.hasNonDefaultMounts()) { return new MountPermissionProvider(root, workspaceName, principals, getRestrictionProvider(), getParameters(), ctx, this); } else { return new PermissionProviderImpl(root, workspaceName, principals, getRestrictionProvider(), getParameters(), ctx, this); } }
private static Set<IndexStoreStrategy> getStrategies(boolean unique, MountInfoProvider mountInfoProvider, Iterable<String> children, String defaultName) { if (mountInfoProvider.hasNonDefaultMounts()) { Set<String> names = new HashSet<String>();
private static Set<IndexStoreStrategy> getStrategies(boolean unique, MountInfoProvider mountInfoProvider, Iterable<String> children, String defaultName) { if (mountInfoProvider.hasNonDefaultMounts()) { Set<String> names = new HashSet<String>();
@Nonnull @Override public PermissionProvider getPermissionProvider(@Nonnull Root root, @Nonnull String workspaceName, @Nonnull Set<Principal> principals) { Context ctx = getSecurityProvider().getConfiguration(AuthorizationConfiguration.class).getContext(); if (mountInfoProvider.hasNonDefaultMounts()) { return new MountPermissionProvider(root, workspaceName, principals, getRestrictionProvider(), getParameters(), ctx, mountInfoProvider, getRootProvider()); } else { return new PermissionProviderImpl(root, workspaceName, principals, getRestrictionProvider(), getParameters(), ctx, getRootProvider()); } }
@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()); }