JAL-2745 update www.ebi.ac.uk to https
[jalview.git] / src / jalview / ws / ebi / EBIFetchClient.java
index d6cad64..50151d9 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -29,6 +29,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
@@ -91,7 +92,7 @@ public class EBIFetchClient
    * @param format
    *          the format wanted
    * @param extension
-   *          for the temporary file to hold response
+   *          for the temporary file to hold response (without separator)
    * @return the file holding the response
    * @throws OutOfMemoryError
    */
@@ -102,7 +103,7 @@ public class EBIFetchClient
     File outFile = null;
     try
     {
-      outFile = File.createTempFile("jalview", ext);
+      outFile = File.createTempFile("jalview", "." + ext);
       outFile.deleteOnExit();
       fetchData(ids, format, outFile);
       if (outFile.length() == 0)
@@ -205,7 +206,14 @@ public class EBIFetchClient
     {
       URL rcall = new URL(url);
 
-      InputStream is = new BufferedInputStream(rcall.openStream());
+      HttpURLConnection conn = (HttpURLConnection) rcall.openConnection();
+      int responseCode = conn.getResponseCode();
+      if (responseCode != 200)
+      {
+        System.out.println("Warning: response code " + responseCode
+                + " for " + url);
+      }
+      InputStream is = new BufferedInputStream(conn.getInputStream());
       if (outFile != null)
       {
         FileOutputStream fio = new FileOutputStream(outFile);
@@ -267,12 +275,12 @@ public class EBIFetchClient
     if (database.equalsIgnoreCase(DBRefSource.EMBL)
             || database.equalsIgnoreCase(DBRefSource.EMBLCDS))
     {
-      url = "http://www.ebi.ac.uk/ena/data/view/" + ids.toLowerCase()
+      url = "https://www.ebi.ac.uk/ena/data/view/" + ids.toLowerCase()
               + (format != null ? "&" + format : "");
     }
     else
     {
-      url = "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/"
+      url = "https://www.ebi.ac.uk/Tools/dbfetch/dbfetch/"
               + database.toLowerCase() + "/" + ids.toLowerCase()
               + (format != null ? "/" + format : "");
     }