Changeset 13536 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2018-03-17T17:01:12+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r13204 r13536 75 75 protected File cacheFile; 76 76 protected boolean initialized; 77 protected String parameter; 77 78 78 79 public static final long DEFAULT_MAXTIME = -1L; … … 173 174 } 174 175 176 /** 177 * Sets additional URL parameter (used e.g. for maps) 178 * @param parameter the URL parameter 179 * @since 13536 180 */ 181 public void setParam(String parameter) { 182 this.parameter = parameter; 183 } 184 175 185 public String getName() { 186 if(parameter != null) 187 return name.replaceAll("%<(.*)>", ""); 176 188 return name; 177 189 } … … 284 296 } 285 297 if (cacheFile == null) 286 throw new IOException("Unable to get cache file for "+ name);298 throw new IOException("Unable to get cache file for "+getName()); 287 299 return cacheFile; 288 300 } … … 298 310 * @param extension the extension of the file we're looking for 299 311 * @param namepart the name part 300 * @return The zip entry path of the matching file. Nullif this cached file312 * @return The zip entry path of the matching file. <code>null</code> if this cached file 301 313 * doesn't represent a zip file or if there was no matching 302 314 * file in the ZIP file. … … 312 324 * @param extension the extension of the file we're looking for 313 325 * @param namepart the name part 314 * @return InputStream to the matching file. Nullif this cached file326 * @return InputStream to the matching file. <code>null</code> if this cached file 315 327 * doesn't represent a zip file or if there was no matching 316 328 * file in the ZIP file. … … 380 392 url = new URL(name); 381 393 if (!"file".equals(url.getProtocol())) { 382 String prefKey = getPrefKey(url, destDir );394 String prefKey = getPrefKey(url, destDir, null); 383 395 List<String> localPath = new ArrayList<>(Config.getPref().getList(prefKey)); 384 396 if (localPath.size() == 2) { … … 403 415 * @return Preference key 404 416 */ 405 private static String getPrefKey(URL url, String destDir ) {417 private static String getPrefKey(URL url, String destDir, String parameter) { 406 418 StringBuilder prefKey = new StringBuilder("mirror."); 407 419 if (destDir != null) { 408 420 prefKey.append(destDir).append('.'); 409 421 } 410 prefKey.append(url.toString()); 422 if (parameter != null) { 423 prefKey.append(url.toString().replaceAll("%<(.*)>", "")); 424 } else { 425 prefKey.append(url.toString()); 426 } 411 427 return prefKey.toString().replaceAll("=", "_"); 412 428 } 413 429 414 430 private File checkLocal(URL url) throws IOException { 415 String prefKey = getPrefKey(url, destDir );431 String prefKey = getPrefKey(url, destDir, parameter); 416 432 String urlStr = url.toExternalForm(); 433 if (parameter != null) 434 urlStr = urlStr.replaceAll("%<(.*)>", ""); 417 435 long age = 0L; 418 436 long maxAgeMillis = maxAge; … … 460 478 } 461 479 480 if(parameter != null) { 481 String u = url.toExternalForm(); 482 String uc; 483 if("".equals(parameter)) { 484 uc = u.replaceAll("%<(.*)>", ""); 485 } else { 486 uc = u.replaceAll("%<(.*)>", "$1"+parameter); 487 } 488 if(!uc.equals(u)) 489 url = new URL(uc); 490 } 491 462 492 String a = urlStr.replaceAll("[^A-Za-z0-9_.-]", "_"); 463 493 String localPath = "mirror_" + a; -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r13272 r13536 85 85 try { 86 86 cachedFile = new CachedFile(source); 87 cachedFile.setParam(Utils.join(",", ImageryInfo.getActiveIds())); 87 88 cachedFile.setFastFail(fastFail); 88 89 try (BufferedReader in = cachedFile … … 168 169 entry.setBestMarked(true); 169 170 } 171 String overlay = atts.getValue("overlay"); 172 if (TRUE.equals(overlay)) { 173 entry.setOverlay(true); 174 } 170 175 } 171 176 break; … … 174 179 "type", 175 180 "url", 181 "id", 176 182 MIN_ZOOM, 177 183 MAX_ZOOM, … … 189 195 "name", 190 196 "id", 197 "oldid", 191 198 "type", 192 199 "description", … … 328 335 } 329 336 break; 337 case "id": 338 mirrorEntry.setId(accumulator.toString()); 339 break; 330 340 case "url": 331 341 mirrorEntry.setUrl(accumulator.toString()); … … 379 389 case "id": 380 390 entry.setId(accumulator.toString()); 391 break; 392 case "oldid": 393 entry.addOldId(accumulator.toString()); 381 394 break; 382 395 case "type":
Note:
See TracChangeset
for help on using the changeset viewer.