Skip to content

Commit

Permalink
[PDI-19784] - Not able to rename a folder from PDI browser inside a c…
Browse files Browse the repository at this point in the history
…ontainer for the VFS connections in 9.4/9.5
  • Loading branch information
bcostahitachivantara committed Oct 26, 2023
1 parent 13ed3a4 commit bbc38cd
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.plugins.fileopensave.api.file.FileDetails;
import org.pentaho.di.plugins.fileopensave.api.overwrite.OverwriteStatus;
import org.pentaho.di.plugins.fileopensave.api.overwrite.OverwriteStatus.OverwriteMode;
import org.pentaho.di.plugins.fileopensave.api.providers.Directory;
import org.pentaho.di.plugins.fileopensave.api.providers.Entity;
import org.pentaho.di.plugins.fileopensave.api.providers.File;
Expand Down Expand Up @@ -1598,14 +1599,14 @@ private void performPaste() {
switch( pasteAction ) {
case PASTE_ACTION_REPLACE:
copyFile( file, destFolder, newFilePath,
new OverwriteStatus( getShell(), OverwriteStatus.OverwriteMode.OVERWRITE ) );
new OverwriteStatus( getShell(), OverwriteMode.OVERWRITE ) );
break;
case PASTE_ACTION_KEEP_BOTH:
if ( StringUtils.isNotEmpty( newFilePath ) ) {
result = FILE_CONTROLLER.getNewName( destFolder, newFilePath );
if ( result.getStatus() == Result.Status.SUCCESS ) {
FILE_CONTROLLER.copyFile( file, destFolder, (String) result.getData(),
new OverwriteStatus( getShell(), OverwriteStatus.OverwriteMode.RENAME ) );
new OverwriteStatus( getShell(), OverwriteMode.RENAME ) );
}
}
break;
Expand All @@ -1621,7 +1622,7 @@ private void performPaste() {

} else {
result = copyFile( file, destFolder, newFilePath,
new OverwriteStatus( getShell(), OverwriteStatus.OverwriteMode.CANCEL ) );
new OverwriteStatus( getShell(), OverwriteMode.CANCEL ) );
}

if ( isCutActionSelected && deleteCutFileFlag ) {
Expand Down Expand Up @@ -1659,11 +1660,11 @@ private void createRenameDialog( File file ) {
RenameDialog renameDialog = new RenameDialog( getShell() );
String renameValue = renameDialog.open( file.getName() );
if ( renameValue != null ) {
String filename = file.getName();
String fileExtention =
filename.lastIndexOf( "." ) != -1 ? filename.substring( filename.lastIndexOf( "." ), filename.length() ) : null;
FILE_CONTROLLER.rename( file, file.getParent() + java.io.File.separator + renameValue,
new OverwriteStatus( null, OverwriteStatus.OverwriteMode.OVERWRITE ) );
String newPath = file.getParent() + java.io.File.separator + renameValue;
// Prevent rename folder to the same name
if ( !file.getPath().equals( newPath ) ) {
FILE_CONTROLLER.rename( file, newPath, new OverwriteStatus( null, OverwriteMode.OVERWRITE ) );
}
}
}

Expand Down

0 comments on commit bbc38cd

Please sign in to comment.