JAL-3829 belt and braces check to make sure there is a pdbe response available to...
authorJim Procter <j.procter@dundee.ac.uk>
Fri, 17 Sep 2021 10:45:37 +0000 (11:45 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Fri, 17 Sep 2021 10:45:37 +0000 (11:45 +0100)
src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java

index ff414dd..4229b72 100644 (file)
@@ -466,11 +466,14 @@ public class ThreeDBStructureChooserQuerySource
   public FTSRestResponse joinResponses(FTSRestResponse upResponse,
           FTSRestResponse pdbResponse)
   {
+    boolean hasPdbResp = lastPdbRequest != null;
+
     int idx_provider = getLastFTSRequest().getFieldIndex("Provider");
     // join on
     int idx_modelId = getLastFTSRequest().getFieldIndex("Model id");
-    int pdbIdx = lastPdbRequest.getFieldIndex("PDB Id");
-    int pdbTitle_idx = lastPdbRequest.getFieldIndex("Title");
+    int pdbIdx = hasPdbResp ? lastPdbRequest.getFieldIndex("PDB Id") : -1;
+    int pdbTitle_idx = hasPdbResp ? lastPdbRequest.getFieldIndex("Title")
+            : -1;
     int tdbTitle_idx = getLastFTSRequest().getFieldIndex("Title");
 
     List<FTSData> joinedRows = new ArrayList<FTSData>();
@@ -480,15 +483,24 @@ public class ThreeDBStructureChooserQuerySource
       String provider = (String) row.getSummaryData()[idx_provider];
       if ("PDBe".equalsIgnoreCase(provider))
       {
-        for (final FTSData pdbrow : pdbResponse.getSearchSummary())
+        if (!hasPdbResp)
+        {
+          System.out.println(
+                  "Warning: seems like we couldn't get to the PDBe search interface.");
+        }
+        else
         {
-          String pdbid = (String) pdbrow.getSummaryData()[pdbIdx];
-          if (id.equalsIgnoreCase(pdbid))
+          for (final FTSData pdbrow : pdbResponse.getSearchSummary())
           {
-            row.getSummaryData()[tdbTitle_idx] = pdbrow
-                    .getSummaryData()[pdbTitle_idx];
+            String pdbid = (String) pdbrow.getSummaryData()[pdbIdx];
+            if (id.equalsIgnoreCase(pdbid))
+            {
+              row.getSummaryData()[tdbTitle_idx] = pdbrow
+                      .getSummaryData()[pdbTitle_idx];
+            }
           }
         }
+
       }
       else
       {