void startBatch(final Collection<Path> paths) { if (paths.size() > 1) { ioService.startBatch(Paths.convert(paths.iterator().next()).getFileSystem()); } }
private Optional<Git> getGit(final CompilationRequest req) { final Path projectPath = req.getInfo().getPrjPath(); if (projectPath.getFileSystem() instanceof JGitFileSystem) { final JGitFileSystem fs = (JGitFileSystem) projectPath.getFileSystem(); if (!gitMap.containsKey(fs)) { gitMap.put(fs, JGitUtils.tempClone(fs, req.getRequestUUID())); } return Optional.of(gitMap.get(fs)); } return Optional.empty(); }
private void saveUserPreferences(final UserPreference preferences, final Path path) { try { ioServiceConfig.startBatch(path.getFileSystem()); ioServiceConfig.write(path, xs.toXML(preferences)); } catch (final Exception e) { throw new RuntimeException(e); } finally { ioServiceConfig.endBatch(); } }
@Override public String getClusterId() { final String fsId = ((FileSystemId) path.getFileSystem()).id(); final String segmentId = ((SegmentedPath) path).getSegmentId(); return fsId + File.separator + segmentId; }
@PostConstruct public void setup() { log.info( "mailbox service is up" ); try { ioService.startBatch( bootstrapFS.getRootDirectories().iterator().next().getFileSystem() ); processOutgoing(); } finally { ioService.endBatch(); } }
protected void writeFile(final IOService ioService, final Path path, final FileItem uploadedItem) throws IOException { try { ioService.startBatch(path.getFileSystem()); ioService.write(path, IOUtils.toByteArray(uploadedItem.getInputStream())); } finally { uploadedItem.getInputStream().close(); ioService.endBatch(); } }
Repository getInboxEntryRepository( InboxEntry inboxEntry ) { try { final Path path = Paths.get( inboxEntry.getItemPath() ); final FileSystem fileSystem = path.getFileSystem(); return configuredRepositories.getRepositoryByRepositoryFileSystem( fileSystem ); } catch ( FileSystemNotFoundException exception ) { return null; } }
protected void delete(org.uberfire.java.nio.file.Path path) { try { ioService.startBatch(path.getFileSystem()); ioService.deleteIfExists(path); } finally { ioService.endBatch(); } }
protected void store(org.uberfire.java.nio.file.Path path, byte[] content) { try { ioService.startBatch(path.getFileSystem()); ioService.write(path, content); } finally { ioService.endBatch(); } }
@Before public void setup() { when(ioService.get(any(URI.class))).thenReturn(path); when(path.getFileSystem()).thenReturn(fileSystem); }
@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); }
@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"); }
@Test public void testDeleteBatch() { when(path.getFileSystem()).thenReturn(fileSystem); registryHelper.deleteBatch(path); verify(ioService, times(1)).startBatch(fileSystem); verify(ioService, times(1)).deleteIfExists(path); verify(ioService, times(1)).endBatch(); }
@Test public void checkRootPath() { URI composedName = URI.create("git://dora-repo/subdir1"); FileSystem fsComposedName = provider.newFileSystem(composedName, EMPTY_ENV); Path path = provider.getPath(URI.create("git://dora-repo/subdir1/file.txt")); Path path1 = provider.getPath(URI.create("git://origin/bla@dora-repo/subdir1/file2.txt")); assertEquals(fsComposedName, path.getRoot().getFileSystem()); assertEquals(fsComposedName, path1.getRoot().getFileSystem()); }
@Test public void simpleStateTest() { assertThat(fsProvider).isNotNull(); assertThat(fsProvider.getScheme()).isEqualTo("file"); final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")), "c:\\path\\to\\file.txt", false); assertThat(path.getFileSystem()).isInstanceOf(SimpleWindowsFileSystem.class); }
private void writeItems( final Path timeLineFile, final List<SocialActivitiesEvent> newEvents ) { SocialFile socialFile = new SocialFile( timeLineFile, ioService, gson ); try { ioService.startBatch( timeLineFile.getFileSystem() ); socialFile.write( newEvents ); } catch ( IOException e ) { throw new ErrorAccessingTimeline( e ); } finally { ioService.endBatch(); } }
public void recordUserEditEvent( @Observes final ResourceUpdatedEvent event ) { checkNotNull( "event", event ); try { ioService.startBatch( bootstrapFS.getRootDirectories().iterator().next().getFileSystem() ); recordUserEditEvent( event.getPath().toURI(), event.getPath().getFileName(), event.getSessionInfo().getIdentity().getIdentifier() ); } finally { ioService.endBatch(); } }
private void setUp(String path) throws IOException, InterruptedException { ioService.startBatch(basePath.getFileSystem()); //Add test files for (String fileName : FILE_NAMES) { addTestFile(path, fileName); } ioService.endBatch(); Thread.sleep(5000); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index }
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); } }
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(); } }