@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() ); }
fileSource.moveTo( fileDestination );
destinationfile = KettleVFS.getFileObject( movetofilenamefull ); if ( !destinationfile.exists() ) { sourcefilename.moveTo( destinationfile ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobPGPEncryptFiles.Log.FileEncrypted", sourcefilename sourcefilename.moveTo( destinationfile ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobPGPEncryptFiles.Log.FileOverwrite", destinationfile destinationfile = KettleVFS.getFileObject( destinationfilenamefull ); sourcefilename.moveTo( destinationfile ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobPGPEncryptFiles.Log.FileEncrypted", destinationfile
destinationfile = KettleVFS.getFileObject( movetofilenamefull ); if ( !destinationfile.exists() ) { sourcefilename.moveTo( destinationfile ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobPGPDecryptFiles.Log.FileDecrypted", sourcefilename sourcefilename.moveTo( destinationfile ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobPGPDecryptFiles.Log.FileOverwrite", destinationfile destinationfile = KettleVFS.getFileObject( destinationfilenamefull ); sourcefilename.moveTo( destinationfile ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobPGPDecryptFiles.Log.FileDecrypted", destinationfile
if ( !destinationfilename.exists() ) { if ( !simulate ) { sourcefilename.moveTo( destinationfilename ); sourcefilename.moveTo( destinationfilename ); sourcefilename.moveTo( destinationfile ); if ( !destinationfile.exists() ) { if ( !simulate ) { sourcefilename.moveTo( destinationfile ); if ( ifmovedfileexists.equals( "overwrite_file" ) ) { if ( !simulate ) { sourcefilename.moveTo( destinationfile ); sourcefilename.moveTo( destinationfile );
destFile = KettleVFS.getFileObject( destinationFilename, this ); sourceFileObject.moveTo( destFile );
@Override public ObjectId renameRepositoryDirectory( ObjectId id, RepositoryDirectoryInterface newParentDir, String newName ) throws KettleException { if ( newParentDir != null || newName != null ) { try { // In case of a root object, the ID is the same as the relative filename... RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree(); RepositoryDirectoryInterface dir = tree.findDirectory( id ); if ( dir == null ) { throw new KettleException( "Could not find folder [" + id + "]" ); } // If newName is null, keep the current name newName = ( newName != null ) ? newName : dir.getName(); FileObject folder = KettleVFS.getFileObject( dir.getPath() ); String newFolderName = null; if ( newParentDir != null ) { FileObject newParentFolder = KettleVFS.getFileObject( newParentDir.getPath() ); newFolderName = newParentFolder.toString() + "/" + newName; } else { newFolderName = folder.getParent().toString() + "/" + newName; } FileObject newFolder = KettleVFS.getFileObject( newFolderName ); folder.moveTo( newFolder ); return new StringObjectId( dir.getObjectId() ); } catch ( Exception e ) { throw new KettleException( "Unable to rename directory folder to [" + id + "]" ); } } return ( id ); }
sourcefile.moveTo( destinationfile ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString(
private ObjectId renameObject( ObjectId id, RepositoryDirectoryInterface newDirectory, String newName, String extension ) throws KettleException { try { // In case of a root object, the ID is the same as the relative filename... // FileObject fileObject = KettleVFS.getFileObject( calcDirectoryName( null ) + id.getId() ); // Same name, different folder? if ( Utils.isEmpty( newName ) ) { newName = calcObjectName( id ); } // The new filename can be anywhere so we re-calculate a new ID... // String newFilename = calcDirectoryName( newDirectory ) + newName + extension; FileObject newObject = KettleVFS.getFileObject( newFilename ); fileObject.moveTo( newObject ); return new StringObjectId( calcObjectId( newDirectory, newName, extension ) ); } catch ( Exception e ) { throw new KettleException( "Unable to rename object with ID [" + id + "] to [" + newName + "]", e ); } }
dummyfile = KettleVFS.getFileObject( filename ); file.moveTo( dummyfile );
fileSource.moveTo( fileDestination );
KettleVFS.getFileObject( realMovetodirectory + Const.FILE_SEPARATOR + fileObjectd.getName().getBaseName(), this ); fileObjectd.moveTo( fileObjectm ); } catch ( IOException e ) { logError( BaseMessages.getString( PKG, "JobZipFiles.Cant_Move_File1.Label" )
data.sourceFile.moveTo( file );
KettleVFS.getFileObject( realDestinationFolder + Const.FILE_SEPARATOR + myFile.getName().getBaseName(), this ); myFile.moveTo( destination ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobSFTPPUT.Log.FileMoved", myFile, destination ) );
KettleVFS.getFileObject( destinationFolder.getName().getBaseName() + Const.FILE_SEPARATOR + file.getName().getBaseName(), this ); file.moveTo( destination ); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "SFTPPut.Log.FileMoved", file, destination ) );
if ( ( ( meta.isOverwriteTargetFile() && data.targetFile.exists() ) || !data.targetFile.exists() ) && !meta.simulate ) { data.sourceFile.moveTo( KettleVFS.getFileObject( targetFilename, getTransMeta() ) ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString(
@Override public void moveTo(final FileObject destFile) throws FileSystemException { decoratedFileObject.moveTo(destFile); }
@Override public void moveTo(org.apache.commons.vfs2.FileObject destFile) { try { if (destFile instanceof FileObject) { destFile = ((FileObject) destFile).fileObject; } this.fileObject.moveTo(destFile); } catch (FileSystemException e) { throw new VFSFileSystemException(e); } }
@Override public void moveTo(org.apache.commons.vfs2.FileObject destFile) { try { if (destFile instanceof FileObject) { destFile = ((FileObject) destFile).fileObject; } this.fileObject.moveTo(destFile); } catch (FileSystemException e) { throw new VFSFileSystemException(e); } }
private void moveFile(final FileObject scratchFolder, final FileObject file, final String content) throws FileSystemException, Exception { final FileObject fileMove = scratchFolder.resolveFile("file1move.txt"); assertTrue(!fileMove.exists()); file.moveTo(fileMove); assertTrue(!file.exists()); assertTrue(fileMove.exists()); assertSameContent(content, fileMove); // Delete the file. assertTrue(fileMove.exists()); assertTrue(fileMove.delete()); }