{
Iterator digitalAssetsIterator = digitalAssets.iterator();
while(digitalAssetsIterator.hasNext())
{
DigitalAsset digitalAsset = (DigitalAsset)digitalAssetsIterator.next();
logger.info("Make copy of reference to digitalAssets " + digitalAsset.getAssetKey());
if(excludedAssetId == null || !digitalAsset.getId().equals(excludedAssetId))
{
newContentVersion.getDigitalAssets().add(digitalAsset);
digitalAsset.getContentVersions().add(newContentVersion);
}
else
{
logger.info("Not copying the excluded asset:" + digitalAsset.getId());
}
}
}
else
{
Iterator digitalAssetsIterator = digitalAssets.iterator();
while(digitalAssetsIterator.hasNext())
{
DigitalAsset digitalAsset = (DigitalAsset)digitalAssetsIterator.next();
if(excludedAssetId == null || !digitalAsset.getId().equals(excludedAssetId))
{
logger.info("Copying digitalAssets " + digitalAsset.getAssetKey());
DigitalAssetVO digitalAssetVO = digitalAsset.getValueObject();
InputStream is = DigitalAssetController.getController().getAssetInputStream(digitalAsset, true);
if(is == null && !allowBrokenAssets)
throw new ConstraintException("DigitalAsset.assetBlob", "3308", "Broken asset found on content '" + originalContentVersion.getValueObject().getContentName() + "' with id " + originalContentVersion.getValueObject().getContentId());
try
{
synchronized (is)
{
DigitalAssetController.create(digitalAssetVO, is, newContentVersion, db);
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if(is != null)
is.close();
}
}
else
{
logger.info("Not copying the excluded asset:" + digitalAsset.getId());
}
logger.info("digitalAssets:" + digitalAssets.size());
}
}
}