source: josm/trunk/src/org/openstreetmap/josm/data/preferences/JosmUrls.java@ 14208

Last change on this file since 14208 was 14208, checked in by simon04, 6 years ago

fix #16702 - Speed up OSM wiki help using MediaWiki API

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.preferences;
3
4import org.openstreetmap.josm.io.OsmApi;
5import org.openstreetmap.josm.spi.preferences.Config;
6import org.openstreetmap.josm.spi.preferences.IUrls;
7
8/**
9 * Class that provides URLs values for JOSM.
10 * @since 14119
11 */
12public final class JosmUrls implements IUrls {
13
14 /**
15 * The JOSM website URL.
16 */
17 private static final String JOSM_WEBSITE = "https://josm.openstreetmap.de";
18
19 /**
20 * The OSM website URL.
21 */
22 private static final String OSM_WEBSITE = "https://www.openstreetmap.org";
23
24 /**
25 * The OSM wiki URL.
26 */
27 private static final String OSM_WIKI = "https://wiki.openstreetmap.org";
28
29 /**
30 * public URL of the standard OSM API.
31 */
32 private static final String DEFAULT_API_URL = "https://api.openstreetmap.org/api";
33
34 private JosmUrls() {
35 // hide constructor
36 }
37
38 private static class InstanceHolder {
39 static final JosmUrls INSTANCE = new JosmUrls();
40 }
41
42 /**
43 * Returns the unique instance.
44 * @return the unique instance
45 */
46 public static JosmUrls getInstance() {
47 return InstanceHolder.INSTANCE;
48 }
49
50 @Override
51 public String getOSMWebsiteDependingOnSelectedApi() {
52 final String api = OsmApi.getOsmApi().getServerUrl();
53 if (DEFAULT_API_URL.equals(api)) {
54 return getOSMWebsite();
55 } else {
56 return api.replaceAll("/api$", "");
57 }
58 }
59
60 @Override
61 public String getBaseBrowseUrl() {
62 if (Config.getPref() != null)
63 return Config.getPref().get("osm-browse.url", getOSMWebsiteDependingOnSelectedApi());
64 return getOSMWebsiteDependingOnSelectedApi();
65 }
66
67 @Override
68 public String getBaseUserUrl() {
69 if (Config.getPref() != null)
70 return Config.getPref().get("osm-user.url", getOSMWebsiteDependingOnSelectedApi() + "/user");
71 return getOSMWebsiteDependingOnSelectedApi() + "/user";
72 }
73
74 @Override
75 public String getJOSMWebsite() {
76 if (Config.getPref() != null)
77 return Config.getPref().get("josm.url", JOSM_WEBSITE);
78 return JOSM_WEBSITE;
79 }
80
81 @Override
82 public String getXMLBase() {
83 // Always return HTTP (issues reported with HTTPS)
84 return "http://josm.openstreetmap.de";
85 }
86
87 @Override
88 public String getOSMWebsite() {
89 if (Config.getPref() != null)
90 return Config.getPref().get("osm.url", OSM_WEBSITE);
91 return OSM_WEBSITE;
92 }
93
94 @Override
95 public String getOSMWiki() {
96 if (Config.getPref() != null)
97 return Config.getPref().get("url.openstreetmap-wiki", OSM_WIKI);
98 return OSM_WIKI;
99 }
100
101 @Override
102 public String getDefaultOsmApiUrl() {
103 return DEFAULT_API_URL;
104 }
105}
Note: See TracBrowser for help on using the repository browser.