Ignore:
Timestamp:
2019-12-03T15:04:32+13:00 (4 years ago)
Author:
ak19
Message:

Refactored code to do more inside functions rather than make callers do extra, specific work that requires knowledge of what happened (and didn't happen) inside the called functions. Shifted the new functions about until they appear after Dr Bainbridge's more important functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFile.java

    r33739 r33744  
    668668        }
    669669       
    670         String curr_directory_path = FilenameEncoding.filenameToURLEncoding(".");
    671         curr_directory_path = curr_directory_path.substring(0, curr_directory_path.length()-2); // cut off /. at end
    672         //System.err.println("@@@ curr_directory_path: " + curr_directory_path);
     670        String curr_directory_path = FilenameEncoding.fullFilepathToURLEncoding(".");
     671       
     672        //String curr_directory_path = FilenameEncoding.filenameToURLEncoding(".");
     673        //curr_directory_path = curr_directory_path.substring(0, curr_directory_path.length()-2); // cut off /. at end
     674        System.err.println("@@@ curr_directory_path: " + curr_directory_path);
    673675       
    674676        //System.err.println("PARSED loaded_file contains:\n" +  XMLTools.elementToString(doc.getDocumentElement(), true));
     
    687689                    // Reencode filename after parseXML() had the side-effect of decoding entities in filename elements
    688690                   
    689                     //System.err.println("Filename before reencoding was: " + filename);                   
     691                    System.err.println("Filename before reencoding was: " + filename);                 
    690692                   
    691693                    // Can't convert to URI with backslash-escaped chars (backslash used in regexed filename are illegal in URI object
    692694                    // created by filenameToURLEncoding). So replace backslashes in regex with url-encoded hex-value of backslash, %5C.
    693695                    String encoded_filename = filename.replace("\\", "%5C");
     696                   
     697                    /*
    694698                    encoded_filename = FilenameEncoding.filenameToURLEncoding(encoded_filename);
    695 
    696699                    // now lop off the metadataxml dir prefix the FilenameEncoding.filenameToURLEncoding(STRING) variant would have added
    697700                    encoded_filename = encoded_filename.substring(curr_directory_path.length());
     
    699702                        encoded_filename = encoded_filename.substring(FilenameEncoding.URL_FILE_SEPARATOR.length());
    700703                    }
    701    
     704                    */
     705                   
     706                    // get the URL encoded filename preserving special encodings, with any curr_directory_path prefix removed
     707                    encoded_filename = FilenameEncoding.filenameToURLEncodingWithPrefixRemoved(encoded_filename, curr_directory_path);
     708                   
    702709                    // Reintrodudce the backslash characters in place of their %5C hex placeholders
    703710                    encoded_filename = encoded_filename.replace("%5C", "\\");               
     
    705712                    // Update filename element in DOM
    706713                    XMLTools.setElementTextValue(filename_element, encoded_filename);
    707                     //System.err.println("Filename after reencoding was: " + encoded_filename);
     714                    System.err.println("Filename after reencoding was: " + encoded_filename);
    708715                }
    709716            }
Note: See TracChangeset for help on using the changeset viewer.