From da3487e3085d36cb8409e3fe4cf392f045609023 Mon Sep 17 00:00:00 2001 From: Jim Bowring Date: Sat, 20 Feb 2021 10:52:02 -0500 Subject: [PATCH 1/3] Fixed access to Sesar and Geochron apis --- pom.xml | 2 +- .../earthtime/archivingTools/URIHelper.java | 48 ++++++++++++++++++- .../dataDictionaries/SampleRegistries.java | 2 +- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index dd976ba7..19114723 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ com.thoughtworks.xstream xstream - 1.4.14 + 1.4.15 javax.help diff --git a/src/main/java/org/earthtime/archivingTools/URIHelper.java b/src/main/java/org/earthtime/archivingTools/URIHelper.java index 248dae8a..cf612b6f 100644 --- a/src/main/java/org/earthtime/archivingTools/URIHelper.java +++ b/src/main/java/org/earthtime/archivingTools/URIHelper.java @@ -33,6 +33,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; +import javax.net.ssl.HttpsURLConnection; import javax.swing.JOptionPane; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; @@ -64,6 +65,45 @@ public class URIHelper { public URIHelper() { } + /** + * + * @param fileURI + * @return + */ + public static InputStream getInputStreamFromHttpsURI(String fileURI) { + URL url; + HttpsURLConnection urlConn = null; + + InputStream retval = null; + try { + + url = new URL(fileURI); + + urlConn = (HttpsURLConnection) url.openConnection(); + + urlConn.setDoInput(true); + urlConn.setUseCaches(false); + // Feb 2021 started throwing 403 so used advice from + // https://stackoverflow.com/questions/13670692/403-forbidden-with-java-but-not-web-browser + urlConn.setRequestProperty( + "User-Agent", + "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); + + // july 2019 + urlConn.setConnectTimeout(10000); + urlConn.setReadTimeout(10000); + + retval = urlConn.getInputStream(); + + } catch (IOException iOException) { +// JOptionPane.showMessageDialog(null, +// new String[]{"Error reaching server: "// +// + iOException.getMessage()}); + } + + return retval; + } + /** * * @param fileURI @@ -137,7 +177,13 @@ public static BufferedReader getBufferedReader(String filename) Reader inReader = null; try { - if (filename.startsWith("http")) { + if (filename.startsWith("https")) { + try { + inReader = new InputStreamReader(getInputStreamFromHttpsURI(filename)); + reader = new BufferedReader(inReader); + } catch (Exception e) { + } + } else if (filename.startsWith("http")) { try { inReader = new InputStreamReader(getInputStreamFromURI(filename)); reader = new BufferedReader(inReader); diff --git a/src/main/java/org/earthtime/dataDictionaries/SampleRegistries.java b/src/main/java/org/earthtime/dataDictionaries/SampleRegistries.java index 15b2f1bd..9d67aee0 100644 --- a/src/main/java/org/earthtime/dataDictionaries/SampleRegistries.java +++ b/src/main/java/org/earthtime/dataDictionaries/SampleRegistries.java @@ -35,7 +35,7 @@ public enum SampleRegistries { /** * */ - GeochronID( "GeochronID", "GCH", "http://www.geochron.org/igsnexists.php?igsn=");// "http://www.geochronid.org/display.php?geochronid=" ), + GeochronID( "GeochronID", "GCH", "https://www.geochron.org/igsnexists.php?igsn=");// "http://www.geochronid.org/display.php?geochronid=" ), //EARTHTIME_ID( "EARTHTIME-ID", "ERT", "" ); From 0fb17e2490a0dd32b24d0f797b22567bf3cf554d Mon Sep 17 00:00:00 2001 From: Jim Bowring Date: Sat, 20 Feb 2021 11:00:55 -0500 Subject: [PATCH 2/3] Updated api test --- .../org/earthtime/dataDictionaries/SampleRegistriesTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/earthtime/dataDictionaries/SampleRegistriesTest.java b/src/test/java/org/earthtime/dataDictionaries/SampleRegistriesTest.java index 82a5e6f4..8ff6c1a9 100644 --- a/src/test/java/org/earthtime/dataDictionaries/SampleRegistriesTest.java +++ b/src/test/java/org/earthtime/dataDictionaries/SampleRegistriesTest.java @@ -44,13 +44,13 @@ public class SampleRegistriesTest { */ @Test public void test_constructor_0(){ - System.out.println("Testing SampleRegistries's enumerations and getters."); + System.out.println("Testing SampleRegistries' enumerations and getters."); //Tests if values are correct for all enumerations, and tests the getters as well. You cannot instantiate new inumerations. SampleRegistries ave=SampleRegistries.GeochronID; assertEquals("GeochronID",ave.getName()); assertEquals("GCH",ave.getCode()); - assertEquals("http://www.geochron.org/igsnexists.php?igsn=",ave.getConnectionString()); + assertEquals("https://www.geochron.org/igsnexists.php?igsn=",ave.getConnectionString()); ave=SampleRegistries.SESAR; assertEquals("SESAR",ave.getName()); From 443882f44ec14e6fc4e7dd2df5f5a4a399ca3b25 Mon Sep 17 00:00:00 2001 From: Jim Bowring Date: Sat, 20 Feb 2021 11:03:52 -0500 Subject: [PATCH 3/3] New version 3.6.91 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 19114723..51ad5158 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.cirdles ET_Redux ET_Redux - 3.6.90 + 3.6.91 Successor to U-Pb_Redux https://cirdles.org 2006