source: josm/trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java@ 8854

Last change on this file since 8854 was 8846, checked in by Don-vip, 9 years ago

sonar - fb-contrib - minor performance improvements:

  • Method passes constant String of length 1 to character overridden method
  • Method needlessly boxes a boolean constant
  • Method uses iterator().next() on a List to get the first item
  • Method converts String to boxed primitive using excessive boxing
  • Method converts String to primitive using excessive boxing
  • Method creates array using constants
  • Class defines List based fields but uses them like Sets
  • Property svn:eol-style set to native
File size: 24.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5import static org.openstreetmap.josm.tools.I18n.trn;
6
7import java.io.IOException;
8import java.io.InputStream;
9import java.net.HttpURLConnection;
10import java.util.ArrayList;
11import java.util.Collection;
12import java.util.HashSet;
13import java.util.Iterator;
14import java.util.LinkedHashSet;
15import java.util.List;
16import java.util.NoSuchElementException;
17import java.util.Set;
18import java.util.concurrent.Callable;
19import java.util.concurrent.CompletionService;
20import java.util.concurrent.ExecutionException;
21import java.util.concurrent.Executor;
22import java.util.concurrent.ExecutorCompletionService;
23import java.util.concurrent.Executors;
24import java.util.concurrent.Future;
25
26import org.openstreetmap.josm.Main;
27import org.openstreetmap.josm.data.osm.DataSet;
28import org.openstreetmap.josm.data.osm.DataSetMerger;
29import org.openstreetmap.josm.data.osm.Node;
30import org.openstreetmap.josm.data.osm.OsmPrimitive;
31import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
32import org.openstreetmap.josm.data.osm.PrimitiveId;
33import org.openstreetmap.josm.data.osm.Relation;
34import org.openstreetmap.josm.data.osm.RelationMember;
35import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
36import org.openstreetmap.josm.data.osm.Way;
37import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
38import org.openstreetmap.josm.gui.progress.ProgressMonitor;
39import org.openstreetmap.josm.tools.CheckParameterUtil;
40import org.openstreetmap.josm.tools.Utils;
41
42/**
43 * Retrieves a set of {@link OsmPrimitive}s from an OSM server using the so called
44 * Multi Fetch API.
45 *
46 * Usage:
47 * <pre>
48 * MultiFetchServerObjectReader reader = MultiFetchServerObjectReader()
49 * .append(2345,2334,4444)
50 * .append(new Node(72343));
51 * reader.parseOsm();
52 * if (!reader.getMissingPrimitives().isEmpty()) {
53 * Main.info("There are missing primitives: " + reader.getMissingPrimitives());
54 * }
55 * if (!reader.getSkippedWays().isEmpty()) {
56 * Main.info("There are skipped ways: " + reader.getMissingPrimitives());
57 * }
58 * </pre>
59 */
60public class MultiFetchServerObjectReader extends OsmServerReader{
61 /**
62 * the max. number of primitives retrieved in one step. Assuming IDs with 7 digits,
63 * this leads to a max. request URL of ~ 1600 Bytes ((7 digits + 1 Separator) * 200),
64 * which should be safe according to the
65 * <a href="http://www.boutell.com/newfaq/misc/urllength.html">WWW FAQ</a>.
66 */
67 private static final int MAX_IDS_PER_REQUEST = 200;
68
69 private Set<Long> nodes;
70 private Set<Long> ways;
71 private Set<Long> relations;
72 private Set<PrimitiveId> missingPrimitives;
73 private DataSet outputDataSet;
74
75 /**
76 * Constructs a {@code MultiFetchServerObjectReader}.
77 */
78 public MultiFetchServerObjectReader() {
79 nodes = new LinkedHashSet<>();
80 ways = new LinkedHashSet<>();
81 relations = new LinkedHashSet<>();
82 this.outputDataSet = new DataSet();
83 this.missingPrimitives = new LinkedHashSet<>();
84 }
85
86 /**
87 * Remembers an {@link OsmPrimitive}'s id. The id will
88 * later be fetched as part of a Multi Get request.
89 *
90 * Ignore the id if it represents a new primitives.
91 *
92 * @param id the id
93 */
94 protected void remember(PrimitiveId id) {
95 if (id.isNew()) return;
96 switch(id.getType()) {
97 case NODE: nodes.add(id.getUniqueId()); break;
98 case WAY: ways.add(id.getUniqueId()); break;
99 case RELATION: relations.add(id.getUniqueId()); break;
100 }
101 }
102
103 /**
104 * remembers an {@link OsmPrimitive}'s id. <code>ds</code> must include
105 * an {@link OsmPrimitive} with id=<code>id</code>. The id will
106 * later we fetched as part of a Multi Get request.
107 *
108 * Ignore the id if it id &lt;= 0.
109 *
110 * @param ds the dataset (must not be null)
111 * @param id the primitive id
112 * @param type The primitive type. Must be one of {@link OsmPrimitiveType#NODE NODE}, {@link OsmPrimitiveType#WAY WAY},
113 * {@link OsmPrimitiveType#RELATION RELATION}
114 * @throws IllegalArgumentException if ds is null
115 * @throws NoSuchElementException if ds does not include an {@link OsmPrimitive} with id=<code>id</code>
116 */
117 protected void remember(DataSet ds, long id, OsmPrimitiveType type) throws NoSuchElementException {
118 CheckParameterUtil.ensureParameterNotNull(ds, "ds");
119 if (id <= 0) return;
120 OsmPrimitive primitive = ds.getPrimitiveById(id, type);
121 if (primitive == null)
122 throw new NoSuchElementException(tr("No primitive with id {0} in local dataset. Cannot infer primitive type.", id));
123 remember(primitive.getPrimitiveId());
124 return;
125 }
126
127 /**
128 * appends a {@link OsmPrimitive} id to the list of ids which will be fetched from the server.
129 *
130 * @param ds the {@link DataSet} to which the primitive belongs
131 * @param id the primitive id
132 * @param type The primitive type. Must be one of {@link OsmPrimitiveType#NODE NODE}, {@link OsmPrimitiveType#WAY WAY},
133 * {@link OsmPrimitiveType#RELATION RELATION}
134 * @return this
135 */
136 public MultiFetchServerObjectReader append(DataSet ds, long id, OsmPrimitiveType type) {
137 OsmPrimitive p = ds.getPrimitiveById(id, type);
138 switch(type) {
139 case NODE:
140 return appendNode((Node) p);
141 case WAY:
142 return appendWay((Way) p);
143 case RELATION:
144 return appendRelation((Relation) p);
145 }
146 return this;
147 }
148
149 /**
150 * appends a {@link Node} id to the list of ids which will be fetched from the server.
151 *
152 * @param node the node (ignored, if null)
153 * @return this
154 */
155 public MultiFetchServerObjectReader appendNode(Node node) {
156 if (node == null) return this;
157 remember(node.getPrimitiveId());
158 return this;
159 }
160
161 /**
162 * appends a {@link Way} id and the list of ids of nodes the way refers to the list of ids which will be fetched from the server.
163 *
164 * @param way the way (ignored, if null)
165 * @return this
166 */
167 public MultiFetchServerObjectReader appendWay(Way way) {
168 if (way == null) return this;
169 if (way.isNew()) return this;
170 for (Node node: way.getNodes()) {
171 if (!node.isNew()) {
172 remember(node.getPrimitiveId());
173 }
174 }
175 remember(way.getPrimitiveId());
176 return this;
177 }
178
179 /**
180 * appends a {@link Relation} id to the list of ids which will be fetched from the server.
181 *
182 * @param relation the relation (ignored, if null)
183 * @return this
184 */
185 protected MultiFetchServerObjectReader appendRelation(Relation relation) {
186 if (relation == null) return this;
187 if (relation.isNew()) return this;
188 remember(relation.getPrimitiveId());
189 for (RelationMember member : relation.getMembers()) {
190 if (OsmPrimitiveType.from(member.getMember()).equals(OsmPrimitiveType.RELATION)) {
191 // avoid infinite recursion in case of cyclic dependencies in relations
192 //
193 if (relations.contains(member.getMember().getId())) {
194 continue;
195 }
196 }
197 if (!member.getMember().isIncomplete()) {
198 append(member.getMember());
199 }
200 }
201 return this;
202 }
203
204 /**
205 * appends an {@link OsmPrimitive} to the list of ids which will be fetched from the server.
206 * @param primitive the primitive
207 * @return this
208 */
209 public MultiFetchServerObjectReader append(OsmPrimitive primitive) {
210 if (primitive != null) {
211 switch (OsmPrimitiveType.from(primitive)) {
212 case NODE: return appendNode((Node) primitive);
213 case WAY: return appendWay((Way) primitive);
214 case RELATION: return appendRelation((Relation) primitive);
215 }
216 }
217 return this;
218 }
219
220 /**
221 * appends a list of {@link OsmPrimitive} to the list of ids which will be fetched from the server.
222 *
223 * @param primitives the list of primitives (ignored, if null)
224 * @return this
225 *
226 * @see #append(OsmPrimitive)
227 */
228 public MultiFetchServerObjectReader append(Collection<? extends OsmPrimitive> primitives) {
229 if (primitives == null) return this;
230 for (OsmPrimitive primitive : primitives) {
231 append(primitive);
232 }
233 return this;
234 }
235
236 /**
237 * extracts a subset of max {@link #MAX_IDS_PER_REQUEST} ids from <code>ids</code> and
238 * replies the subset. The extracted subset is removed from <code>ids</code>.
239 *
240 * @param ids a set of ids
241 * @return the subset of ids
242 */
243 protected Set<Long> extractIdPackage(Set<Long> ids) {
244 Set<Long> pkg = new HashSet<>();
245 if (ids.isEmpty())
246 return pkg;
247 if (ids.size() > MAX_IDS_PER_REQUEST) {
248 Iterator<Long> it = ids.iterator();
249 for (int i = 0; i < MAX_IDS_PER_REQUEST; i++) {
250 pkg.add(it.next());
251 }
252 ids.removeAll(pkg);
253 } else {
254 pkg.addAll(ids);
255 ids.clear();
256 }
257 return pkg;
258 }
259
260 /**
261 * builds the Multi Get request string for a set of ids and a given {@link OsmPrimitiveType}.
262 *
263 * @param type The primitive type. Must be one of {@link OsmPrimitiveType#NODE NODE}, {@link OsmPrimitiveType#WAY WAY},
264 * {@link OsmPrimitiveType#RELATION RELATION}
265 * @param idPackage the package of ids
266 * @return the request string
267 */
268 protected static String buildRequestString(OsmPrimitiveType type, Set<Long> idPackage) {
269 StringBuilder sb = new StringBuilder();
270 sb.append(type.getAPIName()).append("s?")
271 .append(type.getAPIName()).append("s=");
272
273 Iterator<Long> it = idPackage.iterator();
274 for (int i = 0; i < idPackage.size(); i++) {
275 sb.append(it.next());
276 if (i < idPackage.size()-1) {
277 sb.append(',');
278 }
279 }
280 return sb.toString();
281 }
282
283 /**
284 * builds the Multi Get request string for a single id and a given {@link OsmPrimitiveType}.
285 *
286 * @param type The primitive type. Must be one of {@link OsmPrimitiveType#NODE NODE}, {@link OsmPrimitiveType#WAY WAY},
287 * {@link OsmPrimitiveType#RELATION RELATION}
288 * @param id the id
289 * @return the request string
290 */
291 protected static String buildRequestString(OsmPrimitiveType type, long id) {
292 StringBuilder sb = new StringBuilder();
293 sb.append(type.getAPIName()).append("s?")
294 .append(type.getAPIName()).append("s=")
295 .append(id);
296 return sb.toString();
297 }
298
299 protected void rememberNodesOfIncompleteWaysToLoad(DataSet from) {
300 for (Way w: from.getWays()) {
301 if (w.hasIncompleteNodes()) {
302 for (Node n: w.getNodes()) {
303 if (n.isIncomplete()) {
304 nodes.add(n.getId());
305 }
306 }
307 }
308 }
309 }
310
311 /**
312 * merges the dataset <code>from</code> to {@link #outputDataSet}.
313 *
314 * @param from the other dataset
315 */
316 protected void merge(DataSet from) {
317 final DataSetMerger visitor = new DataSetMerger(outputDataSet, from);
318 visitor.merge();
319 }
320
321 /**
322 * fetches a set of ids of a given {@link OsmPrimitiveType} from the server
323 *
324 * @param ids the set of ids
325 * @param type The primitive type. Must be one of {@link OsmPrimitiveType#NODE NODE}, {@link OsmPrimitiveType#WAY WAY},
326 * {@link OsmPrimitiveType#RELATION RELATION}
327 * @throws OsmTransferException if an error occurs while communicating with the API server
328 */
329 protected void fetchPrimitives(Set<Long> ids, OsmPrimitiveType type, ProgressMonitor progressMonitor) throws OsmTransferException {
330 String msg = "";
331 String baseUrl = OsmApi.getOsmApi().getBaseUrl();
332 switch (type) {
333 case NODE: msg = tr("Fetching a package of nodes from ''{0}''", baseUrl); break;
334 case WAY: msg = tr("Fetching a package of ways from ''{0}''", baseUrl); break;
335 case RELATION: msg = tr("Fetching a package of relations from ''{0}''", baseUrl); break;
336 }
337 progressMonitor.setTicksCount(ids.size());
338 progressMonitor.setTicks(0);
339 // The complete set containing all primitives to fetch
340 Set<Long> toFetch = new HashSet<>(ids);
341 // Build a list of fetchers that will download smaller sets containing only MAX_IDS_PER_REQUEST (200) primitives each.
342 // we will run up to MAX_DOWNLOAD_THREADS concurrent fetchers.
343 int threadsNumber = Main.pref.getInteger("osm.download.threads", OsmApi.MAX_DOWNLOAD_THREADS);
344 threadsNumber = Math.min(Math.max(threadsNumber, 1), OsmApi.MAX_DOWNLOAD_THREADS);
345 Executor exec = Executors.newFixedThreadPool(threadsNumber, Utils.newThreadFactory(getClass() + "-%d", Thread.NORM_PRIORITY));
346 CompletionService<FetchResult> ecs = new ExecutorCompletionService<>(exec);
347 List<Future<FetchResult>> jobs = new ArrayList<>();
348 while (!toFetch.isEmpty()) {
349 jobs.add(ecs.submit(new Fetcher(type, extractIdPackage(toFetch), progressMonitor)));
350 }
351 // Run the fetchers
352 for (int i = 0; i < jobs.size() && !isCanceled(); i++) {
353 progressMonitor.subTask(msg + "... " + progressMonitor.getTicks() + '/' + progressMonitor.getTicksCount());
354 try {
355 FetchResult result = ecs.take().get();
356 if (result.missingPrimitives != null) {
357 missingPrimitives.addAll(result.missingPrimitives);
358 }
359 if (result.dataSet != null && !isCanceled()) {
360 rememberNodesOfIncompleteWaysToLoad(result.dataSet);
361 merge(result.dataSet);
362 }
363 } catch (InterruptedException | ExecutionException e) {
364 Main.error(e);
365 }
366 }
367 // Cancel requests if the user choosed to
368 if (isCanceled()) {
369 for (Future<FetchResult> job : jobs) {
370 job.cancel(true);
371 }
372 }
373 }
374
375 /**
376 * invokes one or more Multi Gets to fetch the {@link OsmPrimitive}s and replies
377 * the dataset of retrieved primitives. Note that the dataset includes non visible primitives too!
378 * In contrast to a simple Get for a node, a way, or a relation, a Multi Get always replies
379 * the latest version of the primitive (if any), even if the primitive is not visible (i.e. if
380 * visible==false).
381 *
382 * Invoke {@link #getMissingPrimitives()} to get a list of primitives which have not been
383 * found on the server (the server response code was 404)
384 *
385 * @return the parsed data
386 * @throws OsmTransferException if an error occurs while communicating with the API server
387 * @see #getMissingPrimitives()
388 *
389 */
390 @Override
391 public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException {
392 int n = nodes.size() + ways.size() + relations.size();
393 progressMonitor.beginTask(trn("Downloading {0} object from ''{1}''",
394 "Downloading {0} objects from ''{1}''", n, n, OsmApi.getOsmApi().getBaseUrl()));
395 try {
396 missingPrimitives = new HashSet<>();
397 if (isCanceled()) return null;
398 fetchPrimitives(ways, OsmPrimitiveType.WAY, progressMonitor);
399 if (isCanceled()) return null;
400 fetchPrimitives(nodes, OsmPrimitiveType.NODE, progressMonitor);
401 if (isCanceled()) return null;
402 fetchPrimitives(relations, OsmPrimitiveType.RELATION, progressMonitor);
403 if (outputDataSet != null) {
404 outputDataSet.deleteInvisible();
405 }
406 return outputDataSet;
407 } finally {
408 progressMonitor.finishTask();
409 }
410 }
411
412 /**
413 * replies the set of ids of all primitives for which a fetch request to the
414 * server was submitted but which are not available from the server (the server
415 * replied a return code of 404)
416 *
417 * @return the set of ids of missing primitives
418 */
419 public Set<PrimitiveId> getMissingPrimitives() {
420 return missingPrimitives;
421 }
422
423 /**
424 * The class holding the results given by {@link Fetcher}.
425 * It is only a wrapper of the resulting {@link DataSet} and the collection of {@link PrimitiveId} that could not have been loaded.
426 */
427 protected static class FetchResult {
428
429 /**
430 * The resulting data set
431 */
432 public final DataSet dataSet;
433
434 /**
435 * The collection of primitive ids that could not have been loaded
436 */
437 public final Set<PrimitiveId> missingPrimitives;
438
439 /**
440 * Constructs a {@code FetchResult}
441 * @param dataSet The resulting data set
442 * @param missingPrimitives The collection of primitive ids that could not have been loaded
443 */
444 public FetchResult(DataSet dataSet, Set<PrimitiveId> missingPrimitives) {
445 this.dataSet = dataSet;
446 this.missingPrimitives = missingPrimitives;
447 }
448 }
449
450 /**
451 * The class that actually download data from OSM API.
452 * Several instances of this class are used by {@link MultiFetchServerObjectReader} (one per set of primitives to fetch).
453 * The inheritance of {@link OsmServerReader} is only explained by the need to have a distinct OSM connection by {@code Fetcher} instance.
454 * @see FetchResult
455 */
456 protected static class Fetcher extends OsmServerReader implements Callable<FetchResult> {
457
458 private final Set<Long> pkg;
459 private final OsmPrimitiveType type;
460 private final ProgressMonitor progressMonitor;
461
462 /**
463 * Constructs a {@code Fetcher}
464 * @param type The primitive type. Must be one of {@link OsmPrimitiveType#NODE NODE}, {@link OsmPrimitiveType#WAY WAY},
465 * {@link OsmPrimitiveType#RELATION RELATION}
466 * @param idsPackage The set of primitives ids to fetch
467 * @param progressMonitor The progress monitor
468 */
469 public Fetcher(OsmPrimitiveType type, Set<Long> idsPackage, ProgressMonitor progressMonitor) {
470 this.pkg = idsPackage;
471 this.type = type;
472 this.progressMonitor = progressMonitor;
473 }
474
475 @Override
476 public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException {
477 // This method is implemented because of the OsmServerReader inheritance, but not used,
478 // as the main target of this class is the call() method.
479 return fetch(progressMonitor).dataSet;
480 }
481
482 @Override
483 public FetchResult call() throws Exception {
484 return fetch(progressMonitor);
485 }
486
487 /**
488 * fetches the requested primitives and updates the specified progress monitor.
489 * @param progressMonitor the progress monitor
490 * @return the {@link FetchResult} of this operation
491 * @throws OsmTransferException if an error occurs while communicating with the API server
492 */
493 protected FetchResult fetch(ProgressMonitor progressMonitor) throws OsmTransferException {
494 try {
495 return multiGetIdPackage(type, pkg, progressMonitor);
496 } catch (OsmApiException e) {
497 if (e.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
498 Main.info(tr("Server replied with response code 404, retrying with an individual request for each object."));
499 return singleGetIdPackage(type, pkg, progressMonitor);
500 } else {
501 throw e;
502 }
503 }
504 }
505
506 /**
507 * invokes a Multi Get for a set of ids and a given {@link OsmPrimitiveType}.
508 * The retrieved primitives are merged to {@link #outputDataSet}.
509 *
510 * @param type The primitive type. Must be one of {@link OsmPrimitiveType#NODE NODE}, {@link OsmPrimitiveType#WAY WAY},
511 * {@link OsmPrimitiveType#RELATION RELATION}
512 * @param pkg the package of ids
513 * @return the {@link FetchResult} of this operation
514 * @throws OsmTransferException if an error occurs while communicating with the API server
515 */
516 protected FetchResult multiGetIdPackage(OsmPrimitiveType type, Set<Long> pkg, ProgressMonitor progressMonitor)
517 throws OsmTransferException {
518 String request = buildRequestString(type, pkg);
519 FetchResult result = null;
520 try (InputStream in = getInputStream(request, NullProgressMonitor.INSTANCE)) {
521 if (in == null) return null;
522 progressMonitor.subTask(tr("Downloading OSM data..."));
523 try {
524 result = new FetchResult(OsmReader.parseDataSet(in, progressMonitor.createSubTaskMonitor(pkg.size(), false)), null);
525 } catch (Exception e) {
526 throw new OsmTransferException(e);
527 }
528 } catch (IOException ex) {
529 Main.warn(ex);
530 }
531 return result;
532 }
533
534 /**
535 * invokes a Multi Get for a single id and a given {@link OsmPrimitiveType}.
536 * The retrieved primitive is merged to {@link #outputDataSet}.
537 *
538 * @param type The primitive type. Must be one of {@link OsmPrimitiveType#NODE NODE}, {@link OsmPrimitiveType#WAY WAY},
539 * {@link OsmPrimitiveType#RELATION RELATION}
540 * @param id the id
541 * @return the {@link DataSet} resulting of this operation
542 * @throws OsmTransferException if an error occurs while communicating with the API server
543 */
544 protected DataSet singleGetId(OsmPrimitiveType type, long id, ProgressMonitor progressMonitor) throws OsmTransferException {
545 String request = buildRequestString(type, id);
546 DataSet result = null;
547 try (InputStream in = getInputStream(request, NullProgressMonitor.INSTANCE)) {
548 if (in == null) return null;
549 progressMonitor.subTask(tr("Downloading OSM data..."));
550 try {
551 result = OsmReader.parseDataSet(in, progressMonitor.createSubTaskMonitor(1, false));
552 } catch (Exception e) {
553 throw new OsmTransferException(e);
554 }
555 } catch (IOException ex) {
556 Main.warn(ex);
557 }
558 return result;
559 }
560
561 /**
562 * invokes a sequence of Multi Gets for individual ids in a set of ids and a given {@link OsmPrimitiveType}.
563 * The retrieved primitives are merged to {@link #outputDataSet}.
564 *
565 * This method is used if one of the ids in pkg doesn't exist (the server replies with return code 404).
566 * If the set is fetched with this method it is possible to find out which of the ids doesn't exist.
567 * Unfortunately, the server does not provide an error header or an error body for a 404 reply.
568 *
569 * @param type The primitive type. Must be one of {@link OsmPrimitiveType#NODE NODE}, {@link OsmPrimitiveType#WAY WAY},
570 * {@link OsmPrimitiveType#RELATION RELATION}
571 * @param pkg the set of ids
572 * @return the {@link FetchResult} of this operation
573 * @throws OsmTransferException if an error occurs while communicating with the API server
574 */
575 protected FetchResult singleGetIdPackage(OsmPrimitiveType type, Set<Long> pkg, ProgressMonitor progressMonitor)
576 throws OsmTransferException {
577 FetchResult result = new FetchResult(new DataSet(), new HashSet<PrimitiveId>());
578 String baseUrl = OsmApi.getOsmApi().getBaseUrl();
579 for (long id : pkg) {
580 try {
581 String msg = "";
582 switch (type) {
583 case NODE: msg = tr("Fetching node with id {0} from ''{1}''", id, baseUrl); break;
584 case WAY: msg = tr("Fetching way with id {0} from ''{1}''", id, baseUrl); break;
585 case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, baseUrl); break;
586 }
587 progressMonitor.setCustomText(msg);
588 result.dataSet.mergeFrom(singleGetId(type, id, progressMonitor));
589 } catch (OsmApiException e) {
590 if (e.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
591 Main.info(tr("Server replied with response code 404 for id {0}. Skipping.", Long.toString(id)));
592 result.missingPrimitives.add(new SimplePrimitiveId(id, type));
593 } else {
594 throw e;
595 }
596 }
597 }
598 return result;
599 }
600 }
601}
Note: See TracBrowser for help on using the repository browser.