public void createByCopy(Integer originalContentVersionId, MediumContentVersionImpl cv, Map<Integer,Integer> assetIdMap, Database db) throws ConstraintException, SystemException
{
logger.info("Creating by copying....");
logger.info("originalContentVersionId:" + originalContentVersionId);
//logger.info("newContentVersionId:" + newContentVersionId);
ContentVersion oldContentVersion = ContentVersionController.getContentVersionController().getMediumContentVersionWithId(originalContentVersionId, db);
Collection<DigitalAsset> assets = oldContentVersion.getDigitalAssets();
logger.info("assets:" + assets);
for(DigitalAsset oldDigitalAsset : assets)
{
//ContentVersion contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(newContentVersionId, db);
if(assetIdMap.containsKey(oldDigitalAsset.getId()))
{
logger.info("The asset was allready copied by another version - let's just connect the new one");
MediumDigitalAssetImpl newDigitalAsset = getMediumDigitalAssetWithId(assetIdMap.get(oldDigitalAsset.getId()), db);
newDigitalAsset.getContentVersions().add(cv);
}
else
{
Collection contentVersions = new ArrayList();
contentVersions.add(cv);
try
{
String filePath = getDigitalAssetFilePath(oldDigitalAsset.getValueObject(), db);
File oldAssetFile = new File(filePath);
logger.info("Creating asset for:" + oldDigitalAsset.getAssetKey() + ":" + oldContentVersion.getId() + "/" + cv.getId());
DigitalAssetVO digitalAssetVO = new DigitalAssetVO();
digitalAssetVO.setAssetContentType(oldDigitalAsset.getAssetContentType());
digitalAssetVO.setAssetFileName(oldDigitalAsset.getAssetFileName());
digitalAssetVO.setAssetFilePath(oldDigitalAsset.getAssetFilePath());
digitalAssetVO.setAssetFileSize(oldDigitalAsset.getAssetFileSize());