ResourceURI resourceURI = resource.getURI();
String resourceType = resourceURI.getType();
// Create the filename
ResourceContent content = resource.getContent(language);
// Initiate creation of previews
InputStream resourceInputStream = null;
InputStream contentRepositoryIs = null;
FileOutputStream fos = null;
File scaledResourceFile = null;
try {
scaledResourceFile = ImageStyleUtils.getScaledFile(resource, language, style);
// Find the modification date
long lastModified = ResourceUtils.getModificationDate(resource, language).getTime();
// Create the file if it doesn't exist or if it is out dated. Note that
// the last modified date of a file has a precision of seconds
if (!scaledResourceFile.isFile() || FileUtils.isFileOlder(scaledResourceFile, new Date(lastModified))) {
contentRepositoryIs = contentRepository.getContent(resourceURI, language);
// Is this local content?
if (contentRepositoryIs == null && content != null && content.getExternalLocation() != null) {
contentRepositoryIs = content.getExternalLocation().openStream();
}
// Create the parent directory
File scaledResourceDir = scaledResourceFile.getParentFile();
if (!scaledResourceDir.isDirectory() && !scaledResourceDir.mkdirs()) {