while (results.hasMore())
{
boolean keep = true;
SmallDigitalAssetImpl digitalAsset = (SmallDigitalAssetImpl)results.next();
if(digitalAsset.getAssetKey().equals("portletentityregistry.xml"))
keep = false;
List<SmallestContentVersionVO> contentVersions = DigitalAssetController.getController().getContentVersionVOListConnectedToAssetWithId(digitalAsset.getId());
//Collection contentVersions = digitalAsset.getContentVersions();
Iterator<SmallestContentVersionVO> contentVersionsIterator = contentVersions.iterator();
SmallestContentVersionVO contentVersionVO = null;
while(contentVersionsIterator.hasNext())
{
contentVersionVO = contentVersionsIterator.next();
if(!isOldVersion(contentVersionVO, numberOfVersionsToKeep, db))
keep = false;
}
if(contentVersionVO != null && keep)
{
if(contentVersionVO.getContentId() != null)
{
String contentPath = ContentController.getContentController().getContentPath(contentVersionVO.getContentId(), true, true, db);
optimizationBeanList.addDigitalAsset(digitalAsset);
optimizationBeanList.addEventVersions(contentVersions);
optimizationBeanList.setContentPath(digitalAsset.getId(), contentPath);
}
else
{
logger.error("ContentVersion with id:" + contentVersionVO.getId() + " had no ownningcontent");
}