source: josm/trunk/src/org/openstreetmap/josm/io/OnlineResource.java@ 15735

Last change on this file since 15735 was 14999, checked in by Don-vip, 5 years ago

fix #17619:

  • improve offline startup time on Windows by making certificate download optional
  • fix Taiwan Windows alias
  • issue a warning when a certificate alias is wrong
  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6/**
7 * Online resources directly used by JOSM.
8 * This does not include websites where user can sometimes be redirected through its web browser,
9 * but only those to we establish a connection.
10 *
11 * @since 7434
12 */
13public enum OnlineResource {
14
15 /** The OSM API, used for download, upload, history, etc. */
16 OSM_API(tr("OSM API")),
17 /** The JOSM website, used for startup page, imagery/presets/styles/rules entries, help, etc. */
18 JOSM_WEBSITE(tr("JOSM website")),
19 /** Various government certificates downloaded on Windows to make https imagery work in some countries */
20 CERTIFICATES(tr("Certificates")),
21 /** Value used to represent all online resources */
22 ALL(tr("All"));
23
24 private final String locName;
25
26 OnlineResource(String locName) {
27 this.locName = locName;
28 }
29
30 /**
31 * Replies the localized name.
32 * @return the localized name
33 */
34 public final String getLocName() {
35 return locName;
36 }
37
38 /**
39 * Ensures resource is not accessed in offline mode.
40 * @param downloadString The attempted download string
41 * @param resourceString The resource download string that should not be accessed
42 * @throws OfflineAccessException if resource is accessed in offline mode, in any protocol
43 */
44 public final void checkOfflineAccess(String downloadString, String resourceString) {
45 if (NetworkManager.isOffline(this) && downloadString
46 .startsWith(resourceString.substring(resourceString.indexOf("://")), downloadString.indexOf("://"))) {
47 throw new OfflineAccessException(tr("Unable to access ''{0}'': {1} not available (offline mode)", downloadString, getLocName()));
48 }
49 }
50}
Note: See TracBrowser for help on using the repository browser.