public static OutputStream getOutputStream( String vfsFilename, boolean append ) throws KettleFileException { return getOutputStream( vfsFilename, defaultVariableSpace, append ); }
protected OutputStream getOutputStream( String vfsFilename, VariableSpace space, boolean append ) throws KettleFileException { return KettleVFS.getOutputStream( vfsFilename, space, append ); }
public Log4jFileAppender( FileObject file ) throws IOException { this.file = file; fileOutputStream = KettleVFS.getOutputStream( file, false ); }
public Log4jFileAppender( FileObject file, boolean append ) throws IOException { this.file = file; fileOutputStream = KettleVFS.getOutputStream( file, append ); }
@VisibleForTesting protected OutputStream initOutputStreamUsingKettleVFS( FileObject fileObject ) throws IOException { return KettleVFS.getOutputStream( fileObject, false ); }
@Override public ObjectId insertLogEntry( String description ) throws KettleException { String logfile = calcDirectoryName( null ) + LOG_FILE; try { OutputStream outputStream = KettleVFS.getOutputStream( logfile, true ); outputStream.write( description.getBytes() ); outputStream.write( Const.CR.getBytes() ); outputStream.close(); return new StringObjectId( logfile ); } catch ( IOException e ) { throw new KettleException( "Unable to write log entry to file [" + logfile + "]" ); } }
/** * Copies a VFS File * * @param in the source file object * @param out the destination file object * @throws KettleException */ public static void copyFile( FileObject in, FileObject out ) throws KettleException { try ( BufferedInputStream fis = new BufferedInputStream( KettleVFS.getInputStream( in ) ); BufferedOutputStream fos = new BufferedOutputStream( KettleVFS.getOutputStream( out, false ) ) ) { byte[] buf = new byte[ 1024 * 1024 ]; // copy in chunks of 1 MB int i = 0; while ( ( i = fis.read( buf ) ) != -1 ) { fos.write( buf, 0, i ); } } catch ( Exception e ) { throw new KettleException( e ); } }
public static OutputStream getOutputStream( String vfsFilename, VariableSpace space, boolean append ) throws KettleFileException { try { FileObject fileObject = getFileObject( vfsFilename, space ); return getOutputStream( fileObject, append ); } catch ( IOException e ) { throw new KettleFileException( e ); } }
public static OutputStream getOutputStream( String vfsFilename, VariableSpace space, FileSystemOptions fsOptions, boolean append ) throws KettleFileException { try { FileObject fileObject = getFileObject( vfsFilename, space, fsOptions ); return getOutputStream( fileObject, append ); } catch ( IOException e ) { throw new KettleFileException( e ); } }
targetFileName = findValidTarget( foldername, filename ); fos = KettleVFS.getOutputStream( targetFileName, false ); bos = new BufferedOutputStream( fos ); bis = new BufferedInputStream( input );
/** * Writes the generated meta injection transformation to the file system. * @param targetFilePath the filesystem path to which to save the generated injection ktr * @throws KettleException */ private void writeInjectedKtrToFs( String targetFilePath ) throws KettleException { OutputStream os = null; try { os = KettleVFS.getOutputStream( targetFilePath, false ); os.write( XMLHandler.getXMLHeader().getBytes( Const.XML_ENCODING ) ); os.write( data.transMeta.getXML().getBytes( Const.XML_ENCODING ) ); } catch ( IOException e ) { throw new KettleException( "Unable to write target file (ktr after injection) to file '" + targetFilePath + "'", e ); } finally { if ( os != null ) { try { os.close(); } catch ( Exception e ) { throw new KettleException( e ); } } } }
public void get( FileObject localFile, String remoteFile ) throws KettleJobException { OutputStream localStream = null; try { localStream = KettleVFS.getOutputStream( localFile, false ); c.get( remoteFile, localStream ); } catch ( SftpException e ) { throw new KettleJobException( e ); } catch ( IOException e ) { throw new KettleJobException( e ); } finally { if ( localStream != null ) { try { localStream.close(); } catch ( IOException ignore ) { // Ignore any IOException, as we're trying to close the stream anyways } } } }
private boolean copyFile( String src, String dest ) throws KettleFileException, IOException { FileObject srcFile = getFileObjectFromKettleVFS( src ); FileObject destFile = getFileObjectFromKettleVFS( dest ); try ( InputStream in = KettleVFS.getInputStream( srcFile ); OutputStream out = KettleVFS.getOutputStream( destFile, false ) ) { IOUtils.copy( in, out ); } return true; }
/** * Log only lines belonging to the specified log channel ID or one of it's children (grandchildren) to the specified * file. * * @param logChannelId * @param filename * @param append * @throws KettleException */ public FileLoggingEventListener( String logChannelId, String filename, boolean append ) throws KettleException { this.logChannelId = logChannelId; this.filename = filename; this.layout = new KettleLogLayout( true ); this.exception = null; file = KettleVFS.getFileObject( filename ); outputStream = null; try { outputStream = KettleVFS.getOutputStream( file, append ); } catch ( Exception e ) { throw new KettleException( "Unable to create a logging event listener to write to file '" + filename + "'", e ); } }
/** * Create a new log channel file writer * * @param logChannelId * The log channel (+children) to write to the log file * @param logFile * The logging file to write to * @param appending * set to true if you want to append to an existing file * @param pollingInterval * The polling interval in milliseconds. * * @throws KettleException * in case the specified log file can't be created. */ public LogChannelFileWriter( String logChannelId, FileObject logFile, boolean appending, int pollingInterval ) throws KettleException { this.logChannelId = logChannelId; this.logFile = logFile; this.appending = appending; this.pollingInterval = pollingInterval; active = new AtomicBoolean( false ); finished = new AtomicBoolean( false ); try { logFileOutputStream = KettleVFS.getOutputStream( logFile, appending ); } catch ( IOException e ) { throw new KettleException( "There was an error while trying to open file '" + logFile + "' for writing", e ); } this.buffer = new LogChannelFileWriterBuffer( this.logChannelId ); LoggingRegistry.getInstance().registerLogChannelFileWriterBuffer( this.buffer ); }
/** * Export message content to a filename. * * @param filename * the target filename * @param foldername * the parent folder of filename * @throws KettleException */ public void saveMessageContentToFile( String filename, String foldername ) throws KettleException { OutputStream os = null; try { os = KettleVFS.getOutputStream( foldername + ( foldername.endsWith( "/" ) ? "" : "/" ) + filename, false ); getMessage().writeTo( os ); updateSavedMessagesCounter(); } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "MailConnection.Error.SavingMessageContent", "" + this.message.getMessageNumber(), filename, foldername ), e ); } finally { if ( os != null ) { IOUtils.closeQuietly( os ); } } }
@Override WebResult generateBody( HttpServletRequest request, HttpServletResponse response, boolean useXML ) throws KettleException, IOException { FileObject tempFile = KettleVFS.createTempFile( "export", ".zip", System.getProperty( "java.io.tmpdir" ) ); OutputStream out = KettleVFS.getOutputStream( tempFile, false ); IOUtils.copy( request.getInputStream(), out ); out.flush();
private void prepareFile() throws KettleFileException { try { String filename = environmentSubstitute( meta.getFilename() ); if ( meta.isAddToResultFiles() ) { // Add this to the result file names... ResultFile resultFile = new ResultFile( ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject( filename, getTransMeta() ), getTransMeta() .getName(), getStepname() ); resultFile.setComment( "This file was created with a cube file output step" ); addResultFile( resultFile ); } data.fos = KettleVFS.getOutputStream( filename, getTransMeta(), false ); data.zip = new GZIPOutputStream( data.fos ); data.dos = new DataOutputStream( data.zip ); } catch ( Exception e ) { throw new KettleFileException( e ); } }
try ( OutputStream propsFile = KettleVFS.getOutputStream( data.file, false ) ) { data.pro.store( propsFile, environmentSubstitute( meta.getComment() ) );
private void closeOutputFile() throws KettleException { try ( BufferedOutputStreamWithCloseDetection out = new BufferedOutputStreamWithCloseDetection( KettleVFS.getOutputStream( data.file, false ) ) ) {