@Override public boolean deleteIfExists(Path path, DeleteOption... options) throws IllegalArgumentException, DirectoryNotEmptyException, IOException, SecurityException { if (!authManager.authorize(toResource(path), getUser())) { throw new SecurityException(); } return service.deleteIfExists(path, options); }
protected void delete(org.uberfire.java.nio.file.Path path) { try { ioService.startBatch(path.getFileSystem()); ioService.deleteIfExists(path); } finally { ioService.endBatch(); } }
@Override public boolean deleteIfExists(Path path) { checkNotNull( "path", path ); return ioService.deleteIfExists(path ); }
protected void delete(org.uberfire.java.nio.file.Path path) { try { ioService.startBatch(path.getFileSystem()); ioService.deleteIfExists(path); } finally { ioService.endBatch(); } }
@Test public void testDeleteIfExists() { tested.deleteIfExists(ROOT_PATH); verify(ioService, times(1)).deleteIfExists(any(org.uberfire.java.nio.file.Path.class)); }
@Override public Path getDirectoryPath() { final Path dir = ioService().get(URI.create("git://repo-test/someDir" + new Random(10L).nextInt())); ioService().deleteIfExists(dir); return dir; }
@Override public Path getTargetPath() { final Path file = ioService().get(URI.create("git://repo-test/myTargetFile" + new Random(10L).nextInt() + ".txt")); ioService().deleteIfExists(file); return file; }
@Override public Path getFilePath() { final Path file = ioService().get(URI.create("git://repo-test/myfile" + new Random(10L).nextInt() + ".txt")); ioService().deleteIfExists(file); return file; }
@Test public void testDeleteDataSetDef() throws Exception { when(ioService.exists(any(Path.class))).thenReturn(true); dataSetDefRegistry.registerDataSetDef(dataSetDef); dataSetDefRegistry.removeDataSetDef(dataSetDef.getUUID()); verify(getIOService(), atLeastOnce()).deleteIfExists(any(Path.class), eq(StandardDeleteOption.NON_EMPTY_DIRECTORIES)); verify(dataSetDefRemovedEvent).fire(any(DataSetDefRemovedEvent.class)); } }
protected Path getDirectoryPath( final String repositoryName ) { final Path dir = ioService().get( URI.create( "git://" + repositoryName + "/_someDir" + seed ) ); ioService().deleteIfExists( dir ); return dir; }
private Path getDirectoryPath(final String repositoryName) { final Path dir = ioService().get(URI.create("git://" + repositoryName + "/_someDir" + seed)); ioService().deleteIfExists(dir); return dir; }
@Test(expected = NoSuchFileException.class) public void deleteNoSuchFileException() { final Path path = getFilePath(); ioService().deleteIfExists(path); ioService().delete(path); }
@Test(expected = NoSuchFileException.class) public void deleteNoSuchFileException() { final Path path = getFilePath(); ioService().deleteIfExists(path); ioService().delete(path); }
@Test(expected = NoSuchFileException.class) public void readAttributesNoSuchFileException() { final Path path = getDirectoryPath().resolveSibling("somethingXXX"); ioService().deleteIfExists(path); ioService().readAttributes(path); } }
@Test(expected = FileAlreadyExistsException.class) public void newByteChannelFileAlreadyExistsException() { final Path path = getFilePath().resolveSibling("alreadyExists.txt"); ioService().deleteIfExists(path); ioService().write(path, "ooooo!"); ioService().newByteChannel(path); }
@Test(expected = FileAlreadyExistsException.class) public void createDirectoryFileAlreadyExistsException() { final Path path = getDirectoryPath().resolveSibling("otherDir"); ioService().deleteIfExists(path); ioService().createDirectory(path); ioService().createDirectory(path); }
@Test(expected = FileAlreadyExistsException.class) public void newByteChannelFileAlreadyExistsException() { final Path path = getFilePath().resolveSibling("alreadyExists.txt"); ioService().deleteIfExists(path); ioService().write(path, "ooooo!"); ioService().newByteChannel(path); }
@Test(expected = FileAlreadyExistsException.class) public void createDirectoriesFileAlreadyExistsException() { final Path path = getDirectoryPath().resolveSibling("otherDir").resolve("innerDir"); ioService().deleteIfExists(path); ioService().createDirectories(path); ioService().createDirectories(path); }
@Test(expected = DirectoryNotEmptyException.class) public void deleteIfExistsDirectoryNotEmptyException() { final Path path = getDirectoryPath().resolveSibling("dirToBugIfExists"); ioService().createDirectories(path); ioService().write(path.resolve("myFile.txt"), "ooooo!"); ioService().deleteIfExists(path); }
@Test(expected = FileAlreadyExistsException.class) public void copyFileAlreadyExistsException() { final Path path = getDirectoryPath().resolveSibling("alreadyExistsTest"); ioService().deleteIfExists(path); ioService().createDirectories(path); ioService().write(path.resolve("myFile.txt"), "ooooo!"); ioService().write(path.resolve("mytarget"), "xooooo!"); ioService().copy(path.resolve("myFile.txt"), path.resolve("mytarget")); }