try {
JAXBContext context = JAXBContext.newInstance(
WmsCacheType.class.getPackage().getName(),
WmsCacheType.class.getClassLoader());
Unmarshaller unmarshaller = context.createUnmarshaller();
WmsCacheType cacheEntries;
try (InputStream is = new FileInputStream(indexFile)) {
cacheEntries = (WmsCacheType)unmarshaller.unmarshal(is);
}
totalFileSize = cacheEntries.getTotalFileSize();
if (cacheEntries.getTileSize() != tileSize) {
Main.info("Cache created with different tileSize, cache will be discarded");
return;
}
for (ProjectionType projectionType: cacheEntries.getProjection()) {
ProjectionEntries projection = getProjectionEntries(projectionType.getName(), projectionType.getCacheDirectory());
for (EntryType entry: projectionType.getEntry()) {
CacheEntry ce = new CacheEntry(entry.getPixelPerDegree(), entry.getEast(), entry.getNorth(), tileSize, entry.getFilename());
ce.lastUsed = entry.getLastUsed().getTimeInMillis();
ce.lastModified = entry.getLastModified().getTimeInMillis();