From 3e912e689b988d1c8fe85f87a9374d7f7a40dbae Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 20 Dec 2023 20:28:11 +0000 Subject: [PATCH] JAL-4059 Added some more Platform.addJ2SDirectDatabaseCall web service URLs in static blocks in appropriate classes. Altered addJ2SDirectDatabaseCall to only add scheme://host:port and not path. --- src/jalview/ext/ensembl/EnsemblRestClient.java | 4 +- src/jalview/fts/service/pdb/PDBFTSRestClient.java | 22 +++++----- .../threedbeacons/TDBeaconsFTSRestClient.java | 14 ++++--- src/jalview/util/Platform.java | 43 +++++++++++++------- src/jalview/ws/dbsources/TDBeacons.java | 41 +++++++++++-------- src/jalview/ws/dbsources/Uniprot.java | 6 +++ src/jalview/ws/ebi/EBIFetchClient.java | 20 ++++----- 7 files changed, 87 insertions(+), 63 deletions(-) diff --git a/src/jalview/ext/ensembl/EnsemblRestClient.java b/src/jalview/ext/ensembl/EnsemblRestClient.java index 709136c..3fe219c 100644 --- a/src/jalview/ext/ensembl/EnsemblRestClient.java +++ b/src/jalview/ext/ensembl/EnsemblRestClient.java @@ -49,8 +49,8 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher static { - Platform.addJ2SDirectDatabaseCall("http://rest.ensembl"); - Platform.addJ2SDirectDatabaseCall("https://rest.ensembl"); + Platform.addJ2SDirectDatabaseCall("http://rest.ensembl.org"); + Platform.addJ2SDirectDatabaseCall("https://rest.ensembl.org"); } private static final int DEFAULT_READ_TIMEOUT = 5 * 60 * 1000; // 5 minutes diff --git a/src/jalview/fts/service/pdb/PDBFTSRestClient.java b/src/jalview/fts/service/pdb/PDBFTSRestClient.java index b4bb66e..53a0415 100644 --- a/src/jalview/fts/service/pdb/PDBFTSRestClient.java +++ b/src/jalview/fts/service/pdb/PDBFTSRestClient.java @@ -20,11 +20,7 @@ */ package jalview.fts.service.pdb; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; import java.net.URI; -import java.nio.CharBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -41,17 +37,16 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.DefaultClientConfig; +import jalview.bin.Console; import jalview.datamodel.SequenceI; import jalview.fts.api.FTSData; import jalview.fts.api.FTSDataColumnI; import jalview.fts.api.FTSRestClientI; import jalview.fts.api.StructureFTSRestClientI; -import jalview.fts.core.FTSDataColumnPreferences; import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource; import jalview.fts.core.FTSRestClient; import jalview.fts.core.FTSRestRequest; import jalview.fts.core.FTSRestResponse; -import jalview.fts.service.alphafold.AlphafoldRestClient; import jalview.util.JSONUtils; import jalview.util.MessageManager; import jalview.util.Platform; @@ -69,6 +64,11 @@ public class PDBFTSRestClient extends FTSRestClient public static final String PDB_SEARCH_ENDPOINT = "https://www.ebi.ac.uk/pdbe/search/pdb/select?"; + static + { + Platform.addJ2SDirectDatabaseCall(PDB_SEARCH_ENDPOINT); + } + protected PDBFTSRestClient() { } @@ -175,7 +175,6 @@ public class PDBFTSRestClient extends FTSRestClient URI uri = webResource.getURI(); - jalview.bin.Console.outPrintln(uri); ClientResponse clientResponse = null; int responseStatus = -1; // Get the JSON string from the response object or directly from the @@ -183,8 +182,7 @@ public class PDBFTSRestClient extends FTSRestClient Map jsonObj = null; String responseString = null; - jalview.bin.Console - .outPrintln("query >>>>>>> " + pdbRestRequest.toString()); + Console.info("REST request: " + uri.toString()); if (!isMocked()) { @@ -414,10 +412,10 @@ public class PDBFTSRestClient extends FTSRestClient for (FTSDataColumnI field : diplayFields) { - // jalview.bin.Console.outPrintln("Field " + field); + // Console.outPrintln("Field " + field); String fieldData = (pdbJsonDoc.get(field.getCode()) == null) ? "" : pdbJsonDoc.get(field.getCode()).toString(); - // jalview.bin.Console.outPrintln("Field Data : " + fieldData); + // Console.outPrintln("Field Data : " + fieldData); if (field.isPrimaryKeyColumn()) { primaryKey = fieldData; @@ -441,7 +439,7 @@ public class PDBFTSRestClient extends FTSRestClient } catch (Exception e) { e.printStackTrace(); - jalview.bin.Console.outPrintln("offending value:" + fieldData); + Console.warn("offending value:" + fieldData); } } } diff --git a/src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java b/src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java index 67ed7e6..d9a5ed8 100644 --- a/src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java +++ b/src/jalview/fts/service/threedbeacons/TDBeaconsFTSRestClient.java @@ -36,6 +36,7 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.DefaultClientConfig; +import jalview.bin.Console; import jalview.datamodel.SequenceI; import jalview.fts.api.FTSData; import jalview.fts.api.FTSDataColumnI; @@ -66,6 +67,11 @@ public class TDBeaconsFTSRestClient extends FTSRestClient public static FTSRestClientI instance = null; + static + { + Platform.addJ2SDirectDatabaseCall(DEFAULT_THREEDBEACONS_DOMAIN); + } + protected TDBeaconsFTSRestClient() { } @@ -101,7 +107,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient webResource = client.resource(DEFAULT_THREEDBEACONS_DOMAIN + query); URI uri = webResource.getURI(); - jalview.bin.Console.outPrintln(uri.toString()); + Console.info("3DBeacons URL: " + uri.toString()); // Execute the REST request ClientResponse clientResponse; @@ -269,8 +275,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient String fieldData = (tdbJsonStructure.get(field.getCode()) == null) ? " " : tdbJsonStructure.get(field.getCode()).toString(); - // jalview.bin.Console.outPrintln("Field : " + field + " Data : " + - // fieldData); + // Console.outPrintln("Field : " + field + " Data : " + fieldData); if (field.isPrimaryKeyColumn()) { primaryKey = fieldData; @@ -294,8 +299,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient } catch (Exception e) { // e.printStackTrace(); - jalview.bin.Console - .outPrintln("offending value:" + fieldData + fieldData); + Console.warn("offending value:" + fieldData + fieldData); } } } diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index daaed77..fdddd32 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -30,6 +30,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.net.MalformedURLException; import java.net.URL; import java.util.Properties; @@ -38,6 +39,7 @@ import javax.swing.SwingUtilities; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; +import jalview.bin.Console; import jalview.javascript.json.JSON; /** @@ -309,7 +311,7 @@ public class Platform time = mark = t; if (msg != null) { - jalview.bin.Console.errPrintln("Platform: timer reset\t\t\t" + msg); + Console.errPrintln("Platform: timer reset\t\t\t" + msg); } break; case TIME_MARK: @@ -325,9 +327,8 @@ public class Platform } if (msg != null) { - jalview.bin.Console.errPrintln( - "Platform: timer mark\t" + ((t - time) / 1000f) + "\t" - + ((t - mark) / 1000f) + "\t" + msg); + Console.errPrintln("Platform: timer mark\t" + ((t - time) / 1000f) + + "\t" + ((t - mark) / 1000f) + "\t" + msg); } mark = t; } @@ -338,9 +339,8 @@ public class Platform case TIME_GET: if (msg != null) { - jalview.bin.Console - .errPrintln("Platform: timer dur\t" + ((t - time) / 1000f) - + "\t" + ((duration) / 1000f) + "\t" + msg); + Console.errPrintln("Platform: timer dur\t" + ((t - time) / 1000f) + + "\t" + ((duration) / 1000f) + "\t" + msg); } set = 0; break; @@ -496,7 +496,7 @@ public class Platform * info[key]; */ - jalview.bin.Console.outPrintln( + Console.outPrintln( "Platform id=" + id + " reading Info." + key + " = " + value); p.put(id + "_" + key, value); @@ -617,18 +617,31 @@ public class Platform * @author hansonr@stolaf.edu * */ - public static void addJ2SDirectDatabaseCall(String domain) + public static void addJ2SDirectDatabaseCall(String urlString) { if (isJS()) { - jalview.bin.Console.outPrintln( + String domainString = urlString; + try + { + URL url = new URL(urlString); + URL domain = new URL(url.getProtocol(), url.getHost(), + url.getPort(), ""); + domainString = domain.toString(); + } catch (MalformedURLException e) + { + Console.warn("Could not add '" + urlString + + "' in J2SDirectDatabase -- not a recognised URL"); + } + Console.outPrintln( "Platform adding known access-control-allow-origin * for domain " - + domain);/** - * @j2sNative - * - * J2S.addDirectDatabaseCall(domain); - */ + + domainString); + /** + * @j2sNative + * + * J2S.addDirectDatabaseCall(domain); + */ } } diff --git a/src/jalview/ws/dbsources/TDBeacons.java b/src/jalview/ws/dbsources/TDBeacons.java index 7326c6e..66190ca 100644 --- a/src/jalview/ws/dbsources/TDBeacons.java +++ b/src/jalview/ws/dbsources/TDBeacons.java @@ -20,7 +20,23 @@ */ package jalview.ws.dbsources; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; import java.util.Locale; +import java.util.Vector; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.stream.FactoryConfigurationError; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.stevesoft.pat.Regex; import jalview.bin.Cache; import jalview.datamodel.Alignment; @@ -32,9 +48,9 @@ import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.schemes.ResidueProperties; +import jalview.util.Platform; import jalview.util.StringUtils; import jalview.ws.seqfetcher.DbSourceProxyImpl; -import jalview.xml.binding.embl.ROOT; import jalview.xml.binding.uniprot.DbReferenceType; import jalview.xml.binding.uniprot.Entry; import jalview.xml.binding.uniprot.FeatureType; @@ -42,23 +58,6 @@ import jalview.xml.binding.uniprot.LocationType; import jalview.xml.binding.uniprot.PositionType; import jalview.xml.binding.uniprot.PropertyType; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.stream.FactoryConfigurationError; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.stevesoft.pat.Regex; - /** * This class queries the Uniprot database for sequence data, unmarshals the * returned XML, and converts it to Jalview Sequence records (including attached @@ -75,6 +74,12 @@ public class TDBeacons extends DbSourceProxyImpl private static final String DEFAULT_THREEDBEACONS_DOMAIN = "https://wwwdev.ebi.ac.uk/pdbe/pdbe-kb/3dbeacons-hub-api/uniprot/summary/"; + static + { + Platform.addJ2SDirectDatabaseCall(DEFAULT_UNIPROT_DOMAIN); + Platform.addJ2SDirectDatabaseCall(DEFAULT_THREEDBEACONS_DOMAIN); + } + /** * Constructor */ diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 69ee379..b5b3ca2 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -49,6 +49,7 @@ import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.schemes.ResidueProperties; +import jalview.util.Platform; import jalview.util.StringUtils; import jalview.ws.seqfetcher.DbSourceProxyImpl; import jalview.xml.binding.uniprot.DbReferenceType; @@ -72,6 +73,11 @@ public class Uniprot extends DbSourceProxyImpl private static final String BAR_DELIMITER = "|"; + static + { + Platform.addJ2SDirectDatabaseCall(DEFAULT_UNIPROT_DOMAIN); + } + /** * Constructor */ diff --git a/src/jalview/ws/ebi/EBIFetchClient.java b/src/jalview/ws/ebi/EBIFetchClient.java index 8aca9a2..0d3d54f 100644 --- a/src/jalview/ws/ebi/EBIFetchClient.java +++ b/src/jalview/ws/ebi/EBIFetchClient.java @@ -20,12 +20,6 @@ */ package jalview.ws.ebi; -import java.util.Locale; - -import jalview.datamodel.DBRefSource; -import jalview.util.MessageManager; -import jalview.util.Platform; - import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -35,8 +29,13 @@ import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.StringTokenizer; +import jalview.datamodel.DBRefSource; +import jalview.util.MessageManager; +import jalview.util.Platform; + /** * DOCUMENT ME! * @@ -45,6 +44,10 @@ import java.util.StringTokenizer; */ public class EBIFetchClient { + static + { + Platform.addJ2SDirectDatabaseCall("https://www.ebi.ac.uk/"); + } /** * Creates a new EBIFetchClient object. @@ -270,11 +273,6 @@ public class EBIFetchClient return null; } - static - { - Platform.addJ2SDirectDatabaseCall("https://www.ebi.ac.uk/"); - } - /** * Constructs the URL to fetch from * -- 1.7.10.2