X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblInfo.java;h=895598f38ded53856555e9a5ebefafe49c7116b7;hb=c794c5033adeee182b03a5ea92c0a7495a29661f;hp=69205499287965d5f5c176591a30be58b8b6e73b;hpb=3609d4b908fa64cab35f2348401baab3347188fc;p=jalview.git diff --git a/src/jalview/ext/ensembl/EnsemblInfo.java b/src/jalview/ext/ensembl/EnsemblInfo.java index 6920549..895598f 100644 --- a/src/jalview/ext/ensembl/EnsemblInfo.java +++ b/src/jalview/ext/ensembl/EnsemblInfo.java @@ -23,7 +23,6 @@ package jalview.ext.ensembl; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefSource; -import java.io.BufferedReader; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -33,8 +32,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.json.simple.JSONArray; -import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; public class EnsemblInfo extends EnsemblRestClient @@ -110,53 +107,16 @@ public class EnsemblInfo extends EnsemblRestClient * for convenience, pre-fill ensembl.org as the domain for "ENSEMBL" */ divisions.put(DBRefSource.ENSEMBL.toUpperCase(), ensemblDomain); - - BufferedReader br = null; try { - URL url = getDivisionsUrl(ensemblGenomesDomain); - if (url != null) - { - br = getHttpResponse(url, null); - } - parseResponse(br, ensemblGenomesDomain); - } catch (IOException e) - { - // ignore - } finally - { - if (br != null) - { - try - { - br.close(); - } catch (IOException e) - { - // ignore - } - } - } - } - - /** - * Parses the JSON response to /info/divisions, and add each to the lookup map - * - * @param br - * @param domain - */ - void parseResponse(BufferedReader br, String domain) - { - JSONParser jp = new JSONParser(); - - try - { - JSONArray parsed = (JSONArray) jp.parse(br); - - Iterator rvals = parsed.iterator(); + @SuppressWarnings("unchecked") + Iterator rvals = (Iterator) getJSON(getDivisionsUrl(ensemblGenomesDomain), null, -1, MODE_ITERATOR, null); + if (rvals == null) + return; while (rvals.hasNext()) { String division = rvals.next().toString(); - divisions.put(division.toUpperCase(), domain); + divisions.put(division.toUpperCase(), ensemblGenomesDomain); } } catch (IOException | ParseException | NumberFormatException e) {