try {
for (URL url : urls) {
String path = createReadablePath(url);
NavigationFormatParser parser = new NavigationFormatParser();
final ParserResult result = parser.read(url, getReadFormats());
if (result.isSuccessful()) {
log.info("Appended: " + path);
countRead(result.getFormat());
final String finalPath = path;
// avoid parallelism to ensure the URLs are processed in order
invokeAndWait(new Runnable() {
public void run() {
if (getFormatAndRoutesModel().getFormat().isSupportsMultipleRoutes()) {
for (BaseRoute route : result.getAllRoutes()) {
int appendIndex = getFormatAndRoutesModel().getSize();
getFormatAndRoutesModel().addPositionList(appendIndex, route);
}
} else {
try {
int appendRow = row > 0 ? row : getPositionsModel().getRowCount();
getPositionsModel().add(appendRow, result.getTheRoute());
} catch (FileNotFoundException e) {
r.handleFileNotFound(finalPath);
} catch (IOException e) {
r.handleOpenError(e, finalPath);
}