Ignore:
Timestamp:
2014-08-20T03:07:15+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #8885 (see #4614) - add offline mode with new command line argument --offline which can take one of several of these values (comma separated):

  • josm_website: to disable all accesses to JOSM website (when not cached, disables Getting Started page, help, plugin list, styles, imagery, presets, rules)
  • osm_api: to disable all accesses to OSM API (disables download, upload, changeset queries, history, user message notification)
  • all: alias to disable all values. Currently equivalent to "josm_website,osm_api"

Plus improved javadoc, fixed EDT violations, and fixed a bug with HTTP redirection sent without "Location" header

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r7299 r7434  
    2828import org.openstreetmap.josm.io.IllegalDataException;
    2929import org.openstreetmap.josm.io.MissingOAuthAccessTokenException;
     30import org.openstreetmap.josm.io.OfflineAccessException;
    3031import org.openstreetmap.josm.io.OsmApi;
    3132import org.openstreetmap.josm.io.OsmApiException;
     
    496497
    497498    /**
     499     * Explains a {@link OfflineAccessException} which has caused an {@link OsmTransferException}.
     500     * This is most likely happening when JOSM tries to access OSM API or JOSM website while in offline mode.
     501     *
     502     * @param e the exception
     503     * @return The HTML formatted error message to display
     504     * @since 7434
     505     */
     506    public static String explainOfflineAccessException(OsmTransferException e) {
     507        OfflineAccessException oae = getNestedException(e, OfflineAccessException.class);
     508        Main.error(e);
     509        return tr("<html>Failed to download data.<br>"
     510                + "<br>Details: {0}</html>", oae.getMessage());
     511    }
     512
     513    /**
    498514     * Explains a {@link OsmApiException} which was thrown because of an internal server
    499515     * error in the OSM API server..
  • trunk/src/org/openstreetmap/josm/tools/WikiReader.java

    r7401 r7434  
    3030     */
    3131    public WikiReader() {
    32         this.baseurl = Main.pref.get("help.baseurl", Main.getJOSMWebsite());
     32        this(Main.pref.get("help.baseurl", Main.getJOSMWebsite()));
     33    }
     34
     35    /**
     36     * Returns the base URL of wiki.
     37     * @return the base URL of wiki
     38     * @since 7434
     39     */
     40    public final String getBaseUrlWiki() {
     41        return baseurl + "/wiki/";
    3342    }
    3443
     
    4655        try (BufferedReader in = Utils.openURLReader(u)) {
    4756            boolean txt = url.endsWith("?format=txt");
    48             if (url.startsWith(baseurl) && !txt)
     57            if (url.startsWith(getBaseUrlWiki()) && !txt)
    4958                return readFromTrac(in, u);
    5059            return readNormal(in, !txt);
     
    6473        languageCode = LanguageInfo.getWikiLanguagePrefix(LocaleType.DEFAULTNOTENGLISH);
    6574        if(languageCode != null) {
    66             res = readLang(new URL(baseurl + "/wiki/" + languageCode + text));
     75            res = readLang(new URL(getBaseUrlWiki() + languageCode + text));
    6776        }
    6877
     
    7079            languageCode = LanguageInfo.getWikiLanguagePrefix(LocaleType.BASELANGUAGE);
    7180            if(languageCode != null) {
    72                 res = readLang(new URL(baseurl + "/wiki/" + languageCode + text));
     81                res = readLang(new URL(getBaseUrlWiki() + languageCode + text));
    7382            }
    7483        }
     
    7786            languageCode = LanguageInfo.getWikiLanguagePrefix(LocaleType.ENGLISH);
    7887            if(languageCode != null) {
    79                 res = readLang(new URL(baseurl + "/wiki/" + languageCode + text));
     88                res = readLang(new URL(getBaseUrlWiki() + languageCode + text));
    8089            }
    8190        }
Note: See TracChangeset for help on using the changeset viewer.