From 09562e771c9e14d81fcdab81bd408611b31f3ef8 Mon Sep 17 00:00:00 2001 From: anthony Date: Fri, 1 Jul 2011 16:17:18 -0700 Subject: [PATCH] per angie, Below sequence doesn't work 1. copy template1 from z1 to z2 2. remove template1 from z2 3. copy tempalte1 from z1 to z2 again, 4. template1 for z2 doesn't show up in MyTemplate fixed --- .../src/com/cloud/storage/dao/VMTemplateDaoImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java index e75437e5ba7..139bc576736 100755 --- a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java +++ b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java @@ -520,8 +520,15 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem if (tmplt2 == null){ persist(tmplt); } - VMTemplateZoneVO tmpltZoneVO = new VMTemplateZoneVO(zoneId, tmplt.getId(), new Date()); - _templateZoneDao.persist(tmpltZoneVO); + VMTemplateZoneVO tmpltZoneVO = _templateZoneDao.findByZoneTemplate(zoneId, tmplt.getId()); + if ( tmpltZoneVO == null ) { + tmpltZoneVO = new VMTemplateZoneVO(zoneId, tmplt.getId(), new Date()); + _templateZoneDao.persist(tmpltZoneVO); + } else { + tmpltZoneVO.setRemoved(null); + tmpltZoneVO.setLastUpdated(new Date()); + _templateZoneDao.update(tmpltZoneVO.getId(), tmpltZoneVO); + } txn.commit(); return tmplt.getId();