protected boolean hasKModule(final org.uberfire.java.nio.file.Path path) { final org.uberfire.java.nio.file.Path kmodulePath = path.resolve(KMODULE_PATH); return Files.exists(kmodulePath); } }
@Test(expected = FileAlreadyExistsException.class) public void createDirectoriesFileAlreadyExistsException() { final Path path = getDirectoryPath().resolveSibling("otherDir").resolve("innerDir"); ioService().deleteIfExists(path); ioService().createDirectories(path); ioService().createDirectories(path); }
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)); }
@Test(expected = DirectoryNotEmptyException.class) public void deleteDirectoryNotEmptyException() { final Path path = getDirectoryPath().resolveSibling("dirToBug"); ioService().createDirectories(path); ioService().write(path.resolve("myFile.txt"), "ooooo!"); ioService().delete(path); }
private void setUpDirectory(org.uberfire.java.nio.file.Path directory, String pathAsText, org.uberfire.java.nio.file.Path path) { when( directory.resolve(pathAsText) ).thenReturn( path ); }
public Optional<Path> resolveResource(final Metadata metadata, final Path resource, final String fileName) { Collection<Path> paths = resolveResources(ioService.get(resource.toURI()), resolveGlobalPath(metadata), resolveResourcesPath(metadata), p -> p.resolve(fileName)); return paths.isEmpty() ? Optional.empty() : Optional.of(paths.iterator().next()); }
private InputStream doLoadMetadataStreamByDiagramPath(final Path dPath) { org.uberfire.java.nio.file.Path path = getDiagramsPath().resolve(getMetadataFileName(dPath.getFileName())); if (null != path) { try { return loadPath(path); } catch (Exception e) { LOG.warn("Cannot load metadata for [{}].", dPath.toString(), e); } } return null; }
@Override public Path resolveSibling(final Path other) { checkNotNull("other", other); final Path parent = this.getParent(); if (parent == null || other.isAbsolute()) { return other; } return parent.resolve(other); }
private Path prepareTargetPath(String id, String suffix) { when(registryHelper.md5Hex(id)).thenReturn(ID_MD5); String expectedPath = ID_MD5 + suffix; Path targetPath = mock(Path.class); when(registryRoot.resolve(expectedPath)).thenReturn(targetPath); return targetPath; } }
private Path loadXLSFile(final Path basePath, final String fileName) throws IOException { final Path path = basePath.resolve(fileName); final InputStream is = this.getClass().getResourceAsStream(fileName); final OutputStream os = ioService().newOutputStream(path); IOUtils.copy(is, os); os.flush(); os.close(); return path; } }
private Path loadXLSFile(final Path basePath, final String fileName) throws IOException { final Path path = basePath.resolve(fileName); final InputStream is = this.getClass().getResourceAsStream(fileName); final OutputStream os = ioService().newOutputStream(path); IOUtils.copy(is, os); os.flush(); os.close(); return path; } }
Integer getLastFileIndex( Path timelineDir ) { Path resolve = timelineDir.resolve( Constants.LAST_FILE_INDEX.name() ); if ( !getIoService().exists( resolve ) ) { return -1; } String index = getIoService().readAllString( resolve ); Integer lastIndex = Integer.valueOf( index ); return lastIndex; }
private Path writeFile(final String fileName) { final Path path = getBasePath(this.getClass().getSimpleName()).resolve(fileName); ioService().write(path, "content", Collections.<OpenOption>emptySet()); return path; } }
@Override public Path getTargetPath() { try { final File dir = createTempDirectory(); return ioService().get(dir.toURI()).resolve("myTargetFile.txt"); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public Path getDirectoryPath() { try { final File dir = createTempDirectory(); return ioService().get(dir.toURI()).resolve("myDir"); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public Path getComposedDirectoryPath() { try { final File dir = createTempDirectory(); return ioService().get(dir.toURI()).resolve("path/to/myDir"); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public Package resolveDefaultWorkspacePackage(final Module module) { final Path moduleRootPath = module.getRootPath(); final GAV gav = module.getPom().getGav(); final String defaultWorkspacePackagePath = getDefaultWorkspacePath(gav); final org.uberfire.java.nio.file.Path defaultWorkspacePath = Paths.convert(moduleRootPath).resolve(MAIN_RESOURCES_PATH + "/" + defaultWorkspacePackagePath); return resolvePackage(Paths.convert(defaultWorkspacePath)); }
protected void addTestFile(final String moduleName, final String pathToFile) throws IOException { final Path path = basePath.resolve(moduleName + "/" + pathToFile); final String text = loadText(pathToFile); ioService().write(path, text); }
private void updateLastIndexFile( Path directory, String lastIndex ) { Path lastFileIndex = directory.resolve( Constants.LAST_FILE_INDEX.name() ); try { getIoService().startBatch( lastFileIndex.getFileSystem() ); getIoService().write( lastFileIndex, lastIndex ); } finally { getIoService().endBatch(); } }
@Override protected FormDefinition createModelFormDefinition(String modelType, GenerationContext<Path> context) { FormDefinition form = super.createModelFormDefinition(modelType, context); org.uberfire.java.nio.file.Path path = Paths.convert(context.getSource()).getParent().resolve(form.getName() + "." + FormResourceTypeDefinition.EXTENSION); ioService.write(path, formSerializer.serialize(form), commentedOptionFactory.makeCommentedOption("Automatically generated form")); return form; }