private void createFile() { ioService.createFile(userNamesPath); }
private void createFile() { ioService.createFile(userNamesPath); }
private void createFile() { ioService.createFile( userNamesPath ); }
@Override public Path createFile(Path path) { return ioService.createFile(path); }
@Override public Path createFile(Path path){ if (!isActive()) { return null; } return getIOService().createFile(path); }
@Override public Path createFile(Path path, FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { if (!authManager.authorize(toResource(path), getUser())) { throw new SecurityException(); } return service.createFile(path, attrs); }
@Override public Path createDirectory(Path dir, FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { if (!authManager.authorize(toResource(dir), getUser())) { throw new SecurityException(); } return service.createFile(dir, attrs); }
@Override public Path createFile(Path path, FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { if (!authManager.authorize(toResource(path), getUser())) { throw new SecurityException(); } return service.createFile(path, attrs); }
@Override public Path createDirectory(Path dir, FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { if (!authManager.authorize(toResource(dir), getUser())) { throw new SecurityException(); } return service.createFile(dir, attrs); }
protected KieModule getModule(final Path path) { //We need to create the project.repositories file first otherwise Module resolution fails final org.uberfire.java.nio.file.Path nioPath = Paths.convert(path); if (!ioService.exists(nioPath)) { ioService.createFile(nioPath); } return resourceResolver.resolveModule(path); } }
@Override public void save( final DynamicMenu plugin ) { final Path pluginPath = convert( plugin.getPath() ); final boolean isNewPlugin = !ioService.exists( pluginPath ); if ( isNewPlugin ) { ioService.createFile( getPluginPath( plugin.getName() ).resolve( plugin.getType().toString().toLowerCase() + ".plugin" ) ); } final Path menuItemsPath = getMenuItemsPath( getPluginPath( plugin.getName() ) ); final StringBuilder sb = new StringBuilder(); for ( DynamicMenuItem item : plugin.getMenuItems() ) { sb.append( item.getActivityId() ).append( " / " ).append( item.getMenuLabel() ).append( "\n" ); } ioService.write( menuItemsPath, sb.toString() ); updatePlugin( pluginPath, plugin.getName(), plugin.getType(), isNewPlugin ); }
@Override public Plugin createNewPlugin( final String pluginName, final PluginType type ) { checkNotEmpty( "pluginName", pluginName ); final Path pluginRoot = getPluginPath( pluginName ); if ( ioService.exists( pluginRoot ) ) { throw new PluginAlreadyExists(); } final Path pluginPath = ioService.createFile( pluginRoot.resolve( type.toString().toLowerCase() + ".plugin" ) ); updatePlugin( pluginPath, pluginName, type, true ); return new Plugin( pluginName, type, convert( pluginPath ) ); }
final org.uberfire.java.nio.file.Path nioPath = Paths.convert( resource ); if ( create ) { ioService.createFile( nioPath );
@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)); } }
@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)); } }
@Override public void save( final PluginSimpleContent plugin ) { final Path pluginPath = convert( plugin.getPath() ); final boolean isNewPlugin = !ioService.exists( pluginPath ); if ( isNewPlugin ) { ioService.createFile( getPluginPath( plugin.getName() ).resolve( plugin.getType().toString().toLowerCase() + ".plugin" ) ); } saveCodeMap( plugin.getName(), plugin.getCodeMap() ); if ( plugin.getTemplate() != null ) { ioService.write( getTemplatePath( getPluginPath( plugin.getName() ) ), plugin.getTemplate() ); } if ( plugin.getCss() != null ) { ioService.write( getCssPath( getPluginPath( plugin.getName() ) ), plugin.getCss() ); } try { if ( plugin.getFrameworks() != null && !plugin.getFrameworks().isEmpty() ) { final Framework fm = plugin.getFrameworks().iterator().next(); ioService.createFile( getDependencyPath( getPluginPath( plugin.getName() ), fm ) ); } } catch ( final FileAlreadyExistsException ex ) { } createRegistry( plugin ); updatePlugin( pluginPath, plugin.getName(), plugin.getType(), isNewPlugin ); }
@Test public void testReadAllStringFromEmptyFile() { final Path filePath = getFilePath(); ioService().createFile(filePath); String content = ioService().readAllString(filePath); assertEquals("", content); }
@Test public void testReadAllStringFromEmptyFile() { final Path filePath = getFilePath(); ioService().createFile(filePath); String content = ioService().readAllString(filePath); assertEquals("", content); }
@Test public void testReadAllStringFromExistentFile() { final Path filePath = getFilePath(); ioService().createFile(filePath); ioService().write(filePath, "text"); String content = ioService().readAllString(filePath); assertEquals("text", content); }
@Test public void testReadAllStringFromExistentFile() { final Path filePath = getFilePath(); ioService().createFile(filePath); ioService().write(filePath, "text"); String content = ioService().readAllString(filePath); assertEquals("text", content); }