Refine search![Refine arrow](//d16xvuom8mr9m8.cloudfront.net/code/public/images/refine-arrow.226bef887e7b1c430d6d498717d9d561.svg)
protected void store(org.uberfire.java.nio.file.Path path, byte[] content) { try { ioService.startBatch(path.getFileSystem()); ioService.write(path, content); } finally { ioService.endBatch(); } }
String getItemsMetadata(Path timeLineDir, String originalFilename) { String metadataFileName = originalFilename + Constants.METADATA; Path timelineFile = timeLineDir.resolve(metadataFileName); if (ioService.exists(timelineFile)) { String itemsMetadata = ioService.readAllString(timelineFile); return itemsMetadata; } return "-1"; }
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); }
protected void delete(org.uberfire.java.nio.file.Path path) { try { ioService.startBatch(path.getFileSystem()); ioService.deleteIfExists(path); } finally { ioService.endBatch(); } }
@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 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)); }
@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); }
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() ); } }
@BeforeClass public static void setup() throws IOException { final String path = createTempDirectory().getAbsolutePath(); System.setProperty( "org.uberfire.nio.git.dir", path ); System.out.println( ".niogit: " + path ); final URI newRepo = URI.create( "git://temp-repo-test" ); try { ioService().newFileSystem( newRepo, new HashMap<String, Object>() ); } catch ( final Exception ex ) { } }
private void removeSpaceDirectory(final Space space) { final URI configPathURI = URI.create(SpacesAPI.resolveConfigFileSystemPath(SpacesAPI.Scheme.DEFAULT, space.getName())); final Path configPath = ioService.get(configPathURI); final JGitPathImpl configGitPath = (JGitPathImpl) configPath; final File spacePath = configGitPath.getFileSystem().getGit().getRepository().getDirectory().getParentFile().getParentFile(); ioService.delete(configPath.getFileSystem().getPath("")); spacePath.delete(); }
private void initFileSystem() { try { fileSystem = ioService.newFileSystem(URI.create(VFS_ROOT_PATH), new Maps.Builder<String, Object>() .put("init", Boolean.TRUE) .put("internal", Boolean.TRUE) .build()); } catch (FileSystemAlreadyExistsException e) { fileSystem = ioService.getFileSystem(URI.create(VFS_ROOT_PATH)); } this.root = fileSystem.getRootDirectories().iterator().next(); } }
@Test public void fsUtilsSanityCheck() throws IOException, InterruptedException { IOService ioService = fileSystemTestingUtils.getIoService(); Path init = ioService.get(URI.create("git://amend-repo-test/init.file")); String expected = "setupFS!"; ioService.write(init, expected); assertEquals(expected, ioService.readAllString(init)); } }
@Test public void testValidateWhenTheresNoProject() throws Exception { final URI originRepo = URI.create("git://repo"); final FileSystem origin = fileSystemTestingUtils.getIoService().newFileSystem(originRepo, Collections.singletonMap("init", Boolean.TRUE)); Path path = Paths.convert(origin.getPath("/META-INF/beans.xml")); URL urlToValidate = this.getClass().getResource("/META-INF/beans.xml"); List<ValidationMessage> errors = validator.validate(path, Resources.toString(urlToValidate, Charsets.UTF_8)); assertTrue(errors.isEmpty()); }
@Test public void releaseLockUpdatesSession() { lockService.acquireLock(path); when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true); when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn("testUser"); lockService.releaseLock(path); verify(httpSession).setAttribute(eq(VFSLockServiceImpl.LOCK_SESSION_ATTRIBUTE_NAME), any(Set.class)); }
private IOService mockIoService(final FileSystem fileSystem) { final IOService ioService = spy(fileSystemTestingUtils.getIoService()); doNothing().when(ioService).startBatch(any(FileSystem.class)); doNothing().when(ioService).endBatch(); doReturn(fileSystem).when(ioService).newFileSystem(any(URI.class), anyMap()); return ioService; } }
@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")); }
@PostConstruct public void setup() { log.info( "mailbox service is up" ); try { ioService.startBatch( bootstrapFS.getRootDirectories().iterator().next().getFileSystem() ); processOutgoing(); } finally { ioService.endBatch(); } }