{
logger.info("digitalAssets:" + digitalAssets.size());
Iterator<RemoteAttachment> digitalAssetIterator = digitalAssets.iterator();
while(digitalAssetIterator.hasNext())
{
RemoteAttachment remoteAttachment = digitalAssetIterator.next();
logger.info("digitalAssets in ws:" + remoteAttachment);
InputStream is = new ByteArrayInputStream(remoteAttachment.getBytes());
DigitalAssetVO existingAssetVO = DigitalAssetController.getLatestDigitalAssetVO(contentVersionVO.getId(), remoteAttachment.getName());
if(updateExistingAssets && existingAssetVO != null)
{
ContentVersionController.getContentVersionController().deleteDigitalAssetRelation(contentVersionVO.getId(), existingAssetVO.getId(), principal);
DigitalAssetVO digitalAssetVO = new DigitalAssetVO();
digitalAssetVO.setAssetContentType(remoteAttachment.getContentType());
digitalAssetVO.setAssetKey(remoteAttachment.getName());
digitalAssetVO.setAssetFileName(remoteAttachment.getFileName());
digitalAssetVO.setAssetFilePath(remoteAttachment.getFilePath());
digitalAssetVO.setAssetFileSize(new Integer(new Long(remoteAttachment.getBytes().length).intValue()));
DigitalAssetController.create(digitalAssetVO, is, contentVersionVO.getContentVersionId(), principal);
}
else
{
DigitalAssetVO newAsset = new DigitalAssetVO();
newAsset.setAssetContentType(remoteAttachment.getContentType());
newAsset.setAssetKey(remoteAttachment.getName());
newAsset.setAssetFileName(remoteAttachment.getFileName());
newAsset.setAssetFilePath(remoteAttachment.getFilePath());
newAsset.setAssetFileSize(new Integer(new Long(remoteAttachment.getBytes().length).intValue()));
DigitalAssetController.create(newAsset, is, contentVersionVO.getContentVersionId(), principal);
}
}
}