bug 8074: making xen-tools.iso available to a normal user

status 8074: resolved fixed
This commit is contained in:
abhishek 2011-02-14 11:22:26 -08:00
parent 1ff3aefd1a
commit 3e1fa215c3
2 changed files with 23 additions and 4 deletions

View File

@ -57,6 +57,7 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long> {
public List<VMTemplateVO> searchTemplates(String name, String keyword, TemplateFilter templateFilter, boolean isIso, Boolean bootable, Account account, DomainVO domain, Integer pageSize, Long startIndex, Long zoneId);
public long addTemplateToZone(VMTemplateVO tmplt, long zoneId);
public List<VMTemplateVO> listAllInZone(long dataCenterId);
public List<VMTemplateVO> listAllInZone(long dataCenterId);
public List<VMTemplateVO> listXenToolsIso();
}

View File

@ -67,6 +67,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
protected SearchBuilder<VMTemplateVO> PublicSearch;
private String routerTmpltName;
private String consoleProxyTmpltName;
protected SearchBuilder<VMTemplateVO> XenToolsSearch;
protected VMTemplateDaoImpl() {
}
@ -133,7 +134,13 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
sc.setParameters("publicTemplate", false);
return listActiveBy(sc);
}
@Override
public List<VMTemplateVO> listXenToolsIso() {
SearchCriteria sc = XenToolsSearch.create();
sc.setParameters("uniqueName", "xs-tools.iso");
return listBy(sc);
}
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
boolean result = super.configure(name, params);
@ -165,7 +172,10 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
AccountIdSearch.and("publicTemplate", AccountIdSearch.entity().isPublicTemplate(), SearchCriteria.Op.EQ);
AccountIdSearch.done();
XenToolsSearch = createSearchBuilder();
XenToolsSearch.and("uniqueName", XenToolsSearch.entity().getUniqueName(), SearchCriteria.Op.EQ);
AccountIdSearch.done();
return result;
}
@ -240,7 +250,15 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
} else {
templates.add(tmplt);
}
}
}
//if normal user, add xentools.iso
if(accountType == Account.ACCOUNT_TYPE_NORMAL && isIso) {
List<VMTemplateVO> xenTools = listXenToolsIso();
if(xenTools.size() > 0)
templates.add(xenTools.get(0));
}
} catch (Exception e) {
s_logger.warn("Error listing templates", e);
} finally {