@@ -1396,13 +1396,22 @@ private Set<Pair<Long, Long>> listTemplates(Long templateId, String name, String
13961396 if (template == null ) {
13971397 templateZonePairSet = _templateDao .searchSwiftTemplates (name , keyword , templateFilter , isIso , hypers , bootable , domain , pageSize , startIndex , zoneId , hyperType , onlyReady , showDomr ,
13981398 permittedAccounts , caller );
1399+ Set <Pair <Long , Long >> templateZonePairSet2 = new HashSet <Pair <Long , Long >>();
1400+ templateZonePairSet2 = _templateDao .searchTemplates (name , keyword , templateFilter , isIso , hypers , bootable , domain , pageSize , startIndex , zoneId , hyperType , onlyReady , showDomr ,
1401+ permittedAccounts , caller );
1402+ for (Pair <Long , Long > tmpltPair : templateZonePairSet2 ) {
1403+ if (!templateZonePairSet .contains (new Pair <Long , Long >(tmpltPair .first (), 0L ))) {
1404+ templateZonePairSet .add (tmpltPair );
1405+ }
1406+ }
1407+
13991408 } else {
14001409 // if template is not public, perform permission check here
14011410 if (!template .isPublicTemplate () && caller .getType () != Account .ACCOUNT_TYPE_ADMIN ) {
14021411 Account owner = _accountMgr .getAccount (template .getAccountId ());
14031412 _accountMgr .checkAccess (caller , null , owner );
14041413 }
1405- templateZonePairSet .add (new Pair <Long , Long >(template .getId (), 0L ));
1414+ templateZonePairSet .add (new Pair <Long , Long >(template .getId (), zoneId ));
14061415 }
14071416 } else {
14081417 if (template == null ) {
0 commit comments