Changeset 15868 in josm
- Timestamp:
- 2020-02-16T23:13:25+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/imagery/ApiKeyProvider.java
r15855 r15868 6 6 import java.net.URL; 7 7 import java.util.Collections; 8 import java.util.HashMap; 8 9 import java.util.List; 10 import java.util.Map; 9 11 10 12 import org.openstreetmap.josm.data.Preferences; … … 19 21 */ 20 22 public final class ApiKeyProvider { 23 24 private static final Map<String, String> CACHE = new HashMap<>(); 21 25 22 26 private ApiKeyProvider() { … … 36 40 */ 37 41 public static String retrieveApiKey(String imageryId) throws IOException { 42 if (CACHE.containsKey(imageryId)) { 43 return CACHE.get(imageryId); 44 } 38 45 for (String siteUrl : getApiKeySites()) { 39 46 Response response = HttpClient.create(new URL(siteUrl + imageryId)).connect(); 40 47 try { 41 48 if (response.getResponseCode() == HttpURLConnection.HTTP_OK) { 42 return Utils.strip(response.fetchContent()); 49 String key = Utils.strip(response.fetchContent()); 50 CACHE.put(imageryId, key); 51 return key; 43 52 } 44 53 } finally {
Note:
See TracChangeset
for help on using the changeset viewer.