beginTransaction(db);
try
{
DigitalAsset digitalAsset = getSmallDigitalAssetWithId(digitalAssetId, db);
if(digitalAsset != null)
{
String folderName = "" + (digitalAsset.getDigitalAssetId().intValue() / 1000);
if(logger.isInfoEnabled())
{
logger.info("folderName:" + folderName);
logger.info("Found a digital asset:" + digitalAsset.getAssetFileName());
}
String contentType = digitalAsset.getAssetContentType();
String assetFilePath = digitalAsset.getAssetFilePath();
if(assetFilePath.indexOf("IG_ARCHIVE:") > -1)
{
assetUrl = CmsPropertyHandler.getWebServerAddress() + "/" + CmsPropertyHandler.getImagesBaseUrl() + "/archivedAsset.gif";
}
else if(contentType.equalsIgnoreCase("image/gif") || contentType.equalsIgnoreCase("image/jpg") || contentType.equalsIgnoreCase("image/pjpeg") || contentType.equalsIgnoreCase("image/jpeg") || contentType.equalsIgnoreCase("image/png"))
{
String fileName = digitalAsset.getDigitalAssetId() + "_" + digitalAsset.getAssetFileName();
logger.info("fileName:" + fileName);
String filePath = CmsPropertyHandler.getDigitalAssetPath() + File.separator + folderName;
logger.info("filePath:" + filePath);
logger.info("Making thumb from:" + filePath + File.separator + fileName);
String thumbnailFileName = digitalAsset.getDigitalAssetId() + "_thumbnail_" + digitalAsset.getAssetFileName();
//String thumbnailFileName = "thumbnail_" + fileName;
File thumbnailFile = new File(filePath + File.separator + thumbnailFileName);
File originalFile = new File(filePath + File.separator + fileName);
if(!originalFile.exists())
{
logger.warn("No file there - let's try getting it again.");
String originalUrl = DigitalAssetController.getController().getDigitalAssetUrl(digitalAsset.getValueObject(), db);
logger.warn("originalUrl:" + originalUrl);
originalFile = new File(filePath + File.separator + fileName);
}
if(!originalFile.exists())
{
logger.warn("The original file " + filePath + File.separator + fileName + " was not found - missing from system.");
assetUrl = "images" + File.separator + BROKENFILENAME;
}
else
{
if(!thumbnailFile.exists() && originalFile.exists())
{
logger.info("transforming...");
//ThumbnailGenerator tg = new ThumbnailGenerator();
ThumbnailGenerator tg = ThumbnailGenerator.getInstance();
tg.transform(filePath + File.separator + fileName, filePath + File.separator + thumbnailFileName, 75, 75, 100);
logger.info("transform done...");
}
assetUrl = CmsPropertyHandler.getWebServerAddress() + "/" + CmsPropertyHandler.getDigitalAssetBaseUrl() + "/" + folderName + "/" + thumbnailFileName;
logger.info("assetUrl:" + assetUrl);
}
}
else
{
String fileName = digitalAsset.getDigitalAssetId() + "_" + digitalAsset.getAssetFileName();
String filePath = CmsPropertyHandler.getDigitalAssetPath() + File.separator + folderName;
File originalFile = new File(filePath + File.separator + fileName);
if(!originalFile.exists())
{
assetUrl = CmsPropertyHandler.getWebServerAddress() + "/" + CmsPropertyHandler.getImagesBaseUrl() + "/" + BROKENFILENAME;