if (null != repoUrlOs) {
oses = repoUrlOs.split(",");
}
AmbariMetaInfo ami = injector.getInstance(AmbariMetaInfo.class);
MetainfoDAO metaDao = injector.getInstance(MetainfoDAO.class);
String stackRepoId = stackName + "-" + stackVersion;
if (0 == oses.length) {
// do them all
for (OperatingSystemInfo osi : ami.getOperatingSystems(stackName, stackVersion)) {
ami.updateRepoBaseURL(stackName, stackVersion, osi.getOsType(),
stackRepoId, repoUrl);
}
} else {
for (String os : oses) {
OsFamily family = OsFamily.find(os);
if (null != family) {
String key = ami.generateRepoMetaKey(stackName, stackVersion, os,
stackName + "-" + stackVersion, AmbariMetaInfo.REPOSITORY_XML_PROPERTY_BASEURL);
String familyKey = ami.generateRepoMetaKey(stackName, stackVersion,
family.name().toLowerCase(), stackRepoId, AmbariMetaInfo.REPOSITORY_XML_PROPERTY_BASEURL);
// need to use (for example) redhat6 if the os is centos6
MetainfoEntity entity = metaDao.findByKey(key);
if (null == entity) {
entity = new MetainfoEntity();
entity.setMetainfoName(key);
entity.setMetainfoValue(repoUrl);
metaDao.merge(entity);
} else {
entity.setMetainfoValue(repoUrl);
metaDao.merge(entity);
}
entity = metaDao.findByKey(familyKey);
if (null == entity) {
entity = new MetainfoEntity();
entity.setMetainfoName(familyKey);
entity.setMetainfoValue(repoUrl);
metaDao.merge(entity);
} else {
entity.setMetainfoValue(repoUrl);
metaDao.merge(entity);
}
}
}
}
}