Ignore:
Timestamp:
2010-02-10T17:17:25+01:00 (14 years ago)
Author:
rcernoch
Message:

CzechAddress: New way of handling URLs for MVCR database. Url updated, push into preferences no longer forced.

Location:
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/DatabaseParser.java

    r15582 r19964  
    9696            URL url = new URL(getDatabaseUrl());
    9797            HttpURLConnection con = (HttpURLConnection)url.openConnection();
     98
     99            //Set timeout for 10 seconds.
     100            con.setReadTimeout(10000);
    98101            con.connect();
    99102
     103            System.err.println("CzechAddress: Stahuji: " + url.toString());
    100104            System.err.println("CzechAddress: Server vrátil: " + con.getResponseMessage());
    101105
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/MvcrParser.java

    r18894 r19964  
    208208//==============================================================================
    209209
    210     static final String URL_DEFAULT = "http://web.mvcr.cz/adresa/adresy.zip";
     210    static final String URL_DEFAULT = "http://aplikace.mvcr.cz/adresa/adresy.zip";
    211211    static final String URL_PREFERENCES_KEY = "czechaddress.databaseurl";
    212    
     212
     213    static final String[] OLD_URLS = {
     214        "http://web.mvcr.cz/adresa/adresy.zip" // Remove around 10.02.2011
     215    };
     216
    213217    @Override
    214218    protected String getDatabaseUrl() {
    215219
    216         if (!Main.pref.hasKey(URL_PREFERENCES_KEY))
    217             Main.pref.put(URL_PREFERENCES_KEY, URL_DEFAULT);
    218 
    219         return Main.pref.get(URL_PREFERENCES_KEY);
     220        // No longer add the default URL into preferences.
     221        //if (!Main.pref.hasKey(URL_PREFERENCES_KEY))
     222        //    Main.pref.put(URL_PREFERENCES_KEY, URL_DEFAULT);
     223
     224        /* If an outdated URL is found in the preferences, replace it by the
     225         * new one. However the urls from the list should be removed after
     226         * a reasonable amount of time (one year?), because this is a
     227         * non-systematic solution.
     228         */
     229        for (String oldUrl : OLD_URLS)
     230            if (Main.pref.get(URL_PREFERENCES_KEY, URL_DEFAULT).equals(oldUrl)) {
     231                Main.pref.put(URL_PREFERENCES_KEY, URL_DEFAULT);
     232                break;
     233            }
     234
     235        return Main.pref.get(URL_PREFERENCES_KEY, URL_DEFAULT);
    220236    }
    221237
Note: See TracChangeset for help on using the changeset viewer.