Java Code Examples for org.apache.commons.vfs2.FileObject#refresh()
The following examples show how to use
org.apache.commons.vfs2.FileObject#refresh() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FTPRemoteDownloadSourceDelegate.java From datacollector with Apache License 2.0 | 6 votes |
@Override public String archive(String fromPath) throws IOException { if (archiveURI == null) { throw new IOException("No archive directory defined - cannot archive"); } String toPath = archiveURI.toString() + (fromPath.startsWith("/") ? fromPath.substring(1) : fromPath); FileObject toFile = VFS.getManager().resolveFile(toPath, archiveOptions); toFile.refresh(); // Create the toPath's parent dir(s) if they don't exist toFile.getParent().createFolder(); resolveChild(fromPath).moveTo(toFile); toFile.close(); return toPath; }
Example 2
Source File: GoogleDriveFileSystem.java From hop with Apache License 2.0 | 5 votes |
private synchronized FileObject processFile( FileName name, boolean useCache ) throws FileSystemException { if ( !super.getRootName().getRootURI().equals( name.getRootURI() ) ) { throw new FileSystemException( "vfs.provider/mismatched-fs-for-name.error", new Object[] { name, super.getRootName(), name.getRootURI() } ); } else { FileObject file; if ( useCache ) { file = super.getFileFromCache( name ); } else { file = null; } if ( file == null ) { try { file = this.createFile( (AbstractFileName) name ); } catch ( Exception e ) { throw new FileSystemException( "Unable to get Google Drive file object for '"+name+"'", e ); } file = super.decorateFileObject( file ); if ( useCache ) { super.putFileToCache( file ); } } if ( super.getFileSystemManager().getCacheStrategy().equals( CacheStrategy.ON_RESOLVE ) ) { file.refresh(); } return file; } }
Example 3
Source File: LoadingInfo.java From otroslogviewer with Apache License 2.0 | 5 votes |
public LoadingInfo(FileObject fileObject, boolean tailing, OpenMode openMode) throws IOException { this.fileObject = fileObject; this.tailing = tailing; friendlyUrl = fileObject.getName().getFriendlyURI(); fileObject.refresh(); InputStream inputStream = fileObject.getContent().getInputStream(); byte[] probe = loadProbe(inputStream, 10000); gzipped = checkIfIsGzipped(probe, probe.length); inputStreamBufferedStart = gzipped ? ungzip(probe) : probe; if (openMode == FROM_START || gzipped) { PushbackInputStream pushBackInputStream = new PushbackInputStream(inputStream, probe.length + 1); // +1 to support empty files pushBackInputStream.unread(probe); observableInputStreamImpl = new ObservableInputStreamImpl(pushBackInputStream); contentInputStream = gzipped ? new GZIPInputStream(observableInputStreamImpl) : observableInputStreamImpl; } else { RandomAccessContent randomAccessContent = fileObject.getContent().getRandomAccessContent(READ); randomAccessContent.seek(randomAccessContent.length()); observableInputStreamImpl = new ObservableInputStreamImpl(randomAccessContent.getInputStream()); contentInputStream = observableInputStreamImpl; } if (fileObject.getType().hasContent()) { lastFileSize = fileObject.getContent().getSize(); } }
Example 4
Source File: AbstractFileSystem.java From commons-vfs with Apache License 2.0 | 5 votes |
private synchronized FileObject resolveFile(final FileName name, final boolean useCache) throws FileSystemException { if (!rootName.getRootURI().equals(name.getRootURI())) { throw new FileSystemException("vfs.provider/mismatched-fs-for-name.error", name, rootName, name.getRootURI()); } // [email protected] ==> use getFileFromCache FileObject file; if (useCache) { file = getFileFromCache(name); } else { file = null; } if (file == null) { try { file = createFile((AbstractFileName) name); } catch (final Exception e) { throw new FileSystemException("vfs.provider/resolve-file.error", name, e); } file = decorateFileObject(file); // [email protected] ==> use putFileToCache if (useCache) { putFileToCache(file); } } /** * resync the file information if requested */ if (getFileSystemManager().getCacheStrategy().equals(CacheStrategy.ON_RESOLVE)) { file.refresh(); } return file; }
Example 5
Source File: ProviderCacheStrategyTests.java From commons-vfs with Apache License 2.0 | 5 votes |
/** * Test the manual cache strategy */ public void testManualCache() throws Exception { final FileObject scratchFolder = getWriteFolder(); if (FileObjectUtils.isInstanceOf(getBaseFolder(), RamFileObject.class) || scratchFolder.getFileSystem() instanceof VirtualFileSystem) { // cant check ram filesystem as every manager holds its own ram filesystem data return; } scratchFolder.delete(Selectors.EXCLUDE_SELF); final DefaultFileSystemManager fs = createManager(); fs.setCacheStrategy(CacheStrategy.MANUAL); fs.init(); final FileObject foBase2 = getBaseTestFolder(fs); final FileObject cachedFolder = foBase2.resolveFile(scratchFolder.getName().getPath()); FileObject[] fos = cachedFolder.getChildren(); assertContainsNot(fos, "file1.txt"); scratchFolder.resolveFile("file1.txt").createFile(); fos = cachedFolder.getChildren(); assertContainsNot(fos, "file1.txt"); cachedFolder.refresh(); fos = cachedFolder.getChildren(); assertContains(fos, "file1.txt"); }
Example 6
Source File: GoogleDriveFileSystem.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private synchronized FileObject processFile( FileName name, boolean useCache ) throws FileSystemException { if ( !super.getRootName().getRootURI().equals( name.getRootURI() ) ) { throw new FileSystemException( "vfs.provider/mismatched-fs-for-name.error", new Object[] { name, super.getRootName(), name.getRootURI() } ); } else { FileObject file; if ( useCache ) { file = super.getFileFromCache( name ); } else { file = null; } if ( file == null ) { try { file = this.createFile( (AbstractFileName) name ); } catch ( Exception var5 ) { return null; } file = super.decorateFileObject( file ); if ( useCache ) { super.putFileToCache( file ); } } if ( super.getFileSystemManager().getCacheStrategy().equals( CacheStrategy.ON_RESOLVE ) ) { file.refresh(); } return file; } }