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

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

Sonar - various performance improvements

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