JAL-3829 abstract essential TDB metadata from the user configurable data array displa...
[jalview.git] / src / jalview / fts / service / threedbeacons / TDBeaconsFTSRestClient.java
index 08edcdf..ccdc525 100644 (file)
@@ -127,22 +127,23 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
     } catch (Exception e)
     {
       String exceptionMsg = e.getMessage();
-      if (exceptionMsg.contains("SocketException"))
+      if (exceptionMsg != null)
       {
-        // No internet connection
-        throw new Exception(MessageManager.getString(
-                "exception.unable_to_detect_internet_connection"));
-      }
-      else if (exceptionMsg.contains("UnknownHostException"))
-      {
-        // The server is unreachable
-        throw new Exception(MessageManager.formatMessage(
-                "exception.fts_server_unreachable", "3DB Hub"));
-      }
-      else
-      {
-        throw e;
+        if (exceptionMsg.contains("SocketException"))
+        {
+          // No internet connection
+          throw new Exception(MessageManager.getString(
+                  "exception.unable_to_detect_internet_connection"));
+        }
+        else if (exceptionMsg.contains("UnknownHostException"))
+        {
+          // The server is unreachable
+          throw new Exception(MessageManager.formatMessage(
+                  "exception.fts_server_unreachable", "3DB Hub"));
+        }
       }
+      throw e;
+      
     }
 
   }
@@ -218,8 +219,6 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
   private static FTSData getFTSData(Map<String, Object> tdbJsonStructure,
           FTSRestRequest tdbRequest)
   {
-    // TODO: consider reusing PDBFTSRestClient.getFTSData ?
-
     String primaryKey = null;
     Object[] summaryRowData;
 
@@ -274,52 +273,7 @@ public class TDBeaconsFTSRestClient extends FTSRestClient
     final String primaryKey1 = primaryKey;
     final Object[] summaryRowData1 = summaryRowData;
 
-    return new FTSData()
-    {
-
-      @Override
-      public Object[] getSummaryData()
-      {
-        return summaryRowData1;
-      }
-
-      @Override
-      public Object getPrimaryKey()
-      {
-        return primaryKey1;
-      }
-
-      /**
-       * Returns a string representation of this object;
-       */
-      @Override
-      public String toString()
-      {
-        StringBuilder summaryFieldValues = new StringBuilder();
-        for (Object summaryField : summaryRowData1)
-        {
-          summaryFieldValues.append(
-                  summaryField == null ? " " : summaryField.toString())
-                  .append("\t");
-        }
-        return summaryFieldValues.toString();
-      }
-
-      /**
-       * Returns hash code value for this object
-       */
-      @Override
-      public int hashCode()
-      {
-        return Objects.hash(primaryKey1, this.toString());
-      }
-
-      @Override
-      public boolean equals(Object that)
-      {
-        return this.toString().equals(that.toString());
-      }
-    };
+    return new TDB_FTSData(primaryKey, tdbJsonStructure, summaryRowData1);
   }
 
   // private static FTSData getFTSData(Map<String, Object> doc,