private void updateMap(DatasourceType datasourceType, Map map) throws IOException {
String url = datasourceType.getBaseUrl() + map.getUri();
log.severe(format("Failed to download %s as a map", map.getUri()));
return;
MapType mapType = createMapType(map.getUri(), singletonList(checksum), null);
datasourceType.getMap().add(mapType);
log.severe(format("Failed to download %s partially as a map", map.getUri()));
return;
if (map.getUri().endsWith(DOT_ZIP)) {
try (ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(download.getFile().getFile()))) {
ZipEntry entry = zipInputStream.getNextEntry();
while (entry != null) {
if (!entry.isDirectory() && entry.getName().endsWith(DOT_MAP)) {
log.info(format("Found map %s in URI %s", entry.getName(), map.getUri()));
mapType.getFragment().add(createFragmentType(entry.getName(), entry.getTime(), entry.getSize()));
} else if (map.getUri().endsWith(DOT_MAP)) {
log.info(format("Found map %s", map.getUri()));
BoundingBox boundingBox = MapUtil.extractBoundingBox(download.getFile().getFile());
if (boundingBox != null)
mapType.setBoundingBox(asBoundingBoxType(boundingBox));
} else
log.warning(format("Ignoring %s as a map", map.getUri()));