Changeset 18646

Show
Ignore:
Timestamp:
09.03.2009 19:31:58 (10 years ago)
Author:
ak19
Message:

When deleting a file from the remote GS server or checking for its existence, URL encoding the filename can pose a problem in Java if it contains special characters in some character encoding, since you need to specify the correct character encoding when URL encoding. However, base64 encoding does not require this, and is therefore used to preserve filenames for transferring to the remote server where it will be decoded to obtain the name of the file to be deleted or which needs to be checked for whether it exists.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServerAction.java

    r17612 r18646  
    4141import org.greenstone.gatherer.Gatherer; 
    4242import org.greenstone.gatherer.collection.CollectionManager; 
     43import org.greenstone.gatherer.feedback.Base64; 
    4344import org.greenstone.gatherer.shell.GShell; 
    4445import org.greenstone.gatherer.util.UnzipTools; 
     
    150151        String delete_collection_file_command = "cmd=delete-collection-file"; 
    151152        delete_collection_file_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8"); 
    152         delete_collection_file_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8"); 
     153        delete_collection_file_command += "&file=" + Base64.encodeBytes(collection_file_relative_path.getBytes()); 
    153154        action_output = remote.sendCommandToServer(delete_collection_file_command, null); 
    154155    } 
     
    307308        String file_exists_command = "cmd=file-exists"; 
    308309        file_exists_command += "&c=" + URLEncoder.encode(collection_name, "UTF-8"); 
    309         file_exists_command += "&file=" + URLEncoder.encode(collection_file_relative_path, "UTF-8"); 
     310        // base64 encode the filename to preserve special characters 
     311        file_exists_command += "&file=" + Base64.encodeBytes(collection_file_relative_path.getBytes()); 
     312 
    310313        // returns either "File <filename> exists" or "File <filename> does not exist" 
    311314        // for the file/folder collection_file