LibraryResolverMaven(DbConn cnx) { mavenRepos = GlobalParameter.getParameter(cnx, "mavenRepo", "http://repo1.maven.org/maven2/").split(","); mavenSettingsClPath = GlobalParameter.getParameter(cnx, "mavenSettingsCL", null); mavenSettingsFilePath = GlobalParameter.getParameter(cnx, "mavenSettingsFile", null); }
/** * Set or update a global parameter. */ public void addGlobalParameter(String key, String value) { GlobalParameter.setParameter(cnx, key, value); cnx.commit(); }
public static void setParameter(DbConn cnx, String key, String value) { QueryResult qr = cnx.runUpdate("globalprm_update_value_by_key", value, key); if (qr.nbUpdated == 0) { create(cnx, key, value); } } }
static void dumpParameters(DbConn cnx, Node n) String terse = GlobalParameter.getParameter(cnx, "disableVerboseStartup", "false"); if ("false".equals(terse)) List<GlobalParameter> prms = GlobalParameter.select(cnx, "globalprm_select_all"); for (GlobalParameter prm : prms) jqmlogger.info(String.format("\t%1$s = %2$s", prm.getKey(), prm.getValue()));
public static List<GlobalParameter> select(DbConn cnx, String query_key, Object... args) { List<GlobalParameter> res = new ArrayList<GlobalParameter>(); try { ResultSet rs = cnx.runSelect(query_key, args); while (rs.next()) { GlobalParameter tmp = new GlobalParameter(); tmp.id = rs.getInt(1); tmp.key = rs.getString(2); tmp.value = rs.getString(3); Calendar c = Calendar.getInstance(); c.setTimeInMillis(rs.getTimestamp(4).getTime()); tmp.lastModified = c; res.add(tmp); } } catch (SQLException e) { throw new DatabaseException(e); } return res; }
static void dumpParameters(DbConn cnx, Node n) String terse = GlobalParameter.getParameter(cnx, "disableVerboseStartup", "false"); if ("false".equals(terse)) List<GlobalParameter> prms = GlobalParameter.select(cnx, "globalprm_select_all"); for (GlobalParameter prm : prms) jqmlogger.info(String.format("\t%1$s = %2$s", prm.getKey(), prm.getValue()));
public static List<GlobalParameter> select(DbConn cnx, String query_key, Object... args) { List<GlobalParameter> res = new ArrayList<>(); try { ResultSet rs = cnx.runSelect(query_key, args); while (rs.next()) { GlobalParameter tmp = new GlobalParameter(); tmp.id = rs.getInt(1); tmp.key = rs.getString(2); tmp.value = rs.getString(3); Calendar c = Calendar.getInstance(); c.setTimeInMillis(rs.getTimestamp(4).getTime()); tmp.lastModified = c; res.add(tmp); } } catch (SQLException e) { throw new DatabaseException(e); } return res; }
private void setIsolationDefault(DbConn cnx) { this.launchIsolationDefault = GlobalParameter.getParameter(cnx, "launch_isolation_default", "Isolated"); String rns = GlobalParameter.getParameter(cnx, "job_runners", "com.enioka.jqm.tools.LegacyRunner,com.enioka.jqm.tools.MainRunner,com.enioka.jqm.tools.RunnableRunner"); for (String s : rns.split(",")) { runnerClasses.add(s); jqmlogger.info("Detected a job instance runner named " + s); } }
/** * Set or update a global parameter. */ public void addGlobalParameter(String key, String value) { GlobalParameter.setParameter(cnx, key, value); cnx.commit(); }
public static void setParameter(DbConn cnx, String key, String value) { QueryResult qr = cnx.runUpdate("globalprm_update_value_by_key", value, key); if (qr.nbUpdated == 0) { create(cnx, key, value); } } }
/** * Create a new GP entry in the database. No commit performed. */ public static GlobalParameter create(DbConn cnx, String key, String value) { QueryResult r = cnx.runUpdate("globalprm_insert", key, value); GlobalParameter res = new GlobalParameter(); res.id = r.getGeneratedId(); res.key = key; res.value = value; return res; }
private String getFileProtocol(DbConn cnx) { if (protocol == null) { protocol = "http://"; try { String prm = GlobalParameter.getParameter(cnx, "enableWsApiSsl", "false"); if (Boolean.parseBoolean(prm)) { protocol = "https://"; } } catch (NoResultException e) { protocol = "http://"; } } return protocol; }
public static void upsertGlobalParameter(DbConn cnx, GlobalParameterDto dto) { if (dto == null || dto.getKey() == null || dto.getKey().isEmpty() || dto.getValue() == null || dto.getValue().isEmpty()) { throw new IllegalArgumentException("invalid dto object"); } GlobalParameter.setParameter(cnx, dto.getKey(), dto.getValue()); }
/** * Checks if a parameter exists. If it exists, it is left untouched. If it doesn't, it is created. Only works for parameters which key * is unique. Must be called from within an open transaction. */ static void initSingleParam(String key, String initValue, DbConn cnx) { try { cnx.runSelectSingle("globalprm_select_by_key", 2, String.class, key); return; } catch (NoResultException e) { GlobalParameter.create(cnx, key, initValue); } catch (NonUniqueResultException e) { // It exists! Nothing to do... } }
/** * Create a new GP entry in the database. No commit performed. */ public static GlobalParameter create(DbConn cnx, String key, String value) { QueryResult r = cnx.runUpdate("globalprm_insert", key, value); GlobalParameter res = new GlobalParameter(); res.id = r.getGeneratedId(); res.key = key; res.value = value; return res; }
@Override public String defaultConnect() { DbConn cnx = Helpers.getNewDbSession(); try { return GlobalParameter.getParameter(cnx, "defaultConnection", null); } finally { Helpers.closeQuietly(cnx); } }
public static void upsertGlobalParameter(DbConn cnx, GlobalParameterDto dto) { if (dto == null || dto.getKey() == null || dto.getKey().isEmpty() || dto.getValue() == null || dto.getValue().isEmpty()) { throw new IllegalArgumentException("invalid dto object"); } GlobalParameter.setParameter(cnx, dto.getKey(), dto.getValue()); }
/** * Checks if a parameter exists. If it exists, it is left untouched. If it doesn't, it is created. Only works for parameters which key * is unique. Must be called from within an open transaction. */ static void initSingleParam(String key, String initValue, DbConn cnx) { try { cnx.runSelectSingle("globalprm_select_by_key", 2, String.class, key); return; } catch (NoResultException e) { GlobalParameter.create(cnx, key, initValue); } catch (NonUniqueResultException e) { // It exists! Nothing to do... } }
@Override public String defaultConnect() { DbConn cnx = Helpers.getNewDbSession(); try { return GlobalParameter.getParameter(cnx, "defaultConnection", null); } finally { Helpers.closeQuietly(cnx); } }
String value = gpElement.getElementsByTagName("value").item(0).getTextContent().trim(); GlobalParameter.setParameter(cnx, key, value); jqmlogger.info("Imported global parameter key: " + key + " - value: " + value);