@Override
public TemplateInfo getTemplate(long templateId, DataStore store) {
VMTemplateVO templ = imageDataDao.findById(templateId);
if (store == null) {
TemplateObject tmpl = TemplateObject.getTemplate(templ, null);
return tmpl;
}
// verify if the given input parameters are consistent with our db data.
boolean found = false;
if (store.getRole() == DataStoreRole.Primary) {
VMTemplateStoragePoolVO templatePoolVO = templatePoolDao.findByPoolTemplate(store.getId(), templateId);
if (templatePoolVO != null) {
found = true;
}
} else {
TemplateDataStoreVO templateStoreVO = templateStoreDao.findByStoreTemplate(store.getId(), templateId);
if (templateStoreVO != null) {
found = true;
}
}
if (s_logger.isDebugEnabled()) {
if (!found) {
s_logger.debug("template " + templateId + " is not in store:" + store.getId() + ", type:" + store.getRole());
} else {
s_logger.debug("template " + templateId + " is already in store:" + store.getId() + ", type:" + store.getRole());
}
}
TemplateObject tmpl = TemplateObject.getTemplate(templ, store);
return tmpl;
}