JAL-3615 JAL-2656 missing import after cherrypick
[jalview.git] / src / jalview / io / FileParse.java
index 36f9290..39d8ad4 100755 (executable)
@@ -21,6 +21,7 @@
 package jalview.io;
 
 import jalview.api.AlignExportSettingsI;
+import jalview.api.AlignViewportI;
 import jalview.api.AlignmentViewPanel;
 import jalview.api.FeatureSettingsModelI;
 import jalview.util.MessageManager;
@@ -293,19 +294,35 @@ public class FileParse
   {
     errormessage = "URL NOT FOUND";
     URL url = new URL(urlStr);
-    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-    int rc = conn.getResponseCode();
-    if (rc != HttpURLConnection.HTTP_OK)
+    URLConnection _conn = url.openConnection();
+    if (_conn instanceof HttpURLConnection)
     {
-      throw new IOException(
-              "Response status from " + urlStr + " was " + rc);
+      HttpURLConnection conn = (HttpURLConnection) _conn;
+      int rc = conn.getResponseCode();
+      if (rc != HttpURLConnection.HTTP_OK)
+      {
+        throw new IOException(
+                "Response status from " + urlStr + " was " + rc);
+      }
+    } else {
+      try {
+      dataIn = checkForGzipStream(_conn.getInputStream());
+      dataName=urlStr;
+      } catch (IOException ex)
+      {
+        throw new IOException("Failed to handle non-HTTP URI stream",ex);
+      } catch (Exception ex)
+      {
+        throw new IOException("Failed to determine type of input stream for given URI",ex);
+      }
+      return;
     }
-    String encoding = conn.getContentEncoding();
-    String contentType = conn.getContentType();
+    String encoding = _conn.getContentEncoding();
+    String contentType = _conn.getContentType();
     boolean isgzipped = "application/x-gzip".equalsIgnoreCase(contentType)
             || "gzip".equals(encoding);
     Exception e = null;
-    InputStream inputStream = conn.getInputStream();
+    InputStream inputStream = _conn.getInputStream();
     if (isgzipped)
     {
       try