Resource tags: CS-15591 - delete tags for template/iso when corresponding vo object is removed

This commit is contained in:
Alena Prokharchyk 2012-07-16 14:36:13 -07:00
parent 38e0c4b31a
commit 0fdf1a1d8a
1 changed files with 4 additions and 2 deletions

View File

@ -851,8 +851,10 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
txn.start();
VMTemplateVO template = createForUpdate();
template.setRemoved(new Date());
if (template != null) {
if (template.getFormat() == ImageFormat.ISO) {
VMTemplateVO vo = findById(id);
if (vo != null) {
if (vo.getFormat() == ImageFormat.ISO) {
_tagsDao.removeByIdAndType(id, TaggedResourceType.ISO);
} else {
_tagsDao.removeByIdAndType(id, TaggedResourceType.Template);