use of java.nio.file.DirectoryNotEmptyException in project structr by structr.
the class StructrFilePath method delete.
@Override
public void delete() throws IOException {
final App app = StructrApp.getInstance(fs.getSecurityContext());
final AbstractFile actualFile = getActualFile();
try (final Tx tx = app.tx()) {
// if a folder is to be deleted, check contents
if (actualFile instanceof Folder && ((Folder) actualFile).getChildren().iterator().hasNext()) {
throw new DirectoryNotEmptyException(getActualFile().getPath());
} else {
app.delete(actualFile);
// remove cached version
this.cachedActualFile = null;
}
tx.success();
} catch (FrameworkException fex) {
logger.warn("Unable to delete file {}: {}", new Object[] { getActualFile().getPath(), fex.getMessage() });
}
}
use of java.nio.file.DirectoryNotEmptyException in project neo4j by neo4j.
the class BatchingNeoStoresTest method shouldNotOpenStoreWithNodesOrRelationshipsInIt.
@Test
void shouldNotOpenStoreWithNodesOrRelationshipsInIt() throws Throwable {
Config config = Config.defaults();
// GIVEN
someDataInTheDatabase(config);
// WHEN
DirectoryNotEmptyException exception = assertThrows(DirectoryNotEmptyException.class, () -> {
try (JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
RecordFormats recordFormats = selectForConfig(Config.defaults(), NullLogProvider.getInstance());
try (BatchingNeoStores store = batchingNeoStores(fileSystem, databaseLayout, recordFormats, Configuration.DEFAULT, NullLogService.getInstance(), EMPTY, Config.defaults(), jobScheduler, PageCacheTracer.NULL, INSTANCE)) {
store.createNew();
}
}
});
assertThat(exception.getMessage()).contains("already contains");
}
Aggregations