3253-omnibus save
[jalview.git] / src / jalview / fts / service / pdb / PDBFTSRestClient.java
index 0b5d431..87d640b 100644 (file)
@@ -20,6 +20,8 @@
  */
 package jalview.fts.service.pdb;
 
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
 import jalview.datamodel.SequenceI;
 import jalview.fts.api.FTSData;
 import jalview.fts.api.FTSDataColumnI;
@@ -53,15 +55,19 @@ import com.sun.jersey.api.client.config.DefaultClientConfig;
  * 
  * @author tcnofoegbu
  */
-public class PDBFTSRestClient extends FTSRestClient
+public class PDBFTSRestClient extends FTSRestClient implements ApplicationSingletonI
 {
-
-  private static FTSRestClientI instance = null;
-
   public static final String PDB_SEARCH_ENDPOINT = "https://www.ebi.ac.uk/pdbe/search/pdb/select?";
 
-  protected PDBFTSRestClient()
+  public static FTSRestClientI getInstance()
+  {
+    return (FTSRestClientI) ApplicationSingletonProvider
+            .getInstance(PDBFTSRestClient.class);
+  }
+
+  private PDBFTSRestClient()
   {
+    // singleton -- use getInstance()
   }
 
   /**
@@ -175,7 +181,7 @@ public class PDBFTSRestClient extends FTSRestClient
 
       // Get the JSON string from the response object or directly from the
       // client (JavaScript)
-      Map<String, Object> jsonObj = (status == 200
+      Map<String, Object> jsonObj = (Platform.isJS() && status == 200
               ? clientResponse.getEntity(Map.class)
               : null);
       String responseString = (jsonObj == null
@@ -459,15 +465,6 @@ public static String parseJsonExceptionString(String jsonErrorResponse)
     return "/fts/pdb_data_columns.txt";
   }
 
-  public static FTSRestClientI getInstance()
-  {
-    if (instance == null)
-    {
-      instance = new PDBFTSRestClient();
-    }
-    return instance;
-  }
-
   private Collection<FTSDataColumnI> allDefaultDisplayedStructureDataColumns;
 
   public Collection<FTSDataColumnI> getAllDefaultDisplayedStructureDataColumns()
@@ -482,32 +479,5 @@ public static String parseJsonExceptionString(String jsonErrorResponse)
     return allDefaultDisplayedStructureDataColumns;
   }
   
-  @SuppressWarnings("unchecked")
-public static void main(String[] args) {
-    
-    
-    // check for transpiler fix associated with JSONParser yylex.java use of charAt()
-    // instead of codePointAt()
-
-    String s = "e";
-    char c = 'c';
-    char f = 'f';
-    s += c | f; 
-    int x = c&f;
-    int y = 2 & c;
-    int z = c ^ 5;
-    String result = s +x + y + z;
-    assert (result == "e103982102");
-    try
-    {
-      Map<String, Object> jsonObj = (Map<String, Object>) JSONUtils.parse("{\"a\":3}");
-      System.out.println(jsonObj);
-    } catch (ParseException e)
-    {
-      e.printStackTrace();
-    }
-    
-  }
-  
   
 }