@Override public Path createDirectory(final Path dir, final Map<String, ?> attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { return Paths.convert(ioService.createDirectory(Paths.convert(dir), attrs)); }
/** * Ensure that an expected directory under the VFS registries host directory exists. * @param directory a directory name. * @return the path to the directory. */ public Path ensureDirectory(final String directory) { Path directoryPath = provisioningRootPath.resolve(directory); if (!ioService.exists(directoryPath)) { directoryPath = ioService.createDirectory(directoryPath); } return directoryPath; }
private void createMavenDirectories() { ioService.createDirectory(Paths.convert(moduleRoot).resolve(ModuleResourcePaths.MAIN_SRC_PATH)); ioService.createDirectory(Paths.convert(moduleRoot).resolve(ModuleResourcePaths.MAIN_RESOURCES_PATH)); ioService.createDirectory(Paths.convert(moduleRoot).resolve(ModuleResourcePaths.TEST_SRC_PATH)); ioService.createDirectory(Paths.convert(moduleRoot).resolve(ModuleResourcePaths.TEST_RESOURCES_PATH)); }
@Override public Path createDirectory(final Path dir) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { return Paths.convert(ioService.createDirectory(Paths.convert(dir))); }
private org.uberfire.java.nio.file.Path ensureModuleJavaPath(org.uberfire.java.nio.file.Path modulePath) { org.uberfire.java.nio.file.Path javaPath = modulePath.resolve("src"); if (!ioService.exists(javaPath)) { javaPath = ioService.createDirectory(javaPath); } javaPath = javaPath.resolve("main"); if (!ioService.exists(javaPath)) { javaPath = ioService.createDirectory(javaPath); } javaPath = javaPath.resolve("java"); if (!ioService.exists(javaPath)) { javaPath = ioService.createDirectory(javaPath); } return javaPath; } }
@Override public Path createDirectory(Path dir, Map<String, ?> attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { if (!authManager.authorize(toResource(dir), getUser())) { throw new SecurityException(); } return service.createDirectory(dir, attrs); }
@Override public Path createDirectory(Path dir, Map<String, ?> attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { if (!authManager.authorize(toResource(dir), getUser())) { throw new SecurityException(); } return service.createDirectory(dir, attrs); }
@Override public Path createDirectory(Path path) { checkNotNull( "path", path ); return ioService.createDirectory(path); }
@Override public Path createDirectory(Path path){ if (!isActive()) { return null; } checkNotNull( "path", path ); return getIOService().createDirectory(path); }
@Test @SuppressWarnings("unchecked") public void testCreateDirectoryWithAttributes() { final Map attributes = mock(Map.class); tested.createDirectory(ROOT_PATH, attributes); verify(ioService, times(1)) .createDirectory(any(org.uberfire.java.nio.file.Path.class), eq(attributes)); }
@Test @SuppressWarnings("unchecked") public void testCreateDirectoryWithAttributes() { final Map attributes = mock(Map.class); tested.createDirectory(ROOT_PATH, attributes); verify(ioService, times(1)) .createDirectory(any(org.uberfire.java.nio.file.Path.class), eq(attributes)); }
@Test public void testCreateDirectory() { tested.createDirectory(ROOT_PATH); verify(ioService, times(1)).createDirectory(any(org.uberfire.java.nio.file.Path.class)); }
@Test public void testCreateDirectory() { tested.createDirectory(ROOT_PATH); verify(ioService, times(1)).createDirectory(any(org.uberfire.java.nio.file.Path.class)); }
@Test public void testEnsureDirectoryWhenDirectoryNotExists() { Path path = mock(Path.class); Path createdPath = mock(Path.class); when(provisioningPath.resolve(DIRECTORY_NAME)).thenReturn(path); when(ioService.exists(path)).thenReturn(false); when(ioService.createDirectory(path)).thenReturn(createdPath); Path result = registryHelper.ensureDirectory(DIRECTORY_NAME); verify(provisioningPath, times(1)).resolve(DIRECTORY_NAME); verify(ioService, times(1)).createDirectory(path); assertEquals(createdPath, result); }
@Test public void testEnsureDirectoryWhenDirectoryNotExists() { Path path = mock(Path.class); Path createdPath = mock(Path.class); when(provisioningPath.resolve(DIRECTORY_NAME)).thenReturn(path); when(ioService.exists(path)).thenReturn(false); when(ioService.createDirectory(path)).thenReturn(createdPath); Path result = registryHelper.ensureDirectory(DIRECTORY_NAME); verify(provisioningPath, times(1)).resolve(DIRECTORY_NAME); verify(ioService, times(1)).createDirectory(path); assertEquals(createdPath, result); }
@Test public void testEnsureDirectoryWhenDirectoryExists() { Path path = mock(Path.class); when(provisioningPath.resolve(DIRECTORY_NAME)).thenReturn(path); when(ioService.exists(path)).thenReturn(true); Path result = registryHelper.ensureDirectory(DIRECTORY_NAME); verify(provisioningPath, times(1)).resolve(DIRECTORY_NAME); verify(ioService, never()).createDirectory(path); assertEquals(path, result); }
@Test public void testEnsureDirectoryWhenDirectoryExists() { Path path = mock(Path.class); when(provisioningPath.resolve(DIRECTORY_NAME)).thenReturn(path); when(ioService.exists(path)).thenReturn(true); Path result = registryHelper.ensureDirectory(DIRECTORY_NAME); verify(provisioningPath, times(1)).resolve(DIRECTORY_NAME); verify(ioService, never()).createDirectory(path); assertEquals(path, result); }
@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 createDirectoryFileAlreadyExistsException() { final Path path = getDirectoryPath().resolveSibling("otherDir"); ioService().deleteIfExists(path); ioService().createDirectory(path); ioService().createDirectory(path); }
@Test public void withExistingBranch() throws Exception { final org.uberfire.java.nio.file.Path nioFrom = fileSystemTestingUtils.getIoService().get(URI.create(PATH_PREFIX + "from")); final Path from = Paths.convert(nioFrom); fileSystemTestingUtils.getIoService().createDirectory(fileSystemTestingUtils.getIoService().get(URI.create(PATH_PREFIX + "from/sub1"))); fileSystemTestingUtils.getIoService().createDirectory(fileSystemTestingUtils.getIoService().get(URI.create(PATH_PREFIX + "from/sub2"))); fileSystemTestingUtils.getIoService().createFile(fileSystemTestingUtils.getIoService().get(URI.create(PATH_PREFIX + "from/sub1/file1.txt"))); fileSystemTestingUtils.getIoService().createFile(fileSystemTestingUtils.getIoService().get(URI.create(PATH_PREFIX + "from/sub1/file2.txt"))); fileSystemTestingUtils.getIoService().createFile(fileSystemTestingUtils.getIoService().get(URI.create(PATH_PREFIX + "from/sub2/file3.txt"))); final org.uberfire.java.nio.file.Path nioTo = fileSystemTestingUtils.getIoService().get(URI.create(PATH_PREFIX + "to")); final Path to = Paths.convert(nioTo); fileSystemTestingUtils.getIoService().createDirectory(nioTo); doReturn(mock(Repository.class)).when(repositoryService).getRepository(to); copier.copy(from, to); verify(ioService).startBatch(fileSystemTestingUtils.getFileSystem()); verify(ioService).endBatch(); verify(newBranchEventEvent, never()).fire(any(NewBranchEvent.class)); } }