String assetUrl = "";
assetUrl = urlComposer.composeDigitalAssetUrl("", null, "", deliveryContext);
SmallestContentVersionVO contentVersion = getSmallestContentVersionVO(siteNodeId, contentId, languageId, db, useLanguageFallback, deliveryContext, infoGluePrincipal);
ContentVO contentVO = this.getContentVO(db, contentId, deliveryContext);
LanguageVO masterLanguageVO = LanguageDeliveryController.getLanguageDeliveryController().getMasterLanguageForRepository(contentVO.getRepositoryId(), db);
if(logger.isInfoEnabled())
{
logger.info("languageId:" + languageId);
logger.info("masterLanguageVO:" + masterLanguageVO);
}
/*
if(deliveryContext.getUseDownloadAction())
{
SiteNode siteNode = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getSiteNode(db, siteNodeId);
String dnsName = CmsPropertyHandler.getWebServerAddress();
if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals(""))
dnsName = siteNode.getRepository().getDnsName();
return urlComposer.composeDigitalAssetUrl(dnsName, siteNodeId, contentId, languageId, assetKey, deliveryContext);
}
*/
boolean isUnprotectedAsset = getHasUserContentAccess(db, UserControllerProxy.getController().getUser(CmsPropertyHandler.getAnonymousUser()), contentId);
if(!isUnprotectedAsset)
{
DigitalAssetVO digitalAsset = DigitalAssetController.getLatestDigitalAssetVO(contentVersion.getId(), assetKey, db);
if(digitalAsset == null)
return "";
//SiteNodeVO siteNodeVO = getSiteNodeVO(db, siteNodeId);
String dnsName = CmsPropertyHandler.getWebServerAddress();
if(siteNodeVO != null)
{
RepositoryVO repositoryVO = RepositoryController.getController().getRepositoryVOWithId(siteNodeVO.getRepositoryId(), db);
if(repositoryVO.getDnsName() != null && !repositoryVO.getDnsName().equals(""))
dnsName = repositoryVO.getDnsName();
}
/*
SiteNode siteNode = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getSiteNodeVO(db, siteNodeId);
String dnsName = CmsPropertyHandler.getWebServerAddress();
if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals(""))
dnsName = siteNode.getRepository().getDnsName();
*/
return urlComposer.composeDigitalAssetUrl(dnsName, siteNodeId, contentId, languageId, assetKey, deliveryContext, db);
}
else if(contentVersion != null)
{
DigitalAssetVO digitalAsset = DigitalAssetController.getLatestDigitalAssetVO(contentVersion.getId(), assetKey, db);
if(digitalAsset != null)
{
//String fileName = digitalAsset.getDigitalAssetId() + "_" + digitalAsset.getAssetFileName();
String fileName = DigitalAssetDeliveryController.getAssetFileName(digitalAsset, contentId, languageId, db);
//String folderName = "" + (digitalAsset.getDigitalAssetId().intValue() / 1000);
String folderName = DigitalAssetDeliveryController.getAssetFolderName(digitalAsset, contentId, languageId, db);
int i = 0;
File masterFile = null;
String filePath = CmsPropertyHandler.getDigitalAssetPath0() + File.separator + folderName;
while(filePath != null)
{
try
{
if(masterFile == null)
masterFile = DigitalAssetDeliveryController.getDigitalAssetDeliveryController().dumpDigitalAsset(digitalAsset, fileName, filePath, db);
else
DigitalAssetDeliveryController.getDigitalAssetDeliveryController().dumpDigitalAsset(masterFile, fileName, filePath);
}
catch(Exception e)
{
logger.warn("An file could not be written:" + e.getMessage(), e);
}
i++;
filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i);
if(filePath != null)
filePath += File.separator + folderName;
}
//SiteNodeVO siteNodeVO = getSiteNodeVO(db, siteNodeId);
String dnsName = CmsPropertyHandler.getWebServerAddress();
if(siteNodeVO != null)
{
RepositoryVO repositoryVO = RepositoryController.getController().getRepositoryVOWithId(siteNodeVO.getRepositoryId(), db);
if(repositoryVO.getDnsName() != null && !repositoryVO.getDnsName().equals(""))
dnsName = repositoryVO.getDnsName();
}
/*
SiteNode siteNode = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getSiteNode(db, siteNodeId);
String dnsName = CmsPropertyHandler.getWebServerAddress();
if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals(""))
dnsName = siteNode.getRepository().getDnsName();
*/
if(deliveryContext.getUseDownloadAction())
assetUrl = urlComposer.composeDigitalAssetUrl(dnsName, siteNodeId, contentId, languageId, assetKey, deliveryContext, db);
else
assetUrl = urlComposer.composeDigitalAssetUrl(dnsName, folderName, fileName, deliveryContext);
}
else if(useLanguageFallback)
{
assetUrl = getLanguageIndependentAssetUrl(contentId, languageId, siteNodeId, db, assetKey, deliveryContext, infoGluePrincipal);
}
}
else if(useLanguageFallback && languageId != null && masterLanguageVO != null && languageId.intValue() != masterLanguageVO.getId().intValue())
{
contentVersion = getSmallestContentVersionVO(siteNodeId, contentId, languageId, db, useLanguageFallback, deliveryContext, infoGluePrincipal);
logger.info("contentVersion:" + contentVersion);
if(contentVersion != null)