Refine search
@Override public Form getFormByPath( String ctxUID, String formPath ) { FormEditorContext editorContext = formEditorContextManager.getRootEditorContext( ctxUID ); if ( editorContext != null ) { try { Path currentForm = Paths.convert( ioService.get( new URI( editorContext.getPath() ) ) ); org.uberfire.java.nio.file.Path path = Paths.convert( currentForm ).getParent().resolve( formPath ); String xml = ioService.readAllString( path ).trim(); return formSerializationManager.loadFormFromXML( xml, path.toUri().toString() ); } catch ( Exception e ) { log.warn( "Error getting form {} from context {}: {}", formPath, ctxUID, e ); } } return null; }
public Path getPath(Path path, String version) throws URISyntaxException { String authority = path.toUri().getAuthority(); // master@uf-playground authority = version + authority.substring(authority.indexOf("@")); String scheme = path.getFileSystem().provider().getScheme(); // git String rawPath = path.toUri().getRawPath(); // projectname/org/something/file.txt String uri = scheme + "://" + authority + rawPath; return ioService.get(new URI(uri)); }
public static FileSystem convert(final org.uberfire.java.nio.file.FileSystem fs) { if (!cache.containsKey(fs)) { final Map<String, String> roots = new HashMap<>(); for (final org.uberfire.java.nio.file.Path root : fs.getRootDirectories()) { roots.put(root.toUri().toString(), root.getFileName() == null ? "/" : root.getFileName().toString()); } cache.put(fs, FileSystemFactory.newFS(roots, fs.supportedFileAttributeViews())); } return cache.get(fs); }
public static Path dot(final Path path) { if (path.getFileName() == null) { return path.resolve(".root"); } return path.resolveSibling("." + path.getFileName()); }
public static Path undot(final Path path) { if (!path.getFileName().toString().startsWith(".")) { return path; } return path.resolveSibling(path.getFileName().toString().substring(1)); }
@Test public void addNullDepTest() { boolean result = editor.addDependency(null, PathFactory.newPath(tmp.toAbsolutePath().toString() + File.separator + POM, tmp.toUri().toString() + File.separator + POM)); assertThat(result).isFalse(); }
@Before public void setup() throws Exception { rootUri = new URI(ROOT_URI); when(fileSystem.supportedFileAttributeViews()).thenReturn(FS_ATTRIBUTES); when(rootPath.toUri()).thenReturn(rootUri); when(rootPath.getFileSystem()).thenReturn(fileSystem); doAnswer((Answer<org.uberfire.java.nio.file.Path>) invocationOnMock -> { final URI arg = (URI) invocationOnMock.getArguments()[0]; return arg.toURL().toString().equals(ROOT_URI) ? rootPath : null; }).when(ioService).get(any(URI.class)); tested = new VFSServicesServerImpl(ioService); }
public void configurePackage(@Observes NewPackageEvent pkg) { if (isCaseProject(Paths.convert(pkg.getPackage().getModuleRootPath()))) { String resourcesPathStr = Paths.convert(pkg.getPackage().getPackageMainResourcesPath()).toUri().toString(); String separator = Paths.convert(pkg.getPackage().getModuleRootPath()).getFileSystem().getSeparator(); Path resourcesPath = ioService.get(URI.create(resourcesPathStr + separator + WORK_DEFINITION_FILE)); addWorkDefinitions(resourcesPath); } }
public void addWorkDefinitionsFileToProjectResources(KieModule kieModule, WorkspaceProject project, String separator) { String resourcesPathStr = Paths.convert(kieModule.getKModuleXMLPath()).getParent().getParent().toUri().toString(); Path widFilePath = ioService.get(URI.create(resourcesPathStr + separator + WORK_DEFINITION_FILE)); logger.debug("Adding WorkDefinition.wid file to resources folder {} of the project {}", widFilePath, project); addWorkDefinitions(widFilePath); }
@Test public void testGetComplexPathFileSystemNameIncludedInPath() { final URI newRepo = URI.create("default://default-new-complex-get-repo-name"); FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("default://origin/master@default-new-complex-get-repo-name/home/default-new-complex-get-repo-name/somefolder")); assertThat(path).isNotNull(); assertThat(path.getRoot().toString()).isEqualTo("/"); assertThat(path.toString()).isEqualTo("/home/default-new-complex-get-repo-name/somefolder"); assertThat(path.toUri().getScheme()).isEqualTo("default"); fs.close(); } }
protected Form findForm( org.uberfire.java.nio.file.Path path ) throws Exception { String xml = ioService.readAllString( path ).trim(); return formSerializationManager.loadFormFromXML( xml, path.toUri().toString() ); } }
protected void assertContains(final Iterable<KObject> results, final Path path) { for (KObject kObject : results) { final String key = kObject.getKey(); final String fileName = path.getFileName().toString(); if (key.endsWith(fileName)) { return; } } fail("Results do not contain expected Path '" + path.toUri().toString()); }
@Before public void setUp() throws Exception { ArgumentCaptor<DirectoryStream.Filter> filter = ArgumentCaptor.forClass(DirectoryStream.Filter.class); when(ioService.newDirectoryStream(any(), filter.capture())).thenReturn(directoryStream); when(directoryStream.spliterator()).thenReturn(Arrays.asList(fsPath).spliterator()); when(projectPath.toURI()).thenReturn(DIR_URI); when(fsPath.getFileName()).thenReturn(fileName); when(fsPath.toUri()).thenReturn(new URI(FILE_URI)); when(fsPath.getFileSystem()).thenReturn(fs); when(fileName.toString()).thenReturn(FILE_NAME); tested = new BPMNDiagramServiceImpl(ioService); }
@Test public void validateGetPath() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final URI uri = URI.create("file:///path/to/file.txt"); final Path path = fsProvider.getPath(uri); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.getFileSystem()).isEqualTo(fsProvider.getFileSystem(uri)); assertThat(path.getFileSystem().provider()).isEqualTo(fsProvider); assertThat(path.toString()).isEqualTo("/path/to/file.txt"); }
@Override public URI toUri() throws IOException, SecurityException { if (!isAbsolute()) { return toAbsolutePath().toUri(); } if (fs.provider().isDefault() && !isRealPath) { return URI.create("default://" + host + toURIString()); } return URI.create(fs.provider().getScheme() + "://" + host + toURIString()); }
@Test public void checkGetFileStore() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "/path/to/file.txt", false); assertThat(fsProvider.getFileStore(path)).isNotNull(); assertThat(fsProvider.getFileSystem(path.toUri()).getFileStores()).isNotNull().contains(fsProvider.getFileStore(path)); }
@Test public void testCreate() throws Exception { final Path path = testFileSystem.createTempDirectory("/MyTestProject"); service.create(path, new POM()); ArgumentCaptor<org.uberfire.java.nio.file.Path> pathArgumentCaptor = ArgumentCaptor.forClass(org.uberfire.java.nio.file.Path.class); ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.forClass(String.class); verify(ioServiceSpy).write(pathArgumentCaptor.capture(), stringArgumentCaptor.capture()); assertEquals(pathArgumentCaptor.getValue().toUri().toString(), path.toURI() + "/pom.xml"); String pomXML = stringArgumentCaptor.getValue(); assertTrue(pomXML.contains("<id>guvnor-m2-repo</id>")); } }