Red Hat Application Migration Toolkit
package dvk.api; import dvk.api.ISessionCacheBox; import dvk.api.ml.DvkSessionCacheBox; import dvk.api.ml.Util; import java.io.File; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class DVKAPI { private static Exception serverTestError; private static Session session; public static Exception getTestServerError() { return serverTestError; } public static boolean testServer(String configFileName) { serverTestError = null; org.hibernate.classic.Session sess = null; boolean var3; try { SessionFactory ex = Util.isEmpty(configFileName)?createSessionFactory("hibernate_ora_dvk.cfg.xml"):createSessionFactory(configFileName); sess = ex.openSession(); var3 = true; return var3; } catch (Exception var7) { serverTestError = var7; var3 = false; } finally { if(sess != null) { sess.close(); } } return var3; } public static SessionFactory createSessionFactory(String configFileName) { if(configFileName != null && configFileName.length() != 0) { try { return (new Configuration()).configure(configFileName).buildSessionFactory(); } catch (Throwable var2) { throw new ExceptionInInitializerError(var2); } } else { throw new RuntimeException("Config file name cannot be null.\nTo use default config file name call parameterless method \'CreateSessionFactory\'."); } } public static SessionFactory createSessionFactory(File configFile) { if(configFile == null) { throw new RuntimeException("Config file cannot be null.\nTo use default config file name call parameterless method \'CreateSessionFactory\'."); } else { try { return (new Configuration()).configure(configFile).buildSessionFactory(); } catch (Throwable var2) { throw new ExceptionInInitializerError(var2); } } } public static Session getGlobalSession() { return session; } public static Session openGlobalSession(String configFileName) throws HibernateException { if(Util.isEmpty(configFileName)) { throw new RuntimeException("Configuration file is absent"); } else { if(session == null) { session = createSessionFactory(configFileName).openSession(); } return session; } } public static void closeGlobalSession() { if(session != null) { session.close(); session = null; } } public static ISessionCacheBox createSessionCacheBox(Session sess) { return new DvkSessionCacheBox(sess); } public static enum DvkType { Counter, Organization, Occupation, Subdivision, Settings, SettingsFolder, Message, MessageRecipient; } }