return ((ClufVersionImpl)foundClufs.get(0));
}
public synchronized ClufImpl getCurrentVersion(String language) {
HibernateTemplate t = new HibernateTemplate(getSessionFactory());
ClufVersionImpl version = getCurrentClufVersion();
List currentCluf = t.find("from " + ClufImpl.class.getName() + " c where c.clufVersion = ? and c.language = ?", new Object[] {version, language});
if (currentCluf.size() == 0) {
if ("en".equals(language)) {
throw new IllegalStateException("no cluf found for "+version.getVersion()+" language=en");
} else {
// maybe the language is unknown, let's try with english
currentCluf = t.find("from " + ClufImpl.class.getName() + " c where c.clufVersion = ? and c.language = ?", new Object[] {version, "en"});
if (currentCluf.size() == 0) {
throw new IllegalStateException("no cluf found for "+version.getVersion()+" language="+language+",en");
}
}
}
LOGGER.debug("found " + currentCluf.size() + " cluf as current cluf for "+language);
return ((ClufImpl)currentCluf.get(0));