List initialContentCategories = new ArrayList();
Iterator contentCategoriesIterator = contentCategories.iterator();
while(contentCategoriesIterator.hasNext())
{
ContentCategory contentCategory = (ContentCategory)contentCategoriesIterator.next();
logger.info("contentCategory:" + contentCategory);
contentCategory.setContentVersion((ContentVersionImpl)contentVersion);
Integer oldCategoryId = contentCategory.getCategoryId();
logger.info("oldCategoryId:" + oldCategoryId);
if(!isCopyAction)
{
Integer newCategoryId = (Integer)categoryIdMap.get(oldCategoryId);
logger.info("newCategoryId:" + newCategoryId);
if(newCategoryId == null)
newCategoryId = oldCategoryId;
if(newCategoryId != null)
{
Category category = CategoryController.getController().findById(newCategoryId, db);
logger.info("Got category:" + category);
if(category != null)
{
contentCategory.setCategory((CategoryImpl)category);
logger.info("Creating content category:" + contentCategory);
db.create(contentCategory);
initialContentCategories.add(contentCategory);
}
}
}
else
{
Category category = CategoryController.getController().findById(oldCategoryId, db);
logger.info("Got category:" + category);
if(category != null)
{
contentCategory.setCategory((CategoryImpl)category);
logger.info("Creating content category:" + contentCategory);
db.create(contentCategory);
initialContentCategories.add(contentCategory);