/** * Attempts to delete the entity. After an entity has been deleted, any call to any of the methods of the entity may * produce undefined results. * * @return true, if the entity was deleted and detached from the repository, false otherwise. */ public boolean delete() { try { backend.delete(); return false; } catch ( FileSystemException ex ) { throw new RuntimeException( ex ); } } }
public void deleteFile( String filename ) throws KettleException { try { FileObject fileObject = KettleVFS.getFileObject( filename ); fileObject.delete(); } catch ( Exception e ) { throw new KettleException( "Unable to delete file with name [" + filename + "]", e ); } }
public void deleteRootObject( String name, String extension ) throws KettleException { try { String filename = calcDirectoryName( null ) + name + extension; FileObject fileObject = KettleVFS.getFileObject( filename ); fileObject.delete(); } catch ( Exception e ) { throw new KettleException( "Unable to delete database with name [" + name + "] and extension [" + extension + "]", e ); } }
private void clearBuffers() { // Clean out the sort buffer data.buffer.clear(); data.getBufferIndex = 0; data.rowbuffer.clear(); // close any open DataInputStream objects if ( ( data.dis != null ) && ( data.dis.size() > 0 ) ) { for ( DataInputStream dis : data.dis ) { BaseStep.closeQuietly( dis ); } } // close any open InputStream objects if ( ( data.fis != null ) && ( data.fis.size() > 0 ) ) { for ( InputStream is : data.fis ) { BaseStep.closeQuietly( is ); } } // remove temp files for ( int f = 0; f < data.files.size(); f++ ) { FileObject fileToDelete = data.files.get( f ); try { if ( fileToDelete != null && fileToDelete.exists() ) { fileToDelete.delete(); } } catch ( FileSystemException e ) { logError( e.getLocalizedMessage(), e ); } } }
private static void deleteVfsFile( String path ) throws Exception { TestUtils.getFileObject( path ).delete(); }
private static void deleteVfsFile( String path ) throws Exception { TestUtils.getFileObject( path ).delete(); }
public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { if ( ( data.dis != null ) && ( data.dis.size() > 0 ) ) { for ( DataInputStream is : data.dis ) { BaseStep.closeQuietly( is ); } } // remove temp files for ( int f = 0; f < data.files.size(); f++ ) { FileObject fileToDelete = data.files.get( f ); try { if ( fileToDelete != null && fileToDelete.exists() ) { fileToDelete.delete(); } } catch ( FileSystemException e ) { logError( e.getLocalizedMessage(), e ); } } super.dispose( smi, sdi ); }
if ( fileObject.exists() ) { if ( fileObject.getType() == FileType.FILE ) { if ( !fileObject.delete() ) { throw new RuntimeException( "We can not delete file [" + (String) ArgList[0] + "]!" );
void registerRuleViolation() throws IOException { // close output streams this.delegate.close(); // make attempt to delete file if ( !fileDeleted ) { fileDeleted = writeTo.delete(); } // seems we are unable to delete file? if ( !fileDeleted ) { log.logDebug( BaseMessages.getString( PKG, "Repository.Exporter.Log.UnableToDeleteFile" ) ); } // and we will not use real work writer anymore. this.delegate = new NullStFileWriter(); }
@Test public void unzipPostProcessingTest() throws Exception { JobEntryUnZip jobEntryUnZip = new JobEntryUnZip(); Method unzipPostprocessingMethod = jobEntryUnZip.getClass().getDeclaredMethod( "doUnzipPostProcessing", FileObject.class, FileObject.class, String.class ); unzipPostprocessingMethod.setAccessible( true ); FileObject sourceFileObject = Mockito.mock( FileObject.class ); Mockito.doReturn( Mockito.mock( FileName.class ) ).when( sourceFileObject ).getName(); //delete jobEntryUnZip.afterunzip = 1; unzipPostprocessingMethod.invoke( jobEntryUnZip, sourceFileObject, Mockito.mock( FileObject.class ), "" ); Mockito.verify( sourceFileObject, Mockito.times( 1 ) ).delete(); //move jobEntryUnZip.afterunzip = 2; unzipPostprocessingMethod.invoke( jobEntryUnZip, sourceFileObject, Mockito.mock( FileObject.class ), "" ); Mockito.verify( sourceFileObject, Mockito.times( 1 ) ).moveTo( Mockito.anyObject() ); }
if ( targetFile.exists() && !targetFile.delete() ) { logger.warn( "Unable to delete incomplete export: " + targetFile ); //$NON-NLS-1$
private FileObject createTemplateFile( String content ) throws IOException { FileObject f2 = createTemplateFile(); if ( content == null ) { f2.delete(); } else { OutputStreamWriter fw = null; try { fw = new OutputStreamWriter( f2.getContent().getOutputStream() ); fw.write( content ); } finally { if ( fw != null ) { fw.close(); } } } return f2; }
try { fileObject = KettleVFS.getFileObject( environmentSubstitute( meta.getControlFile() ), getTransMeta() ); fileObject.delete(); fileObject.close(); } catch ( Exception ex ) { try { fileObject = KettleVFS.getFileObject( environmentSubstitute( meta.getDataFile() ), getTransMeta() ); fileObject.delete(); fileObject.close(); } catch ( Exception ex ) {
try { fileObject = KettleVFS.getFileObject( environmentSubstitute( meta.getControlFile() ), getTransMeta() ); fileObject.delete(); fileObject.close(); } catch ( Exception ex ) { try { fileObject = KettleVFS.getFileObject( environmentSubstitute( meta.getDataFile() ), getTransMeta() ); fileObject.delete(); fileObject.close(); } catch ( Exception ex ) {
/** * When an object implementing interface <code>Runnable</code> is used to create a thread, starting the thread causes * the object's <code>run</code> method to be called in that separately executing thread. * <p/> * The general contract of the method <code>run</code> is that it may take any action whatsoever. * * @see Thread#run() */ public void run() { try { targetFile = KettleVFS.getFileObject( targetPath ); if ( targetFile.exists() ) { if ( !targetFile.delete() ) { throw new ReportProcessingException( messages.getErrorString( "ReportExportTask.ERROR_0001_TARGET_EXISTS" ) ); //$NON-NLS-1$ } } if ( createParentFolder ) { targetFile.getParent().createFolder(); } execute(); } catch ( Exception ex ) { statusListener.setStatus( StatusType.ERROR, messages.getString( "ReportExportTask.USER_EXPORT_FAILED" ), ex ); //$NON-NLS-1$ logger.error( "Failed" ); //$NON-NLS-1$ } }
if ( afterunzip == 1 ) { boolean deleted = sourceFileObject.delete(); if ( !deleted ) { updateErrors();
@Test public void testEnforceProtPOnPut() throws Exception { FileObject file = KettleVFS.createTempFile( "FTPSConnectionTest_testEnforceProtPOnPut", KettleVFS.Suffix.TMP); file.createFile(); try { FTPSTestConnection connection = spy( new FTPSTestConnection( FTPSConnection.CONNECTION_TYPE_FTP_IMPLICIT_TLS_WITH_CRYPTED, "the.perfect.host", 2010, "warwickw", "julia", null ) ); connection.replies.put( "PWD", new Reply( Arrays.asList( "257 \"/la\" is current directory" ) ) ); connection.connect(); connection.uploadFile( file.getPublicURIString(), "uploaded-file" ); assertEquals( "buffer not set", "PBSZ 0\r\n", connection.commands.get( 0 ).toString() ); assertEquals( "data privacy not set", "PROT P\r\n", connection.commands.get( 1 ).toString() ); } finally { file.delete(); } }
if ( fileObject.exists() ) { if ( fileObject.getType() == FileType.FILE ) { if ( !fileObject.delete() ) { Context.reportRuntimeError( "We can not delete file [" + Context.toString( ArgList[0] ) + "]!" );
int Nr = filefolder.delete( new TextFileSelector() );
data.sourceFile.delete(); break; default: