Changeset 24915 for main/trunk


Ignore:
Timestamp:
2012-01-06T16:07:14+13:00 (12 years ago)
Author:
ak19
Message:

Dr Bainbridge fixed the problem identified by Blandine and Silver in the mailing list where moving files from one subfolder to another within an existing remote collection would fail if the filename had about 32 or more characters in it (even though the characters were plain ASCII). The reason turned out to be that the feedback\Base64.java class was set to break lines after 76 characters when encoding strings into Base64. This is what happened when Base64 encoding filenames which then got moved about. This is now fixed in feedback\Base64.java with the new method encodeBytesInSingleLine() which sets the base64 encoding options to not break the lines.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/feedback/Base64.java

    r12051 r24915  
    378378        return encodeBytes( source, 0, source.length, NO_OPTIONS );
    379379    }   // end encodeBytes
    380    
    381 
    382 
     380
     381    /**
     382     * Added this variant of the method in so that RemoteGreenstoneServer.java
     383     * can process large source and target filenames, without Base64 encoding
     384     * them introducing a new line.
     385     * @param source The data to convert
     386     * @since January
     387     */
     388    public static String encodeBytesInSingleLine( byte[] source)
     389    {
     390        return encodeBytes( source, 0, source.length, DONT_BREAK_LINES);
     391    }   // end encodeBytes
     392   
    383393    /**
    384394     * Encodes a byte array into Base64 notation.
  • main/trunk/gli/src/org/greenstone/gatherer/remote/RemoteGreenstoneServerAction.java

    r22470 r24915  
    151151        String delete_collection_file_command = "cmd=delete-collection-file";
    152152        delete_collection_file_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    153         delete_collection_file_command += "&file=" + Base64.encodeBytes(collection_file_relative_path.getBytes());
     153        delete_collection_file_command += "&file=" + Base64.encodeBytesInSingleLine(collection_file_relative_path.getBytes());
    154154        action_output = remote.sendCommandToServer(delete_collection_file_command, null);
    155155    }
     
    312312        file_exists_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    313313        // base64 encode the filename to preserve special characters
    314         file_exists_command += "&file=" + Base64.encodeBytes(collection_file_relative_path.getBytes());
     314        file_exists_command += "&file=" + Base64.encodeBytesInSingleLine(collection_file_relative_path.getBytes());
    315315
    316316        // returns either "File <filename> exists" or "File <filename> does not exist"
     
    476476        String move_collection_file_command = "cmd=move-collection-file";
    477477        move_collection_file_command += "&c=" + URLEncoder.encode(collection_name.replace(File.separatorChar, '|'), "UTF-8");
    478         move_collection_file_command += "&source=" + Base64.encodeBytes(source_collection_file_relative_path.getBytes());
    479         move_collection_file_command += "&target=" + Base64.encodeBytes(target_collection_file_relative_path.getBytes());
     478        move_collection_file_command += "&source=" + Base64.encodeBytesInSingleLine(source_collection_file_relative_path.getBytes());
     479        move_collection_file_command += "&target=" + Base64.encodeBytesInSingleLine(target_collection_file_relative_path.getBytes());
    480480        //move_collection_file_command += "&source=" + URLEncoder.encode(source_collection_file_relative_path, "UTF-8");
    481481        //move_collection_file_command += "&target=" + URLEncoder.encode(target_collection_file_relative_path, "UTF-8");
Note: See TracChangeset for help on using the changeset viewer.