From c0f22970d3958093918c6f38bcc3d8a95a8eb373 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 a4046cdb846..03cc2df51db 100755 --- a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java +++ b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java @@ -528,8 +528,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();