mapCountry = country.trim().toLowerCase();
mapUrl = cl.getMapUrl(mapId, mapCountry);
}
- @Nullable
- RawType mapData = HttpUtil.downloadData(mapUrl, null, false, -1);
- if (mapData != null) {
- return mapData;
- } else {
- logger.debug("Could not download '{}'", mapUrl);
+ if (mapUrl.isBlank()) {
+ logger.debug("Cannot download map data: Returned map URL is empty");
return null;
}
+ try {
+ RawType mapData = HttpUtil.downloadData(mapUrl, null, false, -1);
+ if (mapData != null) {
+ return mapData;
+ } else {
+ logger.debug("Could not download '{}'", mapUrl);
+ return null;
+ }
+ } catch (IllegalArgumentException e) {
+ logger.debug("Error downloading map: {}", e.getMessage());
+ }
+ return null;
}
public void setCredentials(@Nullable String username, @Nullable String password, @Nullable String country) {
if (response.getAsJsonObject().has("result") && response.getAsJsonObject().get("result").isJsonObject()) {
JsonObject jo = response.getAsJsonObject().get("result").getAsJsonObject();
if (jo.has("url")) {
- return jo.get("url").getAsString();
+ String mapUrl = jo.get("url").getAsString();
+ return mapUrl != null ? mapUrl : "";
} else {
errorMsg = "Could not get url";
}