Ignore:
Timestamp:
2010-12-09T22:27:33+13:00 (13 years ago)
Author:
ak19
Message:

GLI now has a gs.FilenameEncoding metadata field which appears like all the others in GLI's EnrichPane, but is unique in that this metadata (once set, changed or removed) must be applied to the affected filenames in the Collection Tree. More importantly, the changes made for this are to allow GLI's java code to interact with the recent changes to Perl where strings were made unicode-aware (for proper regex matching) but which required other changes elsewhere. To still support filenames with different encodings Perl used URL encoded versions of filenames representing characters' code point values in URL encoding. This required that GLI write out URL encoded filenames to the metadata.xml files that are associated with each folder level of a collection, so that Perl can read them. In this way, they can both speak of the same filenames. Only works on unicode 16 (such as latin-1), non-UTF8 systems. The latter is a requirement since Java uses the filesystem encoding from startup. If it is UTF8, non-recognised characters are replaced by the invalid char for UTF8. This process being destructive, we can't get the original filenames' bytecodes back. The changes made to GLI will work on Windows which is UTF-16 (windows codepage 1252), presumably also Macs (some kind of UTF-16) and also works on Native Latin 1 Linux systems. UTF-8 Linux systems need to be reconfigured to Native Latin-1, or if not installed, an administrator can install it easily.

File:
1 edited

Legend:

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

    r23143 r23433  
    5656import org.greenstone.gatherer.gui.WarningDialog;
    5757import org.greenstone.gatherer.gui.FedoraLogin;
     58import org.greenstone.gatherer.metadata.FilenameEncoding;
    5859import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
    5960import org.greenstone.gatherer.util.JarTools;
     
    471472        }
    472473
     474        // Check that the local can support multiple filename encodings
     475            //System.err.println("#### Java identifies current Locale as (file.encoding): "
     476            //  + System.getProperty("file.encoding"));
     477        if(System.getProperty("file.encoding").equals("UTF-8")){
     478            // If the locale is UTF-8, Java will interpret all filename bytes as UTF-8,
     479            // which is a destructive process as it will convert characters not recognised
     480            // by UTF-8 into the invalid character, rather than preserving the bytecodes.
     481            // This has the effect that non-UTF8 encoded filenames on a system set to a
     482            // UTF-8 locale are not 'seen' by Java (if they contain non-ASCII characters).
     483            multipleFilenameEncodingsNotSupported();       
     484            FilenameEncoding.MULTIPLE_FILENAME_ENCODINGS_SUPPORTED = false;
     485            FilenameEncoding.URL_FILE_SEPARATOR = File.separator;
     486        } else {
     487            FilenameEncoding.MULTIPLE_FILENAME_ENCODINGS_SUPPORTED = true;
     488            FilenameEncoding.URL_FILE_SEPARATOR = "/"; // URL file separator is always "/"
     489        }
     490       
    473491        // Set the default font for all Swing components.
    474492        FontUIResource default_font = Configuration.getFont("general.font", true);
     
    852870                + File.separator + "cgi" + File.separator + "gsdl3site.cfg";
    853871        } else { // cgi-bin/gsdlsite.cfg
    854             return Configuration.gsdl_path + File.separator
     872            return Configuration.gsdl_path /* + File.separator */
    855873                + "cgi-bin" + File.separator + "gsdlsite.cfg";
    856874        }
     
    12581276    }
    12591277
     1278    /** Prints a warning message about the OS not supporting multiple filename encodings.  */
     1279    static private void multipleFilenameEncodingsNotSupported() {   
     1280        WarningDialog dialog = new WarningDialog("warning.NoEncodingSupport",
     1281            Dictionary.get("General.MultipleFileNamesNotSupported.Title"),
     1282            Dictionary.get("General.MultipleFileNamesNotSupported.Message"), null, false);
     1283        dialog.display();
     1284        dialog.dispose();
     1285        dialog = null;
     1286    }
    12601287
    12611288    /** Sets up the proxy connection by setting JVM Environment flags and creating a new Authenticator.
Note: See TracChangeset for help on using the changeset viewer.