@Override
protected DefaultContentProvider.StaticContentFile getStaticContentFile(File file, ImageUtils.StaticContentPathInfo pathInfo, int publicationId) throws ContentProviderException, IOException {
BinaryMeta binaryMeta;
WebComponentMetaFactory factory = new WebComponentMetaFactoryImpl(publicationId);
ComponentMeta componentMeta;
int itemId;
synchronized (LOCK) {
binaryMeta = dynamicMetaRetriever.getBinaryMetaByURL(prependFullUrlIfNeeded(pathInfo.getFileName()));
if (binaryMeta == null) {
throw new StaticContentNotFoundException("No binary meta found for: [" + publicationId + "] " +
pathInfo.getFileName());
}
itemId = (int) binaryMeta.getURI().getItemId();
componentMeta = factory.getMeta(itemId);
if (componentMeta == null) {
throw new StaticContentNotFoundException("No meta meta found for: [" + publicationId + "] " +
pathInfo.getFileName());
}
}
long componentTime = componentMeta.getLastPublicationDate().getTime();
if (isToBeRefreshed(file, componentTime)) {
BinaryData binaryData = binaryContentRetriever.getBinary(publicationId, itemId, binaryMeta.getVariantId());
LOG.debug("Writing binary content to file: {}", file);
writeToFile(file, pathInfo, binaryData.getBytes());
} else {
LOG.debug("File does not need to be refreshed: {}", file);
}
return new StaticContentFile(file, binaryMeta.getType());
}