* @param rftId identifier of the image to be resolved
* @return ImageRecord instance containing resolvable metadata
* @throws ResolverException
*/
public ImageRecord getImageRecord(String rftId) throws ResolverException {
ImageRecord ir = imgs.get(rftId);
if (ir == null && isResolvableURI(rftId)) {
try {
URI uri = new URI(rftId);
if (dim.getProcessingList().contains(uri.toString())) {
int i = 0;
Thread.sleep(1000);
while (dim.getProcessingList().contains(uri) && i < (5 * 60)){
Thread.sleep(1000);
i++;
}
if (imgs.containsKey(rftId))
return imgs.get(rftId);
}
File f = dim.convert(uri);
ir = new ImageRecord(rftId, f.getAbsolutePath());
// LRU cache will delete oldest file when max is reached,
// will also remove object from imgs and remoteCacheMap
remoteCacheMap.put(rftId, f.getAbsolutePath());
if (f.length() > 0)
imgs.put(rftId, ir);
else
throw new ResolverException("An error occurred processing file:" + uri.toURL().toString());
} catch (Exception e) {
logger.error(e,e);
throw new ResolverException(e);
}
} else if (isResolvableURI(rftId) && !new File(ir.getImageFile()).exists()) {
// Handle ImageRecord in cache, but file does not exist on the file system
imgs.remove(rftId);
remoteCacheMap.remove(rftId);
return getImageRecord(rftId);
}