@Test public void testDeleteAllOccurences() { final ScopePathBuilderFactory factory = getConfigService().getScopePathBuilderFactory(TestConfiguration.class); final ScopePath parentPath = factory.annotatedPath().create(); final ScopePath childPath = factory.annotatedPathUntil(GlobalScopeDescriptor.NAME).create(); final ScopePath child2Path = factory.annotatedPathUntil(DefaultScopeDescriptor.NAME).create(); final ComplexConfigDTO parentConfig = createTestConfigDTO(parentPath); final ComplexConfigDTO childConfig = createTestConfigDTO(childPath); final ComplexConfigDTO child2Config = createTestConfigDTO(child2Path); persister.saveConfiguration(parentConfig); persister.saveConfiguration(childConfig); persister.saveConfiguration(child2Config); final File file = new File(rootDirectory + File.separator + "default" + File.separator + "global" + File.separator + "user" + File.separator + "userName-hugo" + File.separator + gen.createName(factory.annotatedPath().create())); persister.deleteAllOccurences(UserScopeDescriptor.NAME, getUserScopeProperties()); Assert.assertTrue(!file.exists()); }
@Override public void deleteAllOccurences(final String scopeName, final Map<String, String> properties) { Assert.paramNotNull(scopeName, "scopeName"); Assert.paramNotNull(properties, "properties"); final Collection<?> files = FileUtils.listFiles( new File(rootDirectory), FileFilterUtils.fileFileFilter(), TrueFileFilter.INSTANCE); final String searchedPathPart = gen.buildScopeWithProperty(scopeName, properties); for (final Object file : files) { final String path = ((File) file).getAbsolutePath(); if (path.contains(searchedPathPart)) { deleteConfigFileIfExists(((File) file)); } } }
FileConfigPersister implements ConfigPersister { @Override public void deleteAllOccurences(final String scopeName, final Map<String, String> properties) { Assert.paramNotNull(scopeName, "scopeName"); Assert.paramNotNull(properties, "properties"); final Collection<?> files = FileUtils.listFiles( new File(rootDirectory), FileFilterUtils.fileFileFilter(), TrueFileFilter.INSTANCE); final String searchedPathPart = gen.buildScopeWithProperty(scopeName, properties); for (final Object file : files) { final String path = ((File) file).getAbsolutePath(); if (path.contains(searchedPathPart)) { deleteConfigFileIfExists(((File) file)); } } } }
FileConfigPersister implements ConfigPersister { @Override public void deleteAllOccurences(final String scopeName, final Map<String, String> properties) { Assert.paramNotNull(scopeName, "scopeName"); Assert.paramNotNull(properties, "properties"); final Collection<?> files = FileUtils.listFiles( new File(rootDirectory), FileFilterUtils.fileFileFilter(), TrueFileFilter.INSTANCE); final String searchedPathPart = gen.buildScopeWithProperty(scopeName, properties); for (final Object file : files) { final String path = ((File) file).getAbsolutePath(); if (path.contains(searchedPathPart)) { deleteConfigFileIfExists(((File) file)); } } } FileConfigPersister(final ConfigMarshaller marshaller, final String rootDirectory, final String fileExtension); }
FileConfigPersister implements ConfigPersister { @Override public void deleteAllOccurences(final String scopeName, final Map<String, String> properties) { Assert.paramNotNull(scopeName, "scopeName"); Assert.paramNotNull(properties, "properties"); final Collection<?> files = FileUtils.listFiles( new File(rootDirectory), FileFilterUtils.fileFileFilter(), TrueFileFilter.INSTANCE); final String searchedPathPart = gen.buildScopeWithProperty(scopeName, properties); for (final Object file : files) { final String path = ((File) file).getAbsolutePath(); if (path.contains(searchedPathPart)) { deleteConfigFileIfExists(((File) file)); } } } FileConfigPersister(final ConfigMarshaller marshaller, final String rootDirectory, final String fileExtension); @Override String getId(); @Override ComplexConfigDTO loadConfiguration(final ScopePath scopePath); @Override void updateConfiguration(final ComplexConfigDTO configDTO); @Override void saveConfiguration(final ComplexConfigDTO configDTO); @Override void delete(final ScopePath scopePath, final boolean deleteChildren); @Override void deleteAllOccurences(final String scopeName, final Map<String, String> properties); @Override Collection<ScopePath> listScopes(final String scopeName, final Map<String, String> properties); }
FileConfigPersister implements ConfigPersister { @Override public void deleteAllOccurences(final String scopeName, final Map<String, String> properties) { Assert.paramNotNull(scopeName, "scopeName"); Assert.paramNotNull(properties, "properties"); final Collection<?> files = FileUtils.listFiles( new File(rootDirectory), FileFilterUtils.fileFileFilter(), TrueFileFilter.INSTANCE); final String searchedPathPart = gen.buildScopeWithProperty(scopeName, properties); for (final Object file : files) { final String path = ((File) file).getAbsolutePath(); if (path.contains(searchedPathPart)) { deleteConfigFileIfExists(((File) file)); } } } FileConfigPersister(final ConfigMarshaller marshaller, final String rootDirectory, final String fileExtension); @Override String getId(); @Override ComplexConfigDTO loadConfiguration(final ScopePath scopePath); @Override void updateConfiguration(final ComplexConfigDTO configDTO); @Override void saveConfiguration(final ComplexConfigDTO configDTO); @Override void delete(final ScopePath scopePath, final boolean deleteChildren); @Override void deleteAllOccurences(final String scopeName, final Map<String, String> properties); @Override Collection<ScopePath> listScopes(final String scopeName, final Map<String, String> properties); static final String ID; }