JAL-3193 removal of rest.ensemblgenomes.org
[jalview.git] / src / jalview / ext / ensembl / EnsemblInfo.java
index de55a53..9b97080 100644 (file)
@@ -1,7 +1,6 @@
 package jalview.ext.ensembl;
 
 import jalview.datamodel.AlignmentI;
-import jalview.datamodel.DBRefSource;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -21,22 +20,26 @@ public class EnsemblInfo extends EnsemblRestClient
 {
 
   /*
-   * cached results of REST /info/divisions service, currently
-   * <pre>
-   * { 
-   *  { "ENSEMBLFUNGI", "http://rest.ensemblgenomes.org"},
-   *    "ENSEMBLBACTERIA", "http://rest.ensemblgenomes.org"},
-   *    "ENSEMBLPROTISTS", "http://rest.ensemblgenomes.org"},
-   *    "ENSEMBLMETAZOA", "http://rest.ensemblgenomes.org"},
-   *    "ENSEMBLPLANTS",  "http://rest.ensemblgenomes.org"},
+   * cached upper-cased results of REST /info/divisions service, 
+   * currently (from April 2019)
+   *  { "ENSEMBLFUNGI", "http://rest.ensembl.org",
+   *    "ENSEMBLBACTERIA", "http://rest.ensembl.org",
+   *    "ENSEMBLPROTISTS", "http://rest.ensembl.org",
+   *    "ENSEMBLMETAZOA", "http://rest.ensembl.org",
+   *    "ENSEMBLPLANTS",  "http://rest.ensembl.org",
    *    "ENSEMBL", "http://rest.ensembl.org" }
    *  }
-   * </pre>
-   * The values for EnsemblGenomes are retrieved by a REST call, that for
-   * Ensembl is added programmatically for convenience of lookup
    */
   private static Map<String, String> divisions;
 
+  /**
+   * Constructor
+   */
+  public EnsemblInfo()
+  {
+    super();
+  }
+
   @Override
   public String getDbName()
   {
@@ -61,22 +64,9 @@ public class EnsemblInfo extends EnsemblRestClient
     return true;
   }
 
-  @Override
-  protected String getRequestMimeType(boolean multipleIds)
-  {
-    return "application/json";
-  }
-
-  @Override
-  protected String getResponseMimeType()
-  {
-    return "application/json";
-  }
-
   /**
-   * Answers the domain (http://rest.ensembl.org or
-   * http://rest.ensemblgenomes.org) for the given division, or null if not
-   * recognised by Ensembl.
+   * Answers the domain (e.g. http://rest.ensembl.org) for the given division,
+   * or null if not recognised by Ensembl
    * 
    * @param division
    * @return
@@ -92,26 +82,21 @@ public class EnsemblInfo extends EnsemblRestClient
 
   /**
    * On first request only, populate the lookup map by fetching the list of
-   * divisions known to EnsemblGenomes.
+   * divisions known to Ensembl
    */
   void fetchDivisions()
   {
     divisions = new HashMap<>();
 
-    /*
-     * for convenience, pre-fill ensembl.org as the domain for "ENSEMBL"
-     */
-    divisions.put(DBRefSource.ENSEMBL.toUpperCase(), ENSEMBL_REST);
-
     BufferedReader br = null;
     try
     {
-      URL url = getDivisionsUrl(ENSEMBL_GENOMES_REST);
+      URL url = getDivisionsUrl();
       if (url != null)
       {
         br = getHttpResponse(url, null);
       }
-      parseResponse(br, ENSEMBL_GENOMES_REST);
+      parseResponse(br);
     } catch (IOException e)
     {
       // ignore
@@ -134,15 +119,15 @@ public class EnsemblInfo extends EnsemblRestClient
    * Parses the JSON response to /info/divisions, and add each to the lookup map
    * 
    * @param br
-   * @param domain
    */
-  void parseResponse(BufferedReader br, String domain)
+  void parseResponse(BufferedReader br)
   {
     JSONParser jp = new JSONParser();
 
     try
     {
       JSONArray parsed = (JSONArray) jp.parse(br);
+      String domain = getDomain();
 
       Iterator rvals = parsed.iterator();
       while (rvals.hasNext())
@@ -157,20 +142,20 @@ public class EnsemblInfo extends EnsemblRestClient
   }
 
   /**
-   * Constructs the URL for the EnsemblGenomes /info/divisions REST service
-   * @param domain TODO
+   * Constructs the URL for the Ensembl /info/divisions REST service
    * 
    * @return
    * @throws MalformedURLException
    */
-  URL getDivisionsUrl(String domain) throws MalformedURLException
+  URL getDivisionsUrl() throws MalformedURLException
   {
-    return new URL(domain
+    return new URL(
+            getDomain()
             + "/info/divisions?content-type=application/json");
   }
 
   /**
-   * Returns the set of 'divisions' recognised by Ensembl or EnsemblGenomes
+   * Returns the set of 'divisions' recognised by Ensembl
    * 
    * @return
    */