/** * Prepare file-dependent data for fill additional fields. */ protected void fillFileAdditionalFields( D data, FileObject file ) throws FileSystemException { data.shortFilename = file.getName().getBaseName(); data.path = KettleVFS.getFilename( file.getParent() ); data.hidden = file.isHidden(); data.extension = file.getName().getExtension(); data.uriName = file.getName().getURI(); data.rootUriName = file.getName().getRootURI(); if ( file.getType().hasContent() ) { data.lastModificationDateTime = new Date( file.getContent().getLastModifiedTime() ); data.size = file.getContent().getSize(); } else { data.lastModificationDateTime = null; data.size = null; } } }
@Override protected InputStream doGetInputStream() throws Exception { // VFS-210: ram allows to gather an input stream even from a directory. So we need to check the type anyway. if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return new ByteArrayInputStream(this.data.getContent()); }
@Override protected InputStream doGetInputStream() throws Exception { // VFS-210: ram allows to gather an input stream even from a directory. So we need to check the type anyway. if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return new ByteArrayInputStream(this.data.getContent()); }
@Override protected InputStream doGetInputStream() throws Exception { // VFS-210: ram allows to gather an input stream even from a directory. So we need to check the type anyway. if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return new ByteArrayInputStream(this.data.getContent()); }
@Override protected InputStream doGetInputStream() throws Exception { // VFS-210: ram allows to gather an input stream even from a directory. So we need to check the type anyway. if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return new ByteArrayInputStream(this.data.getContent()); }
@Override protected InputStream doGetInputStream() throws Exception { if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return archive.getInputStream(header); }
/** * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns * {@link FileType#FILE}. The input stream returned by this method is guaranteed to be closed before this method is * called again. */ @Override protected InputStream doGetInputStream() throws Exception { // VFS-210: zip allows to gather an input stream even from a directory and will // return -1 on the first read. getType should not be expensive and keeps the tests // running if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return getAbstractFileSystem().getZipFile().getInputStream(entry); }
@Override protected InputStream doGetInputStream() throws Exception { if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return archive.getInputStream(header); }
/** * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns * {@link FileType#FILE}. The input stream returned by this method is guaranteed to be closed before this method is * called again. */ @Override protected InputStream doGetInputStream() throws Exception { // VFS-210: zip allows to gather an input stream even from a directory and will // return -1 on the first read. getType should not be expensive and keeps the tests // running if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return getAbstractFileSystem().getZipFile().getInputStream(entry); }
/** * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns * {@link FileType#FILE}. The input stream returned by this method is guaranteed to be closed before this method is * called again. */ @Override protected InputStream doGetInputStream() throws Exception { // VFS-210: zip allows to gather an input stream even from a directory and will // return -1 on the first read. getType should not be expensive and keeps the tests // running if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return getAbstractFileSystem().getZipFile().getInputStream(entry); }
/** * Returns the size of the content (in bytes). * * @return The size of the content (in bytes). * @throws FileSystemException if an error occurs. */ @Override public long getSize() throws FileSystemException { // Do some checking if (!fileObject.getType().hasContent()) { throw new FileSystemException("vfs.provider/get-size-not-file.error", fileObject); } /* * if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw * new FileSystemException("vfs.provider/get-size-write.error", file); } */ try { // Get the size return fileObject.doGetContentSize(); } catch (final Exception exc) { throw new FileSystemException("vfs.provider/get-size.error", exc, fileObject); } }
/** * Returns the size of the content (in bytes). * * @return The size of the content (in bytes). * @throws FileSystemException if an error occurs. */ @Override public long getSize() throws FileSystemException { // Do some checking if (!fileObject.getType().hasContent()) { throw new FileSystemException("vfs.provider/get-size-not-file.error", fileObject); } /* * if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw * new FileSystemException("vfs.provider/get-size-write.error", file); } */ try { // Get the size return fileObject.doGetContentSize(); } catch (final Exception exc) { throw new FileSystemException("vfs.provider/get-size.error", exc, fileObject); } }
/** * Returns the size of the content (in bytes). * * @return The size of the content (in bytes). * @throws FileSystemException if an error occurs. */ @Override public long getSize() throws FileSystemException { // Do some checking if (!fileObject.getType().hasContent()) { throw new FileSystemException("vfs.provider/get-size-not-file.error", fileObject); } /* * if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS) { throw * new FileSystemException("vfs.provider/get-size-write.error", file); } */ try { // Get the size return fileObject.doGetContentSize(); } catch (final Exception exc) { throw new FileSystemException("vfs.provider/get-size.error", exc, fileObject); } }
/** * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns * {@link FileType#FILE}. The input stream returned by this method is guaranteed to be closed before this method is * called again. */ @Override protected InputStream doGetInputStream() throws Exception { // VFS-210: zip allows to gather an input stream even from a directory and will // return -1 on the first read. getType should not be expensive and keeps the tests // running if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return getAbstractFileSystem().getInputStream(entry); } }
/** * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns * {@link FileType#FILE}. The input stream returned by this method is guaranteed to be closed before this method is * called again. */ @Override protected InputStream doGetInputStream() throws Exception { // VFS-210: zip allows to gather an input stream even from a directory and will // return -1 on the first read. getType should not be expensive and keeps the tests // running if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return getAbstractFileSystem().getInputStream(entry); } }
/** * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns * {@link FileType#FILE}. The input stream returned by this method is guaranteed to be closed before this method is * called again. */ @Override protected InputStream doGetInputStream() throws Exception { // VFS-210: zip allows to gather an input stream even from a directory and will // return -1 on the first read. getType should not be expensive and keeps the tests // running if (!getType().hasContent()) { throw new FileSystemException("vfs.provider/read-not-file.error", getName()); } return getAbstractFileSystem().getInputStream(entry); } }
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(); } }
private void assertEquals(final FileType expected, final FileType actualFileType) { Assert.assertEquals(expected.getName(), actualFileType.getName()); Assert.assertEquals(expected.hasAttributes(), actualFileType.hasAttributes()); Assert.assertEquals(expected.hasChildren(), actualFileType.hasChildren()); Assert.assertEquals(expected.hasContent(), actualFileType.hasContent()); } }
private void assertEquals(final FileType expected, final FileType actualFileType) { Assert.assertEquals(expected.getName(), actualFileType.getName()); Assert.assertEquals(expected.hasAttributes(), actualFileType.hasAttributes()); Assert.assertEquals(expected.hasChildren(), actualFileType.hasChildren()); Assert.assertEquals(expected.hasContent(), actualFileType.hasContent()); } }
private void assertEquals(final FileType expected, final FileType actualFileType) { Assert.assertEquals(expected.getName(), actualFileType.getName()); Assert.assertEquals(expected.hasAttributes(), actualFileType.hasAttributes()); Assert.assertEquals(expected.hasChildren(), actualFileType.hasChildren()); Assert.assertEquals(expected.hasContent(), actualFileType.hasContent()); } }