X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblXref.java;h=4eeb97780e137c6b521941695371779137967daf;hb=c3d402372ed9c45f1e4e7a7774d8037c4b8382bb;hp=5ce18be1d433e47818bca9a8089df3892428330d;hpb=853624fb32058cccc544ae7d13af6ad4b0800b6c;p=jalview.git
diff --git a/src/jalview/ext/ensembl/EnsemblXref.java b/src/jalview/ext/ensembl/EnsemblXref.java
index 5ce18be..4eeb977 100644
--- a/src/jalview/ext/ensembl/EnsemblXref.java
+++ b/src/jalview/ext/ensembl/EnsemblXref.java
@@ -1,8 +1,29 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.ext.ensembl;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefEntry;
import jalview.util.DBRefUtils;
+import jalview.util.JSONUtils;
import java.io.BufferedReader;
import java.io.IOException;
@@ -11,10 +32,8 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
/**
@@ -68,18 +87,6 @@ class EnsemblXref extends EnsemblRestClient
return true;
}
- @Override
- protected String getRequestMimeType(boolean multipleIds)
- {
- return "application/json";
- }
-
- @Override
- protected String getResponseMimeType()
- {
- return "application/json";
- }
-
/**
* Calls the Ensembl xrefs REST endpoint and retrieves any cross-references
* ("primary_id") for the given identifier (Ensembl accession id) and database
@@ -91,83 +98,54 @@ class EnsemblXref extends EnsemblRestClient
* an Ensembl stable identifier
* @return
*/
+ @SuppressWarnings("unchecked")
public List getCrossReferences(String identifier)
{
- List result = new ArrayList();
- List ids = new ArrayList();
+ List result = new ArrayList<>();
+ List ids = new ArrayList<>();
ids.add(identifier);
- BufferedReader br = null;
- try
- {
- URL url = getUrl(identifier);
- if (url != null)
- {
- br = getHttpResponse(url, ids);
- }
- return (parseResponse(br));
- } catch (IOException e)
- {
- // ignore
- } finally
- {
- if (br != null)
- {
- try
- {
- br.close();
- } catch (IOException e)
- {
- // ignore
- }
- }
- }
-
- return result;
- }
-
- /**
- * Parses "primary_id" and "dbname" values from the JSON response and
- * constructs a DBRefEntry. Returns a list of the DBRefEntry created. Note we
- * don't parse "synonyms" as they appear to be either redirected or obsolete
- * in Uniprot.
- *
- * @param br
- * @return
- * @throws IOException
- */
- protected List parseResponse(BufferedReader br)
- throws IOException
- {
- JSONParser jp = new JSONParser();
- List result = new ArrayList();
try
{
- JSONArray responses = (JSONArray) jp.parse(br);
- Iterator rvals = responses.iterator();
+ Iterator