diff --git a/vcell-client/src/main/java/cbit/vcell/client/VCellClientMain.java b/vcell-client/src/main/java/cbit/vcell/client/VCellClientMain.java index 78467c7d5b..d3d0c55c61 100644 --- a/vcell-client/src/main/java/cbit/vcell/client/VCellClientMain.java +++ b/vcell-client/src/main/java/cbit/vcell/client/VCellClientMain.java @@ -35,6 +35,7 @@ import javax.swing.*; import java.io.File; import java.lang.management.ManagementFactory; +import java.net.URL; import java.util.Arrays; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.Callable; @@ -118,7 +119,11 @@ public Integer call() throws Exception { Injector injector = Guice.createInjector(new VCellClientModule(apihost, apiport, pathPrefixV0)); this.vcellClient = injector.getInstance(VCellClient.class); - Thread dynamicClientPropertiesThread = new Thread(() -> BeanUtils.updateDynamicClientProperties()); + // see static-files-config ConfigMap for definitions of dynamic properties as deployed + String url_path = PropertyLoader.getProperty(PropertyLoader.DYNAMIC_PROPERTIES_URL_PATH, "/vcell_dynamic_properties.csv"); + String webapp_base_url = "https://" + apihost + ":" + apiport; + URL vcell_dynamic_client_properties_url = new URL(webapp_base_url + url_path); + Thread dynamicClientPropertiesThread = new Thread(() -> BeanUtils.updateDynamicClientProperties(vcell_dynamic_client_properties_url)); dynamicClientPropertiesThread.setDaemon(false); // non-daemon thread to keep JVM running dynamicClientPropertiesThread.start(); diff --git a/vcell-core/src/main/java/cbit/vcell/client/server/ClientServerManager.java b/vcell-core/src/main/java/cbit/vcell/client/server/ClientServerManager.java index 5d17c7b2f2..88e36ad593 100644 --- a/vcell-core/src/main/java/cbit/vcell/client/server/ClientServerManager.java +++ b/vcell-core/src/main/java/cbit/vcell/client/server/ClientServerManager.java @@ -35,6 +35,8 @@ import org.vcell.util.document.VCellSoftwareVersion.VCellSite; import java.io.IOException; +import java.net.URL; + /** * Insert the type's description here. * Creation date: (5/12/2004 4:31:18 PM) @@ -373,7 +375,15 @@ public void connectAs(InteractiveContext requester, String user, DigestedPasswor * Creation date: (5/12/2004 4:48:13 PM) */ private VCellConnection connectToServer(InteractiveContext requester,boolean bShowErrors) { - BeanUtils.updateDynamicClientProperties(); + try { + // see static-files-config ConfigMap for definitions of dynamic properties as deployed + String url_path = PropertyLoader.getProperty(PropertyLoader.DYNAMIC_PROPERTIES_URL_PATH, "/vcell_dynamic_properties.csv"); + String webapp_base_url = "https://" + getClientServerInfo().getApihost() + ":" + getClientServerInfo().getApiport(); + URL vcell_dynamic_client_properties_url = new URL(webapp_base_url + url_path); + BeanUtils.updateDynamicClientProperties(vcell_dynamic_client_properties_url); + } catch (Exception e) { + lg.error(e.getMessage(), e); + } VCellThreadChecker.checkRemoteInvocation(); VCellConnection newVCellConnection = null; diff --git a/vcell-core/src/main/java/cbit/vcell/resource/PropertyLoader.java b/vcell-core/src/main/java/cbit/vcell/resource/PropertyLoader.java index ccd75d0186..b46712bab5 100644 --- a/vcell-core/src/main/java/cbit/vcell/resource/PropertyLoader.java +++ b/vcell-core/src/main/java/cbit/vcell/resource/PropertyLoader.java @@ -146,7 +146,8 @@ public static void setConfigProvider(VCellConfigProvider configProvider) { public static final String bioformatsJarFileName = record("vcell.bioformatsJarFileName",ValueType.GEN); public static final String bioformatsJarDownloadURL = record("vcell.bioformatsJarDownloadURL",ValueType.URL); - // VCell special URLs + // VCell special URLs which are loaded from web server at path DYNAMIC_PROPERTIES_URL_PATH (default /vcell_dynamic_properties.csv) + public static final String DYNAMIC_PROPERTIES_URL_PATH = record("vcell.dynamicPropertiesUrlPath",ValueType.GEN); public static final String COPASI_WEB_URL = record("vcell.COPASI_WEB_URL",ValueType.URL); public static final String SMOLDYN_WEB_URL = record("vcell.SMOLDYN_WEB_URL",ValueType.URL); public static final String BIONETGEN_WEB_URL = record("vcell.BIONETGEN_WEB_URL",ValueType.URL); @@ -177,7 +178,7 @@ public static void setConfigProvider(VCellConfigProvider configProvider) { public static final String BIOPAX_RSABIO65_URL = record("vcell.BIOPAX_RSABIO65_URL",ValueType.URL); public static final String BIOPAX_RKEGGR01026_URL = record("vcell.BIOPAX_RKEGGR01026_URL",ValueType.URL); public static final String COMSOL_URL = record("vcell.COMSOL_URL",ValueType.URL); - + // public static final String databaseThreadsProperty = record("vcell.databaseThreads",ValueType.GEN); public static final String exportdataThreadsProperty = record("vcell.exportdataThreads",ValueType.GEN); diff --git a/vcell-util/src/main/java/org/vcell/util/BeanUtils.java b/vcell-util/src/main/java/org/vcell/util/BeanUtils.java index 7854f32357..5c0ad6d63f 100644 --- a/vcell-util/src/main/java/org/vcell/util/BeanUtils.java +++ b/vcell-util/src/main/java/org/vcell/util/BeanUtils.java @@ -11,27 +11,6 @@ package org.vcell.util; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Serializable; -import java.math.BigDecimal; -import java.net.InetSocketAddress; -import java.net.URL; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.concurrent.Executors; - -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; -import javax.net.ssl.HttpsURLConnection; - import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVRecord; import org.apache.logging.log4j.LogManager; @@ -40,11 +19,24 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; -import org.jboss.netty.handler.codec.http.DefaultHttpRequest; -import org.jboss.netty.handler.codec.http.HttpHeaders; -import org.jboss.netty.handler.codec.http.HttpMethod; -import org.jboss.netty.handler.codec.http.HttpRequest; -import org.jboss.netty.handler.codec.http.HttpVersion; +import org.jboss.netty.handler.codec.http.*; + +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import javax.net.ssl.HttpsURLConnection; +import java.io.*; +import java.math.BigDecimal; +import java.net.InetSocketAddress; +import java.net.URL; +import java.time.format.DateTimeFormatter; +import java.util.Calendar; +import java.util.Map; +import java.util.TreeMap; +import java.util.concurrent.Executors; /** * Insert the type's description here. @@ -82,24 +74,18 @@ public static synchronized VCellDynamicProps getDynamicClientProperties(){ return vcellDynamicProps; } - public static synchronized void updateDynamicClientProperties(){ + public static synchronized void updateDynamicClientProperties(URL vcell_dynamic_properties_url) { Map temp = new TreeMap<>(); HttpsURLConnection conn; - //"https://vcell.org/webstart/dynamicClientProperties.txt" try { - //HttpURLConnection conn = new HttpURLConnection(new GetMethod(), new URL("http://dockerbuild:8080")); - //https://vcell.org/webstart/vcell_dynamic_properties.csv -// HttpURLConnection conn = (HttpURLConnection)(new URL("http://dockerbuild:8080")).openConnection(); - conn = (HttpsURLConnection) (new URL("https://vcell.org/webstart/vcell_dynamic_properties.csv")).openConnection(); + conn = (HttpsURLConnection) vcell_dynamic_properties_url.openConnection(); conn.setRequestMethod("GET"); conn.setConnectTimeout(5000); conn.setReadTimeout(5000); try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()))) { Iterable records = CSVFormat.DEFAULT -// .withHeader(HEADERS) -// .withFirstRecordAsHeader() .withIgnoreSurroundingSpaces() .withQuote('"') .parse(br);